Select from a list of instrument descriptors which one to use based on date of measurement.
Usage
which_descriptor(
date = lubridate::now(tzone = "UTC"),
descriptors = ooacquire::MAYP11278_descriptors,
verbose = getOption("photobiology.verbose", TRUE),
strict.calib = getOption("photobiology.strict.calib", FALSE),
entrance.optics = NULL,
...
)
Arguments
- date
Any object that
anytime::anydate()
will decode as a date or convert to a date. Used to select a descriptor containing calibration data valid for a given day.- descriptors
A named list of descriptors of the characteristics of the spectrometer including calibration data.
- verbose
Logical indicating the level of warnings wanted.
- strict.calib
Logical indicating the level of validity checks.
- entrance.optics
character The name or geometry of the diffuser or entrance optics to select. Only required when there are calibration with multiple entrance optics for the same spectrometer.
- ...
Currently ignored.
Details
Calibrations for instruments stored in a list and passed as argument
to descriptors
, also store the dates between which they are valid.
This function walks the list searching for a calibration valid for
date
. If no valid calibration is found and strict.calib =
FALSE
, the calibration valid closest in time is returned with a warning
while if no valid calibration is found and strict.calib = TRUE
an
error is triggered.
If a character string is passed as argument to date
, it must be
in a format suitable for anytime::anydate()
. One needs to be
careful with months and days of the month when supplying them as numbers,
so using months names or their abbreviations can be safer.
Note
The default argument for verbose
is for this function
TRUE
as conversion of other objects to a date may fail.
Examples
d1 <- which_descriptor()
#> Warning: Using a calibration 142 days past its validity
d1$spectrometer.sn
#> [1] "MAYP11278"
d1$entrance.optics$geometry
#> [1] "cosine"
d2 <- which_descriptor(entrance.optics = "hemispherical")
#> Warning: Using a calibration 142 days past its validity
d2$spectrometer.sn
#> [1] "MAYP11278"
d2$entrance.optics$geometry
#> [1] "hemispherical"
d3 <- which_descriptor(descriptors = ooacquire::MAYP112785_descriptors)
#> Warning: Using a calibration 142 days past its validity
d3$spectrometer.sn
#> [1] "MAYP112785"
d3$entrance.optics$geometry
#> [1] "cosine"
# gives error, as expected
# which_descriptor(descriptors = ooacquire::MAYP112785_descriptors,
# entrance.optics = "hemispherical")
# gives error
# which_descriptor(date = lubridate::now() + lubridate::years(1))