# bandSpectra: Compute Band-based Material Spectra, and Bands for Existing... In colorSpec: Color Calculations with Emphasis on Spectral Data

## Description

A band-based material spectrum is a superimposition of bandpass filters, and (optionally) a bandstop filter. The 2 functions in this topic convert a vector of numbers between 0 and 1 to a band representation, and back again.

## Usage

 ```1 2 3 4``` ```bandMaterial( lambda, wavelength=380:780 ) ## S3 method for class 'colorSpec' bandRepresentation( x ) ```

## Arguments

 `lambda` a numeric Mx2 matrix with wavelength pairs in the rows, or a vector that can be converted to such a matrix, by row. The two wavelengths in a row (the transition wavelengths) define either a bandpass or bandstop filter, and all the rows are superimposed to define the transmittance spectrum of the final material. If the 2 wavelengths are denoted by λ_1 and λ_2, and λ_1 < λ_2 then the filter is a bandpass filter. If the 2 wavelengths are swapped, then the spectrum is "flipped" and is a bandstop filter, and the band "wraps around" from long wavelengths to short. There can be at most 1 bandstop filter in the matrix, otherwise it is an error. The bands must be pairwise disjoint, otherwise it is an error. To get a material with transmittance identically 0, set `lambda` to a 0x2 matrix. To get a material with transmittance identically 1, set `lambda` to a 1x2 matrix with λ_1=β_0 and λ_2=β_N, where N is the number of wavelengths. See vignette convexity for the definition of β_0 and β_N and other mathematical details. `lambda` can also be a list of such matrices, which are processed separately, see Value. `wavelength` a vector of wavelengths for the returned object `x` a colorSpec object with `type` equal to `'material'`

## Details

`bandRepresentation()` is a right-inverse of `bandMaterial()`, see Examples and the test script `test-bands.R`. For more mathematical details, see vignette convexity.

## Value

`bandMaterial()` returns a colorSpec object with `quantity` equal to `'transmitance'`. If `lambda` is a matrix, then the object has 1 spectrum. If `lambda` is a list of matrices with length N, then the object has N spectra.

`bandRepresentation()` returns a list of matrices with 2 columns. There is a matrix in the list for each spectrum in `x`.

## See Also

`rectangularMaterial()`, vignette convexity

## Examples

 ``` 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20``` ```# 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) ##  -9.092727e-14 2.275957e-14 ```

colorSpec documentation built on June 24, 2019, 9:03 a.m.