Skip to contents

Trimming of waveband boundaries can be needed when the spectral data do not cover the whole waveband, or wavebands may have to be removed altogether.

Usage

trim_waveband(
  w.band,
  range = NULL,
  low.limit = 0,
  high.limit = Inf,
  trim = getOption("photobiology.waveband.trim", default = TRUE),
  use.hinges = TRUE,
  trunc.labels = getOption("photobiology.brief.trunc.names", default = c("]", "["))
)

Arguments

w.band

an object of class "waveband" or a list of such objects.

range

a numeric vector of length two, or any other object for which function range() will return a numeric vector of two wavelengths (nm).

low.limit

shortest wavelength to be kept (defaults to 0 nm).

high.limit

longest wavelength to be kept (defaults to Inf nm).

trim

logical (default is TRUE which trims the wavebands at the boundary, while FALSE discards wavebands that are partly off-boundary).

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.

trunc.labels

character vector of length one or two. The first string will be prepended to the waveband name and label on left truncation and the second appended on right truncation. If the vector is of length one, the same string will be used in both cases.

Value

The returned value is a waveband object or a list of waveband objects depending on whether a single waveband object or a list of waveband objects was supplied as argument to formal parameter w.band. If no waveband is retained, in the first case, a NULL waveband object is returned, and in the second case, a list of length zero is returned. If the input is a named, list, names are preserved in the returned list.

Details

This function will accept both individual wavebands or list of wavebands. When the input is a list, wavebands outside the range of the range will be removed from the list, and those partly outside the target range either "trimmed" to this edge truncated if trim = TRUE is passed or excluded if trim = FALSE). Waveband objects contain a name and a label that are used to label the returned values of calculations that make use of them. When a waveband object is truncated so that the definition changes, the name and label are also modified so that the change is visible when they are used. The name and label have a string prepended or appended, and what strings are used can be set with an R option.

Note

Modification of the name and label stored in the wavebands passed as input is done so that summaries produced with the modified objects can be recognized as different from those computed using the original definitions when the waveband objects are used. When the input is a named list, the names of the retained members of the list are not modified as these are not part of the definitions.

See also

Other trim functions: clip_wl(), trim_spct(), trim_wl()

Examples

VIS <- waveband(c(380, 760)) # manometers

trim_waveband(VIS, c(400,700))
#> ]range.380.760[ 
#> low (nm) 400 
#> high (nm) 700 
#> weighted none 
trim_waveband(VIS, low.limit = 400)
#> ]range.380.760 
#> low (nm) 400 
#> high (nm) 760 
#> weighted none 
trim_waveband(VIS, high.limit = 700)
#> range.380.760[ 
#> low (nm) 380 
#> high (nm) 700 
#> weighted none 
trim_waveband(VIS, c(400,700), trunc.labels = c(">", "<"))
#> >range.380.760< 
#> low (nm) 400 
#> high (nm) 700 
#> weighted none 
trim_waveband(VIS, c(400,700), trunc.labels = "!")
#> !range.380.760! 
#> low (nm) 400 
#> high (nm) 700 
#> weighted none