colorSpec
is used to construct colorSpec objects. is.colorSpec
tests whether an object is a valid colorSpec object.
colorSpec( data, wavelength, quantity='auto', organization='auto' )
is.colorSpec(x)
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.NROW(data)
.
The sequence must be increasing.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.'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.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.vector
, matrix
, or data.frame
.
It is of S3 class 'colorSpec'
with these extra attributes:
wavelength
df.col
, then this is absent.
quantity
quantity
for a list of possible values.
metadata
'path'
, 'header'
and 'date'
are already reserved; see metadata
.
step.wl
is.regular
.
specname
organization
is 'vector'
, in which case it is equal to the single character string name of the single spectrum. See specnames
.
sequence
product
. It is a list of the colorSpec terms in this product.
calibration
calibrate
.
wavelength
,
quantity
,
metadata
,
step.wl
,
specnames
,
is.regular
,
coredata
# 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 DataLab