interpolate {colorSpec}R Documentation

interpolate spectra

Description

interpolate along a 1-parameter path of spectra

Usage

## S3 method for class 'colorSpec'
interpolate( x, p, pout, pname=deparse(substitute(p)) )

Arguments

x

a colorSpec object, typically with multiple spectra

p

a numeric vector with length(p)==numSpectra(x). The value p[i] is associated with the i'th spectrum in x.

pout

a numeric vector of parameter values at which interpolation of the spectra in x take place

pname

the name of the parameter p

Details

Each spectrum in x can be thought of as a point in a high-dimensional space, and each point has a real-valued parameter associated with it. The function performs natural spline interpolation on these points, one coordinate at a time. For each wavelength value it calls spline with method='natural'.

Value

interpolate(x) returns a colorSpec object y with a spectrum for each value in pout. The organization of y is 'df.row', and extradata(y) has a single column which is a copy of pout. The name of the column is pname. The names in specnames(y) are <pname>=<pout>. Other properties of y, e.g. wavelength, quantity, ..., are the same as x.
In case of ERROR, the function returns NULL.

See Also

organization, wavelength, extradata, spline

Examples

path = system.file( "extdata/stains/PhenolRed-Fig7.txt", package="colorSpec" )
wave = 350:650
phenolred = readSpectra( path, wavelength=wave )
pH = as.numeric( sub( '[^0-9]+([0-9]+)$', '\\1', specnames(phenolred) ) )
pHvec = seq(min(pH),max(pH),by=0.05)
phenolinterp = interpolate( phenolred, pH, pHvec )

[Package colorSpec version 1.5-0 Index]