colorSpec (version 0.5-3)

colorSpec: constructing and testing colorSpec Objects

Description

The function colorSpec is used to construct colorSpec objects.

is.colorSpec tests whether an object is a valid colorSpec object.

Usage

colorSpec( data, wavelength, quantity='auto', organization='auto' )
is.colorSpec(x)

Arguments

data
a vector or matrix of the spectrum values. In case data is a vector, there is a single spectrum and the number of points in that spectrum is the length of the vector. In case data is a matrix, the spectra are stored in the columns, so the number of points in each spectrum is the number of rows. It is OK for the matrix to have only 0 or 1 column. The column names (if any) are taken as the spectrum names. If no names are given, or if there are duplicate names, then 'S1', 'S2', ... are used. Names can also be assigned after construction too; see specnames. Row names are ignored. Compare this function with ts.
wavelength
a numeric vector of wavelengths for all the spectra. The length of this vector must be equal to NROW(data). The sequence must be increasing.
quantity
a character string giving the quantity of all spectra; see quantity for a list of possible values. In case of 'auto', a guess is made from the column names. This guess can be overridden later.
organization
a character string giving the desired organization of the returned colorSpec object. In case of 'auto', the organization is 'vector' or 'matrix' depending on data. Other possible organizations are 'df.col' or 'df.row'. The organization can be changed later, see organization for discussion of all 4 possible organizations.
x
an R object to test for validity.

Value

colorSpec returns a colorSpec object, or NULL in case of ERROR.is.colorSpec returns TRUE or FALSE. If FALSE it logs helpful reasons that x is invalid.

Details

A colorSpec object is either a vector, matrix, or data.frame. It is of S3 class 'colorSpec' with these extra attributes:
wavelength
a numeric vector of wavelengths for all the spectra. If the organization of the object is df.col, then this is absent.

quantity
a character string that gives the physical quantity of all spectra, see quantity for a list of possible values.

metadata
a list for user-defined data. The names 'path', 'header' and 'date' are already reserved; see metadata.

step.wl
step between adjacent wavelengths in nm. This is assigned only when the wavelengths are regular; see is.regular.

specname
only assigned when the organization is 'vector', in which case it is equal to the single character string name of the single spectrum. See specnames.

sequence
only assigned when the object was returned from product. It is a list of the colorSpec terms in this product.

calibration
only assigned when the object was returned from calibrate.

See Also

wavelength, quantity, metadata, step.wl, specnames, is.regular, coredata

Examples

Run this code
#  make a synthetic Gaussian bandpass filter

center = 600
wave   = 400:700
trans  = exp( -(wave-center)^2 / 20^2 )

filter.bp   = colorSpec( trans, wave, 'transmittance' )

organization( filter.bp )  # returns: [1] "vector"

specnames( filter.bp ) = "myfilter"

# and now plot it
plot( filter.bp )

Run the code above in your browser using DataCamp Workspace