Convert 'colorSpec::colorSpec' objects

Usage

colorSpec2mspct(x, multiplier = 1, ...)
colorSpec2spct(x, multiplier = 1, ...)
colorSpec2chroma_spct(x, multiplier = 1, ...)
mspct2colorSpec(x, spct.data.var = NULL, multiplier = 1, ...)
spct2colorSpec(x, spct.data.var = NULL, multiplier = 1, ...)
chroma_spct2colorSpec(x, spct.data.var = NULL, multiplier = 1, ...)

Arguments

x
colorSpec object
multiplier
numeric A multiplier to be applied to the 'spc' data to do unit or scale conversion.
...
currently ignored.
spct.data.var
character The name of the variable to read spectral data from.

Description

Convert 'colorSpec::colorSpec' objects into spectral objects (xxxx_spct, xxxx_mspct) as defined in package 'photobiology' and vice veersa preserving as much information as possible.

Note

Objects of class colorSpec::colorSpec do not contain metadata or class data from which 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' but should only rarely need to use parameter spct.data.var to select the quantity.

colorSpec::colorSpec 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(colorSpec) colorSpec2mspct(Fs.5nm)
Object: source_mspct [12 x 1] --- Member: F1 --- Object: source_spct [81 x 2] Wavelength range 380 to 780 nm, step 5 nm Time unit 1s # A tibble: 81 x 2 w.length s.e.irrad <dbl> <dbl> 1 380 1.87 2 385 2.36 3 390 2.94 4 395 3.47 5 400 5.17 6 405 19.49 7 410 6.13 8 415 6.24 9 420 7.01 10 425 7.79 # ... with 71 more rows --- Member: F2 --- Object: source_spct [81 x 2] Wavelength range 380 to 780 nm, step 5 nm Time unit 1s # A tibble: 81 x 2 w.length s.e.irrad <dbl> <dbl> 1 380 1.18 2 385 1.48 3 390 1.84 4 395 2.15 5 400 3.44 6 405 15.69 7 410 3.85 8 415 3.74 9 420 4.19 10 425 4.62 # ... with 71 more rows --- Member: F3 --- Object: source_spct [81 x 2] Wavelength range 380 to 780 nm, step 5 nm Time unit 1s # A tibble: 81 x 2 w.length s.e.irrad <dbl> <dbl> 1 380 0.82 2 385 1.02 3 390 1.26 4 395 1.44 5 400 2.57 6 405 14.36 7 410 2.70 8 415 2.45 9 420 2.73 10 425 3.00 # ... with 71 more rows --- Member: F4 --- Object: source_spct [81 x 2] Wavelength range 380 to 780 nm, step 5 nm Time unit 1s # A tibble: 81 x 2 w.length s.e.irrad <dbl> <dbl> 1 380 0.57 2 385 0.70 3 390 0.87 4 395 0.98 5 400 2.01 6 405 13.75 7 410 1.95 8 415 1.59 9 420 1.76 10 425 1.93 # ... with 71 more rows --- Member: F5 --- Object: source_spct [81 x 2] Wavelength range 380 to 780 nm, step 5 nm Time unit 1s # A tibble: 81 x 2 w.length s.e.irrad <dbl> <dbl> 1 380 1.87 2 385 2.35 3 390 2.92 4 395 3.45 5 400 5.10 6 405 18.91 7 410 6.00 8 415 6.11 9 420 6.85 10 425 7.58 # ... with 71 more rows --- Member: F6 --- Object: source_spct [81 x 2] Wavelength range 380 to 780 nm, step 5 nm Time unit 1s # A tibble: 81 x 2 w.length s.e.irrad <dbl> <dbl> 1 380 1.05 2 385 1.31 3 390 1.63 4 395 1.90 5 400 3.11 6 405 14.80 7 410 3.43 8 415 3.30 9 420 3.68 10 425 4.07 # ... with 71 more rows --- Member: F7 --- Object: source_spct [81 x 2] Wavelength range 380 to 780 nm, step 5 nm Time unit 1s # A tibble: 81 x 2 w.length s.e.irrad <dbl> <dbl> 1 380 2.56 2 385 3.18 3 390 3.84 4 395 4.53 5 400 6.15 6 405 19.37 7 410 7.37 8 415 7.05 9 420 7.71 10 425 8.41 # ... with 71 more rows --- Member: F8 --- Object: source_spct [81 x 2] Wavelength range 380 to 780 nm, step 5 nm Time unit 1s # A tibble: 81 x 2 w.length s.e.irrad <dbl> <dbl> 1 380 1.21 2 385 1.50 3 390 1.81 4 395 2.13 5 400 3.17 6 405 13.08 7 410 3.83 8 415 3.45 9 420 3.86 10 425 4.42 # ... with 71 more rows --- Member: F9 --- Object: source_spct [81 x 2] Wavelength range 380 to 780 nm, step 5 nm Time unit 1s # A tibble: 81 x 2 w.length s.e.irrad <dbl> <dbl> 1 380 0.90 2 385 1.12 3 390 1.36 4 395 1.60 5 400 2.59 6 405 12.80 7 410 3.05 8 415 2.56 9 420 2.86 10 425 3.30 # ... with 71 more rows --- Member: F10 --- Object: source_spct [81 x 2] Wavelength range 380 to 780 nm, step 5 nm Time unit 1s # A tibble: 81 x 2 w.length s.e.irrad <dbl> <dbl> 1 380 1.11 2 385 0.63 3 390 0.62 4 395 0.57 5 400 1.48 6 405 12.16 7 410 2.12 8 415 2.70 9 420 3.74 10 425 5.14 # ... with 71 more rows .......................... 2 other member spectra not shown --- END ---
colorSpec2spct(Fs.5nm)
Object: source_spct [972 x 3] containing 12 spectra in long form Wavelength range 380 to 780 nm, step 5 nm Time unit 1s # A tibble: 972 x 3 w.length s.e.irrad spct.idx <dbl> <dbl> <fctr> 1 380 1.87 F1 2 385 2.36 F1 3 390 2.94 F1 4 395 3.47 F1 5 400 5.17 F1 6 405 19.49 F1 7 410 6.13 F1 8 415 6.24 F1 9 420 7.01 F1 10 425 7.79 F1 # ... with 962 more rows
colorSpec2mspct(C.5nm)
Object: source_mspct [1 x 1] --- Member: C --- Object: source_spct [93 x 2] Wavelength range 320 to 780 nm, step 5 nm Time unit 1s # A tibble: 93 x 2 w.length s.e.irrad <dbl> <dbl> 1 320 0.0001 2 325 0.0020 3 330 0.0040 4 335 0.0155 5 340 0.0270 6 345 0.0485 7 350 0.0700 8 355 0.0995 9 360 0.1290 10 365 0.1720 # ... with 83 more rows --- END ---
colorSpec2spct(C.5nm)
Object: source_spct [93 x 3] Wavelength range 320 to 780 nm, step 5 nm Time unit 1s # A tibble: 93 x 3 w.length s.e.irrad spct.idx <dbl> <dbl> <fctr> 1 320 0.0001 C 2 325 0.0020 C 3 330 0.0040 C 4 335 0.0155 C 5 340 0.0270 C 6 345 0.0485 C 7 350 0.0700 C 8 355 0.0995 C 9 360 0.1290 C 10 365 0.1720 C # ... with 83 more rows