# make a vector superimposing a bandpass and a bandstop filter, and of the proper length 401
vec = c( rep(1,100), 0.5, rep(0,40), .25, rep(1,50), 0.9, rep(0,100), 0.4, rep(1,107) )
# convert that vector to a colorSpec object, with a single spectrum
spec = colorSpec( vec, wavelength=380:780, quantity='transmittance', specnames='sample' )
# extract and print the 2 bands
lambda = bandRepresentation( spec ) ; print(lambda)
## $sample
## lambda1 lambda2
## BS 673.10 480.0
## BP1 521.25 572.4
# convert the 2 bands (the transition wavelengths) back to a vector of length 401
# and compare with the original vector
delta = vec - coredata( bandMaterial(lambda) )
range(delta)
## [1] -9.092727e-14 2.275957e-14
Run the code above in your browser using DataLab