addspec: Add Mismatched Spectra Together

View source: R/photom.R

addspecR Documentation

Add Mismatched Spectra Together

Description

Simple function that interpolates two non wavelength alligned spectra onto a common interpolated scheme,

Usage

addspec(wave1, flux1, wave2, flux2, extrap = "constant", waveout = NULL)

Arguments

wave1

Numeric vector; wavelength 1 in in any units (but must be the same as wave2).

flux1

Numeric vector; flux density 1 in any units (but must be the same as flux2).

wave2

Numeric vector; wavelength 2 in in any units (but must be the same as wave1).

flux2

Numeric vector; flux density 2 in any units (but must be the same as flux1).

extrap

If 'constant' then values outside the range inherit the nearest. If a numeric scalar (e.g. 0) then values outside the range inherit this value.

waveout

Numeric vector; desired output logged wavelength grid to use. If not provided then a sorted vector of wave1 and wave2 is used instead.

Details

Internally it uses the R approxfun, so if more sophisticated interpolation is necessary then other routes might be required.

Value

Data.frame; first column is observed wavelength (Angstroms) and second column is observed flux density.

Author(s)

Aaron Robotham

See Also

approxfun

Examples

plot(BC03lr$Wave, BC03lr$Zspec[[5]][100,], log='xy', type='l', xlim=c(1e3,1e7),
ylim=c(1e-4,1), xlab=BC03lr$Labels$Wavelab, ylab=BC03lr$Labels$Lumlab, col='grey')
lines(Dale_Msol$Wave, Dale_Msol$Aspec[[1]][10,], col='grey')
add=addspec(BC03lr$Wave, BC03lr$Zspec[[5]][100,],Dale_Msol$Wave,
Dale_Msol$Aspec[[1]][10,])
lines(add)

asgr/ProSpect documentation built on Feb. 21, 2025, 1:43 a.m.