Skip to contents

Trim tails of a spectrum based on wavelength limits, interpolating the values at the boundaries.Trimming is needed for example to remove short wavelength noise when the measured spectrum extends beyond the known emission spectrum of the measured light source. Occasionally one may want also to expand the wavelength range.

Usage

trim_tails(
  x,
  y,
  low.limit = min(x),
  high.limit = max(x),
  use.hinges = TRUE,
  fill = NULL,
  verbose = TRUE
)

Arguments

x

numeric vector of wavelengths.

y

numeric vector of values for a spectral quantity.

low.limit

smallest x-value to be kept (defaults to smallest x-value in input).

high.limit

largest x-value to be kept (defaults to largest x-value in input).

use.hinges

logical Flag indicating whether to insert "hinges" into the spectral data before integration so as to reduce interpolation errors at the boundaries of the wavebands.

fill

if fill == NULL then tails are deleted, otherwise tails of y are filled with the value of fill.

verbose

logical Use to suppress warnings.

Value

A data.frame with variables x and y.

Note

When expanding a spectrum, if fill == NULL, expansion is not performed with a warning.

Examples

head(sun.data)
#>   w.length    s.e.irrad    s.q.irrad
#> 1      293 2.609665e-06 6.391823e-12
#> 2      294 6.142401e-06 1.509586e-11
#> 3      295 2.176175e-05 5.366463e-11
#> 4      296 6.780119e-05 1.677650e-10
#> 5      297 1.533491e-04 3.807237e-10
#> 6      298 3.669677e-04 9.141478e-10
head(with(sun.data,
     trim_tails(w.length, s.e.irrad, low.limit=300)))
#>      x           y
#> 8  300 0.001264554
#> 9  301 0.002623718
#> 10 302 0.003922583
#> 11 303 0.008974134
#> 12 304 0.011655666
#> 13 305 0.017991275
head(with(sun.data,
     trim_tails(w.length, s.e.irrad, low.limit=300, fill=NULL)))
#>      x           y
#> 8  300 0.001264554
#> 9  301 0.002623718
#> 10 302 0.003922583
#> 11 303 0.008974134
#> 12 304 0.011655666
#> 13 305 0.017991275