colorSpec2mspct: Convert 'colorSpec::colorSpec' objects

View source: R/foreign-conversion.r

colorSpec2mspctR Documentation

Convert 'colorSpec::colorSpec' objects

Description

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

Usage

colorSpec2mspct(x, multiplier = 1, ...)

## S3 method for class 'colorSpec'
as.source_spct(x, multiplier = 1, ...)

## S3 method for class 'colorSpec'
as.source_mspct(x, multiplier = 1, ...)

## S3 method for class 'colorSpec'
as.response_spct(x, multiplier = 1, ...)

## S3 method for class 'colorSpec'
as.response_mspct(x, multiplier = 1, ...)

## S3 method for class 'colorSpec'
as.filter_spct(x, multiplier = 1, ...)

## S3 method for class 'colorSpec'
as.filter_mspct(x, multiplier = 1, ...)

## S3 method for class 'colorSpec'
as.reflector_spct(x, multiplier = 1, ...)

## S3 method for class 'colorSpec'
as.reflector_mspct(x, multiplier = 1, ...)

## S3 method for class 'colorSpec'
as.chroma_mspct(x, multiplier = 1, ...)

colorSpec2spct(x, multiplier = 1, ...)

colorSpec2chroma_spct(x, multiplier = 1, ...)

## S3 method for class 'colorSpec'
as.chroma_spct(x, multiplier = 1, ...)

## S3 method for class 'colorSpec'
as.chroma_mspct(x, multiplier = 1, ...)

## S3 method for class 'colorSpec'
as.generic_spct(x, multiplier = 1, ...)

## S3 method for class 'colorSpec'
as.generic_mspct(x, 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.

Details

Objects of class colorSpec::colorSpec do not contain metadata or class data from which the units of expression could be obtained. When using function colorSpec2mspct 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. When using as.colorSpec methods to convert collections of spectra into colorSpec objects, if the wavelengths of the individual spectra differe, only the shared range of wavelengths is retained and within the this range, wavelngth values are made consistent by interpolation.

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 without help from the user through optional function arguments.

Note

In generic_mspct objects, wavelengths are stored for each spectrum, individual generic_spct objects. However, 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.

Examples

# example run only if 'colorSpec' is available
if (requireNamespace("colorSpec", quietly = TRUE)) {
  library(colorSpec)
  colorSpec2mspct(Fs.5nm)
  colorSpec2spct(Fs.5nm)
  colorSpec2mspct(C.5nm)
  colorSpec2spct(C.5nm)
} 


photobiologyInOut documentation built on Sept. 14, 2024, 5:06 p.m.