Convert "pavo::rspec" objects

Usage

rspec2mspct(x, member.class = "reflector_spct", spct.data.var = "Rpc", multiplier = 1, ...)
rspec2spct(x, multiplier = 1, ...)

Arguments

x
rspec object
member.class
character One of the spectrum classes defined in package 'photobiology'.
spct.data.var
character The name to be used for the 'spc' data when constructing the spectral objects.
multiplier
numeric A multiplier to be applied to the 'rspc' data to do unit or scale conversion.
...
currently ignored.

Description

Convert between 'pavo::rspec' objects containing spectral reflectance data into spectral objects (xxxx_spct, xxxx_mspct) as defined in package 'photobiology'.

Note

Objects of class pavo::rspec do not contain metadata or class data from which the quantity measured and the units of expression could be obtained. When using this function the user needs to use parameter multiplier to convert the data to what is expected by the object constructors defined in package 'photobiology' and use parameter spct.data.var to select the quantity.

pavo::rspec objects may use memory more efficiently than spectral objects of the classes for collections of spectra defined in package 'photobiology' as wavelengths are assumed to be the same for all member spectra, and stored only once while this assumption is not made for collections of spectra, allowing different wavelengths and lengths for the component spectra. Wavelengths are stored for each spectrum, but as spectral classes are derived from 'tbl_df' in many cases no redundant copies of wavelength data will be made in memory in spite of the more flexible semantics of the objects.

Warning!

Always check the sanity of the imported or exported data values, as guessing is needed when matching the different classes, and the functions defined here are NOT guaranteed to return valid data wihtout help from the user through optional function arguments.

Examples

library(pavo) data(sicalis) sicalis.mspct <- rspec2mspct(sicalis) class(sicalis.mspct)
[1] "reflector_mspct" "generic_mspct" "list"
data(teal) teal.spct <- rspec2spct(teal) class(teal.spct)
[1] "reflector_spct" "generic_spct" "tbl_df" "tbl" "data.frame"
levels(teal.spct[["spct.idx"]])
[1] "Acrecca-1" "Acrecca-2" "Acrecca-3" "Acrecca-4" "Acrecca-5" "Acrecca-6" [7] "Acrecca-7" "Acrecca-8" "Acrecca-9" "Acrecca-10" "Acrecca-11" "Acrecca-12"
angles <- seq(from = 15, to = 75, by = 5) # from teal's documentation teal.spct[["angle"]] <- angles[as.numeric(teal.spct[["spct.idx"]])] teal.spct
Object: reflector_spct [4,812 x 4] containing 12 spectra in long form Wavelength range 300 to 700 nm, step 1 nm # A tibble: 4,812 x 4 w.length Rfr spct.idx angle <int> <dbl> <fctr> <dbl> 1 300 0.223388 Acrecca-1 15 2 301 0.221828 Acrecca-1 15 3 302 0.210080 Acrecca-1 15 4 303 0.215870 Acrecca-1 15 5 304 0.213067 Acrecca-1 15 6 305 0.218222 Acrecca-1 15 7 306 0.200616 Acrecca-1 15 8 307 0.222068 Acrecca-1 15 9 308 0.212346 Acrecca-1 15 10 309 0.215332 Acrecca-1 15 # ... with 4,802 more rows