merit.function: Compute the chi2 merit function for template fitting

Description Usage Arguments Details Value Note Author(s) See Also

Description

This function computes the noise weighted chi2 merit function for template fitting. The model is a stellar template spectrum convolved with a Gaussian or Gauss-Hermitian LOSVD. It is matched to a galaxy spectrum. The galaxy spectrum, the model spectrum and the residuals can be plotted.

Usage

1
2
3
4
merit.function(p, galaxy, template, LOSVD=c("gauss", "gh",
               "gauss-hermite"), mask = TRUE, noise = NULL,
               plot = FALSE, verbose = FALSE, return.fit = FALSE,
               sigma.max = 1000, ...)

Arguments

p

a two-component vector containing the parameters for the template fit: velocity v and velocity dispersion sigma, both in km/s.

galaxy

an object of class spectrum containing the galaxy spectrum that is to be fitted

template

an object of class spectrum containing the stellar template spectrum

LOSVD

Shape of the LOSVD to be fit to the spectrum. Defaults to Gaussian but can also be set to a Gauss-Hermite series, to order 4.

mask

a data.frame with two columns x1 and x2 giving the left and right limits of wavelength regions that are to be masked; or, the name of a file containing such a data.frame; or, a logical vector along galaxy$lambda, with TRUE for pixels that shall be included in the fit

noise

a vector along galaxy$lambda containing an estimate of the noise for each pixel; or, a single number giving the average noise value. If missing, the merit function will be unnormalized.

plot

logical. If TRUE, the galaxy spectrum will be plotted along with the model and residuals.

verbose

logical. If TRUE, informative messages will be printed

return.fit

logical. If FALSE, only the value of the merit function will be returned, otherwise a list (see below).

sigma.max

the maximum allowed value for sigma. If sigma is larger than sigma.max, the function will return NA.

...

Parameters to be passed to build.model, in particular the orders of the multiplicative and additive polynomials

Details

The value returned by this function does not seem to be a proper chi2 yet.

Value

If return.fit is FALSE, only the value of the merit function is returned. This should be the setting for optimising over the parameters. If return.fit is TRUE, a list is returned with the components

L, M

the coordinates of galaxy

gof

the value of the merit function

v, sigma, h3, h4

the kinematic parameters used in the computation of the merit function

lambda, model, residual

the model spectrum and the residuals on the wavelength vector of galaxy

mask, noise

the mask and noise vectors

lm.fit

the linear fit for the coefficients of the multiplicative and additive polynomials

Note

The chi2 is as yet not properly normalized.

Author(s)

Oliver Czoske

See Also

build.model, fit.spectrum


oczoske/slacR documentation built on May 20, 2019, 8:23 p.m.