fit.spectrum: Fit a galaxy spectrum with a stellar template and a Gaussian...

Description Usage Arguments Details Value Author(s) See Also

Description

This function determines velocity and velocity dispersion of a galaxy by optimizing over a merit.function given by convolving a stellar template spectrum and comparing to the galaxy spectrum in the least squares sense. The line profile can be parameterized as Gaussian or a Gauss-Hermite series of order 4.

Usage

1
2
3
4
5
6
fit.spectrum(galaxy, template, p0 = c(0, 230, 0, 0),
             LOSVD=c("gauss", "gh", "gauss-hermite"),
             noise = NULL, lambda = NULL, errors = 0, mask = NULL,
             SN.lim = 0, niter = 3, nsig = 3, verbose = FALSE,
             plot = FALSE, plot.errors = FALSE, 
             simple = FALSE, o.mult=4, o.add=6, ...)

Arguments

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

p0

four-component vector containing the starting values for the parameters that are to be determined from the template fit: velocity v and velocity dispersion sigma, both in km/s. The Gauss-Hermite coefficients h3 and h4 are ignored if LOSVD=="gauss".

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.

noise

an object of class spectrum or 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 noise will be estimated from the wavelength region lambda. If noise is a spectrum, then the wavelength component should be identical to galaxy$lambda

lambda

a two-component vector giving the limits of a wavelength region within which level, noise and signal-to-noise of the galaxy spectrum will be determined

errors

Number of Monte Carlo simulations that will be performed to give an estimate of the error distribution; defaults to zero

mask

Normally, the mask used in the fit is included in the spectrum galaxy. It is possible to specify an additional mask, which is combined with galaxy$mask by logical AND. Any format that is understood by convert.mask is allowed: 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

SN.lim

Only galaxy spectra which have signal-to-noise larger than this value will be analysed; defaults to zero, i.e. all spectra will be analysed.

niter

number of iterations in the sigma-clipping

nsig

data points with residuals larger than nsig times the standard deviation of the fit will be masked

verbose

logical. If TRUE, informative messages will be printed

plot

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

plot.errors

logical. If TRUE, then a contour plot of the merit.function in the vsigma plane will be plotted and the estimates from the error runs will be marked

simple

logical. If TRUE, a list of only scalar vectors will be returned (this is required when the function is called by fit.cube)

o.mult

order of polynomial multiplying the convolved template spectrum

o.add

order of polynomial added to the convolved template spectrum

...

Further parameters to be passed to merit.function

Details

Plotting the errors does not work yet, rewrite of gof.contours is required.

Value

An object of class kinfit. This is the original spectrum with added parameters describing the fit and its results. Of particular importance are the first and second velocity moments, v1 and v2, computed by integrating over the best-fit LOSVD.

If errors is larger than zero, the list includes summaries of the error distribution:

dv1.low, dv1.high, dv2.low, dv2.high

68% confidence levels for the first and second velocity moments

dv.low, dv.high

68% confidence limits for velocity

dsig.low, dsig.high

68% confidence limits for velocity dispersion

v1.err, v2.err, v.err, sig.err, gof.err, h3.err, h4.err

velocities, velocity dispersions and corresponding merit.function values determined from each Monte Carlo simulation (only if simple=FALSE)

Author(s)

Oliver Czoske

See Also

merit.function, fit.cube


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