Learn R Programming

photobiology (version 0.10.6)

get_peaks: Get peaks and valleys in a spectrum

Description

These functions find peaks (local maxima) or valleys (local minima) in a spectrum, using a user selectable size threshold relative to the tallest peak (global maximum). This a wrapper built on top of function peaks from package splus2R.

Usage

get_peaks(
  x,
  y,
  ignore_threshold = 0,
  span = 5,
  strict = TRUE,
  x_unit = "",
  x_digits = 3,
  na.rm = FALSE
)

get_valleys( x, y, ignore_threshold = 0, span = 5, strict = TRUE, x_unit = "", x_digits = 3, na.rm = FALSE )

Arguments

x

numeric

y

numeric

ignore_threshold

numeric Value between 0.0 and 1.0 indicating the relative size compared to tallest peak threshold below which peaks will be ignored. Negative values set a threshold so that the tallest peaks are ignored, instead of the shortest.

span

integer A peak is defined as an element in a sequence which is greater than all other elements within a window of width span centered at that element. Use NULL for the global peak.

strict

logical If TRUE, an element must be strictly greater than all other values in its window to be considered a peak.

x_unit

character Vector of texts to be pasted at end of labels built from x value at peaks.

x_digits

numeric Number of significant digits in wavelength label.

na.rm

logical indicating whether NA values should be stripped before searching for peaks.

Value

A data frame with variables w.length and s.irrad with their values at the peaks or valleys plus a character variable of labels.

See Also

Other peaks and valleys functions: find_peaks(), find_spikes(), peaks(), replace_bad_pixs(), spikes(), valleys(), wls_at_target()

Examples

Run this code
# NOT RUN {
with(sun.spct, get_peaks(w.length, s.e.irrad))
with(sun.spct, get_valleys(w.length, s.e.irrad))

# }

Run the code above in your browser using DataLab