Skip to contents

Check that an R object contains the expected data members and within range values in them. For wavelengths also check if ordered and if unique or not.

Usage

check_spct(x, byref, strict.range, force = FALSE, ...)

# Default S3 method
check_spct(x, byref = FALSE, strict.range = NA, force = FALSE, ...)

# S3 method for class 'generic_spct'
check_spct(
  x,
  byref = TRUE,
  strict.range = NA,
  force = FALSE,
  multiple.wl = getMultipleWl(x),
  ...
)

# S3 method for class 'calibration_spct'
check_spct(
  x,
  byref = TRUE,
  strict.range = getOption("photobiology.strict.range", default = FALSE),
  force = FALSE,
  multiple.wl = getMultipleWl(x),
  ...
)

# S3 method for class 'raw_spct'
check_spct(
  x,
  byref = TRUE,
  strict.range = getOption("photobiology.strict.range", default = FALSE),
  force = FALSE,
  multiple.wl = getMultipleWl(x),
  ...
)

# S3 method for class 'cps_spct'
check_spct(
  x,
  byref = TRUE,
  strict.range = getOption("photobiology.strict.range", default = FALSE),
  force = FALSE,
  multiple.wl = getMultipleWl(x),
  ...
)

# S3 method for class 'filter_spct'
check_spct(
  x,
  byref = TRUE,
  strict.range = getOption("photobiology.strict.range", default = FALSE),
  force = FALSE,
  multiple.wl = getMultipleWl(x),
  ...
)

# S3 method for class 'solute_spct'
check_spct(
  x,
  byref = TRUE,
  strict.range = getOption("photobiology.strict.range", default = FALSE),
  force = FALSE,
  multiple.wl = getMultipleWl(x),
  ...
)

# S3 method for class 'reflector_spct'
check_spct(
  x,
  byref = TRUE,
  strict.range = getOption("photobiology.strict.range", default = FALSE),
  force = FALSE,
  multiple.wl = getMultipleWl(x),
  ...
)

# S3 method for class 'object_spct'
check_spct(
  x,
  byref = TRUE,
  strict.range = getOption("photobiology.strict.range", default = FALSE),
  force = FALSE,
  multiple.wl = getMultipleWl(x),
  ...
)

# S3 method for class 'response_spct'
check_spct(
  x,
  byref = TRUE,
  strict.range = NA,
  force = FALSE,
  multiple.wl = getMultipleWl(x),
  ...
)

# S3 method for class 'source_spct'
check_spct(
  x,
  byref = TRUE,
  strict.range = getOption("photobiology.strict.range", default = FALSE),
  force = FALSE,
  multiple.wl = getMultipleWl(x),
  ...
)

# S3 method for class 'chroma_spct'
check_spct(
  x,
  byref = TRUE,
  strict.range = getOption("photobiology.strict.range", default = FALSE),
  force = FALSE,
  multiple.wl = getMultipleWl(x),
  ...
)

Arguments

x

An R object

byref

logical indicating if new object will be created by reference or by copy of x

strict.range

logical indicating whether off-range values result in an error instead of a warning, with NA a message is issued on failure.

force

logical If TRUE check is done even if checks are disabled.

...

additional parameters possible in derived methods

multiple.wl

numeric Maximum number of repeated w.length entries with same value.

Details

These methods are exported and can be called by user code if needed, for example, when the checks have been disabled by setting an R option with disable_check_spct.

Methods (by class)

  • check_spct(default): Default for generic function.

  • check_spct(generic_spct): Specialization for generic_spct.

  • check_spct(calibration_spct): Specialization for calibration_spct.

  • check_spct(raw_spct): Specialization for raw_spct.

  • check_spct(cps_spct): Specialization for cps_spct.

  • check_spct(filter_spct): Specialization for filter_spct.

  • check_spct(solute_spct): Specialization for solute_spct.

  • check_spct(reflector_spct): Specialization for reflector_spct.

  • check_spct(object_spct): Specialization for object_spct.

  • check_spct(response_spct): Specialization for response_spct.

  • check_spct(source_spct): Specialization for source_spct.

  • check_spct(chroma_spct): Specialization for chroma_spct.

See also

Other data validity check functions: check_spectrum(), check_w.length(), enable_check_spct()

Examples

check_spct(sun.spct)
#> Object: source_spct [522 x 3]
#> Wavelength range 280-800 nm, step 0.9230769-1 nm 
#> Label: sunlight, simulated 
#> Measured on 2010-06-22 09:51:00 UTC 
#> Measured at 60.20911 N, 24.96474 E; Kumpula, Helsinki, FI 
#> Variables:
#>  w.length: Wavelength [nm]
#>  s.e.irrad: Spectral energy irradiance [W m-2 nm-1]
#>  s.q.irrad: Spectral photon irradiance [mol s-1 m-2 nm-1] 
#> --
#> # A tibble: 522 × 3
#>    w.length s.e.irrad s.q.irrad
#>       <dbl>     <dbl>     <dbl>
#>  1     280          0         0
#>  2     281.         0         0
#>  3     282.         0         0
#>  4     283.         0         0
#>  5     284.         0         0
#>  6     285.         0         0
#>  7     286.         0         0
#>  8     286.         0         0
#>  9     287.         0         0
#> 10     288.         0         0
#> # ℹ 512 more rows

check_spct(sun.spct)
#> Object: source_spct [522 x 3]
#> Wavelength range 280-800 nm, step 0.9230769-1 nm 
#> Label: sunlight, simulated 
#> Measured on 2010-06-22 09:51:00 UTC 
#> Measured at 60.20911 N, 24.96474 E; Kumpula, Helsinki, FI 
#> Variables:
#>  w.length: Wavelength [nm]
#>  s.e.irrad: Spectral energy irradiance [W m-2 nm-1]
#>  s.q.irrad: Spectral photon irradiance [mol s-1 m-2 nm-1] 
#> --
#> # A tibble: 522 × 3
#>    w.length s.e.irrad s.q.irrad
#>       <dbl>     <dbl>     <dbl>
#>  1     280          0         0
#>  2     281.         0         0
#>  3     282.         0         0
#>  4     283.         0         0
#>  5     284.         0         0
#>  6     285.         0         0
#>  7     286.         0         0
#>  8     286.         0         0
#>  9     287.         0         0
#> 10     288.         0         0
#> # ℹ 512 more rows
# try(check_spct(-sun.spct))
# try(check_spct((sun.spct[1, "w.length"] <- 1000)))