colorSpec {colorSpec} | R Documentation |
constructing and testing colorSpec Objects
Description
The function colorSpec()
is the constructor for colorSpec objects.
is.colorSpec()
tests whether an object is a valid colorSpec object.
as.colorSpec()
converts other variables to a colorSpec object,
and is designed to be overridden by other packages.
Usage
colorSpec( data, wavelength, quantity='auto', organization='auto', specnames=NULL )
is.colorSpec(x)
## Default S3 method:
as.colorSpec( ... )
Arguments
data |
a vector or matrix of the spectrum values.
In case |
wavelength |
a numeric vector of wavelengths for all the spectra, in nm.
The length of this vector must be equal to |
quantity |
a character string giving the |
organization |
a character string giving the desired organization
of the returned colorSpec object.
In case of |
specnames |
a character vector with length equal to the number of spectra,
and with no duplicates.
If |
x |
an R object to test for being a valid colorSpec object. |
... |
arguments for use in other packages. |
Details
Under the hood, 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 named list for user-defined data. The names
'path'
,'header'
and'date'
are already reserved; seemetadata()
.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. Note that the wordspecname
is singular. Also seespecnames()
.
And there are a few more attributes that exist only in special cases; see the colorSpec User Guide.
Value
colorSpec()
returns a colorSpec object, or NULL
in case of ERROR.
Compare this function with stats::ts()
.
is.colorSpec()
returns TRUE
or FALSE
.
It does more than check the class
,
and also checks wavelength
, quantity
, and organization
.
If FALSE
, it logs (at loglevel='DEBUG'
)
the reason that x
is invalid.
as.colorSpec.default()
issues an ERROR message and returns NULL
See Also
wavelength
,
quantity
,
organization
,
metadata
,
step.wl
,
specnames
,
is.regular
,
coredata
Examples
# make a synthetic Gaussian bandpass filter
center = 600
wave = 400:700
trans = exp( -(wave-center)^2 / 20^2 )
filter.bp = colorSpec( trans, wave, quantity='transmittance', specnames='myfilter' )
organization( filter.bp ) # returns: "vector"
# and now plot it
plot( filter.bp )