Skip to contents

Calculates the ratio between intensities at numerator and denominator wavenumbers for every spectrum in an OpenSpecy object.

Usage

peak_ratio(x, ...)

# Default S3 method
peak_ratio(x, ...)

# S3 method for class 'OpenSpecy'
peak_ratio(x, numerator, denominator, method = c("nearest", "linear"), ...)

Arguments

x

an OpenSpecy object.

numerator

a finite numeric scalar giving the numerator wavenumber.

denominator

a finite numeric scalar giving the denominator wavenumber.

method

character; use "nearest" to select measured points or "linear" to interpolate between adjacent measured points.

...

additional arguments passed to methods.

Value

A named numeric vector with one ratio per spectrum. Names and order match the columns of x$spectra. Ratios with a zero denominator or a non-finite numerator, denominator, or result are returned as NA.

Details

This function evaluates intensities at two user-supplied points; it does not search for local maxima. With method = "nearest", a point exactly halfway between two measured wavenumbers uses the lower wavenumber. Linear interpolation is confined to the two adjacent measured points and never extrapolates beyond the shared wavenumber axis.

For an area-over-area ratio, calculate the numerator and denominator from explicit ranges with area_under_band() and divide the two returned vectors. Named area-under-band indices remain available through that function's index argument.

See also

area_under_band() for individual band areas and named area-over-area indices.

Examples

data("raman_hdpe")
peak_ratio(raman_hdpe, numerator = 2880, denominator = 2840)
#> intensity 
#>   1.90099 
peak_ratio(raman_hdpe, numerator = 2880, denominator = 2840,
           method = "linear")
#> intensity 
#>  2.024691