Gaussfit {rvmethod} | R Documentation |
Fit Gaussians to Absorption Features of a Normalized Spectrum
Description
This function takes a spectrum, which ideally is a high signal-to-noise template
spectrum estimated with the estimate_template
function, and the
absorption features found with the findabsorptionfeatures
function
and uses nonlinear least-squares to fit Gaussians to the features. This follows
the procedure described in Holzer et al. (2020).
Usage
Gaussfit(wvl, flx, ftrs, cores = 1, mse_max1 = 0.00014, mse_max2 = 1e-04)
Arguments
wvl |
vector of wavelengths of the spectrum |
flx |
vector of normalized flux of the spectrum |
ftrs |
a list of length 2 vectors that each give the lower and upper bounds of found absorption features. The |
cores |
the integer count of cores to parallelize over. If set to 1, no parallelization is done. |
mse_max1 |
the maximum mean squared error required for a fit from one Gaussian to be considered a good fit for an absorption feature |
mse_max2 |
the maximum mean squared error required for a fit of two Gaussians to be considered a good fit for an absorption feature |
Value
a list with the following components:
parameters |
a dataframe with the wavelength bounds, fitted amplitude, fitted center, fitted spread, and fit type for absorption features with a good fit. A fit type of 0 indicates that the feature had a good fit of a single Gaussian. A fit type of 1 indicates that the feature did not have a good fit with a single Gaussian initially, but after fitting with two it did. |
fitted |
the vector of fitted values (with the same length as the
|
goodfits |
a vector of the indices for which rows in the |
mse |
a vector with the mean squared error for each of the features in
the |
Examples
data(template)
ftrs = findabsorptionfeatures(template$Wavelength,
template$Flux,
pix_range = 8, gamma = 0.05,
alpha = 0.07, minlinedepth = 0.015)
gapp = Gaussfit(template$Wavelength, template$Flux, ftrs)
plot(template$Wavelength, template$Flux)
lines(template$Wavelength, gapp$fitted, col=2)