Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

thin_wl

Thin the density of wavelength values


Description

Increase the wavelength step in stored spectral data in featureless regions to save storage space.

Usage

thin_wl(x, ...)

## Default S3 method:
thin_wl(x, ...)

## S3 method for class 'generic_spct'
thin_wl(x, max.wl.step = 10, max.slope.delta = 0.001, col.names, ...)

## S3 method for class 'source_spct'
thin_wl(
  x,
  max.wl.step = 10,
  max.slope.delta = 0.001,
  unit.out = getOption("photobiology.radiation.unit", default = "energy"),
  ...
)

## S3 method for class 'response_spct'
thin_wl(
  x,
  max.wl.step = 10,
  max.slope.delta = 0.001,
  unit.out = getOption("photobiology.radiation.unit", default = "energy"),
  ...
)

## S3 method for class 'filter_spct'
thin_wl(
  x,
  max.wl.step = 10,
  max.slope.delta = 0.001,
  qty.out = getOption("photobiology.filter.qty", default = "transmittance"),
  ...
)

## S3 method for class 'reflector_spct'
thin_wl(x, max.wl.step = 10, max.slope.delta = 0.001, ...)

## S3 method for class 'raw_spct'
thin_wl(x, max.wl.step = 10, max.slope.delta = 0.001, col.names, ...)

## S3 method for class 'cps_spct'
thin_wl(x, max.wl.step = 10, max.slope.delta = 0.001, col.names, ...)

## S3 method for class 'object_spct'
thin_wl(x, max.wl.step = 10, max.slope.delta = 0.001, col.names, ...)

## S3 method for class 'chroma_spct'
thin_wl(x, ...)

## S3 method for class 'calibration_spct'
thin_wl(x, ...)

## S3 method for class 'generic_mspct'
thin_wl(x, max.wl.step = 10, max.slope.delta = 0.001, ...)

## S3 method for class 'chroma_mspct'
thin_wl(x, ...)

## S3 method for class 'calibration_mspct'
thin_wl(x, ...)

Arguments

x

An R object

...

additional named arguments passed down to f.

max.wl.step

numeric. Largest allowed wavelength difference between adjacent spectral values in nanometres (nm).

max.slope.delta

numeric in 0 to 1. Largest allowed change in relative slope of the spectral quantity per nm betweem adjacent pairs of values.

col.names

character. Name of the column of x containing the spectral data to check against max.slope.delta. Currently only one column supported.

unit.out

character Allowed values "energy", and "photon", or its alias "quantum".

qty.out

character Allowed values "transmittance", and "absorbance".

Details

The algorithm used for spectra is "naive" in an effort to keep it efficient. It works by iteratively attempting to delete every other observation along wavelengths, based on the criteria for maximum wavelength step and maximum relative step in the spectral variable between adjacent data values.

Value

An object of the same class as x but with a reduced density of wavelength values in those regions were slope is shallow and featureless.

Methods (by class)

  • default: Default for generic function

  • generic_spct:

  • source_spct:

  • response_spct:

  • filter_spct:

  • reflector_spct:

  • raw_spct:

  • cps_spct:

  • object_spct:

  • chroma_spct:

  • calibration_spct:

  • generic_mspct:

  • chroma_mspct:

  • calibration_mspct:

Note

The value of max.slope.delta is expressed as relative change in the slope of spectral variable per nanometre. This means that values between 0.0005 and 0.005 tend to work reasonably well. The best value will depend on the wavelength step of the input and noise in data. A moderate smoothing before thinning can sometimes help in the case of noisy data. The amount of thinning is almost always less than the value of criteria passed as argument as it is based on existing wavelength values. For example if we start with a spectrum with a uniform wavelength step of 1 nm, possible steps in the thinned spectrum are 2, 4, 8, 16, 32, etc. nm. The algorithm, does work with any step sizes, regular or variable in the input. Thinning is most effective for spectra with large "featureless" regions as the algorithm attempts not to discard information, contrary to smoothing or interpolation.

See Also

Other experimental utility functions: collect2mspct(), drop_user_cols(), uncollect2spct()

Examples

nrow(yellow_gel.spct)
wl_stepsize(yellow_gel.spct)
thinned.spct <- thin_wl(yellow_gel.spct)
nrow(thinned.spct)
wl_stepsize(thinned.spct)

photobiology

Photobiological Calculations

v0.10.10
GPL (>= 2)
Authors
Pedro J. Aphalo [aut, cre] (<https://orcid.org/0000-0003-3385-972X>), Titta K. Kotilainen [ctb] (<https://orcid.org/0000-0002-2822-9734>), Glenn Davis [ctb], Agnese Fazio [ctb]
Initial release
2022-03-24

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.