SpringerLink
Forum Springer Astron. Astrophys.
Forum Whats New Search Orders


Astron. Astrophys. 355, 979-993 (2000)

Previous Section Next Section Title Page Table of Contents

Appendix A: the 3D Gaussian fitting program "FG3"

We have developed a computer program for the inspection and analysis of spectral line cubes. In general, a spectral line cube is a 3-dimensional (3D) array in which two of the dimensions are sky spatial coordinates (usually the right ascension [FORMULA] and the declination [FORMULA] or functions of them) and the third dimension is velocity or frequency. The cube stores the intensity distribution of the source.

In the study of astronomical maser emission, we can model the intensity distribution as produced by a number of (3D Gaussian) spots. A spatially unresolved 3D Gaussian feature can be specified by eight parameters, which are the Gaussian peak intensity ([FORMULA]), the Gaussian position center ([FORMULA]) and velocity ([FORMULA]), the full linewidth at half power ([FORMULA]) and, finally, the Gaussian spatial form, which is determined by the interferometer beam shape (more specifically by the restoring beam ); in a general case, it is a tilted ellipse specified by three parameters (the semimajor axis [FORMULA], the semiminor axis [FORMULA], and the tilting angle [FORMULA], defined, for example, counterclockwise from the X-axis to the major axis). A maser feature can be described, then, as

[EQUATION]

where

[EQUATION]

The derivatives of this 3D Gaussian function with respect to the eight parameters are

[EQUATION]

A.1. The Levenberg-Marquardt method

The modeling of the spectral line data cube in terms of 3D Gaussian features can be studied as a least-squares fitting problem, noting that the model does not depend linearly with the parameters. The intensity distribution is, in general, a non-linear function of [FORMULA] parameters (for G Gaussian components),

[EQUATION]

We are looking for a method to find these parameters (that we will represent as [FORMULA] in what follows), error estimates on them, and a statistical measure of the goodness of the fit. Following the discussion and procedures shown in Press et al. (1986), we will identify the probability of the data given the parameters (a mathematically computable number) with the likehood of the parameters given the data. A maximum likehood estimate of the model parameters is obtained by minimizing the value of chi-square ,

[EQUATION]

At the chi-square minimum, the following set of nonlinear equations must hold

[EQUATION]

for [FORMULA]. Sufficiently close to the minimum, the nonlinear expression for [FORMULA] can be well approximated by a quadratic form

[EQUATION]

where d is a M-vector, D is a M x M matrix, and a is a vector representing the parameters. Because of the nonlinear dependences, the minimization must proceed iteratively. Given the current trial parameters a cur, an improved trial solution is obtained as

[EQUATION]

and the procedure is repeated until [FORMULA] stops decreasing. If the quadratic approximation is a good one, the minimizing parameters can be written directly as

[EQUATION]

where D is the second derivative matrix (Hessian matrix).

Because we know exactly the analytical form of [FORMULA] (as it is based on a model function specified by us), we can calculate the gradient

[EQUATION]

and the Hessian matrix

[EQUATION]

Defining the curvature matrix [FORMULA], we can write Eq. A.9 as

[EQUATION]

where this set is solved for the increments [FORMULA] that, added to the current approximation [FORMULA], give [FORMULA]. On the other hand, Eq. A.8 translates to

[EQUATION]

Furthermore, the second derivatives of [FORMULA] can be neglected in the expression for [FORMULA].

The Levenberg-Marquardt method has become the standard of the nonlinear least-squares routines. It varies smoothly between the steepest descent method, used far from the minimum, and the inverse-Hessian method, used as the minimum is approached. By using [FORMULA] and defining a new matrix

[EQUATION]

we can rewrite

[EQUATION]

so when [FORMULA] gets very large, the matrix [FORMULA] becomes diagonally dominant, however when [FORMULA] approaches zero, we recover Eq. (A.11).

The Levenberg-Marquardt method for obtaining the set of parameters a that minimize [FORMULA] and produce the best fit of the model to our data is:

  • Select a set a of initial trial parameters.

  • Calculate [FORMULA].

  • Set a modest value for [FORMULA], say [FORMULA].

  • ([FORMULA]) Solve the linear equations for [FORMULA] and evaluate [FORMULA].

  • If [FORMULA] then increase [FORMULA] and return to ([FORMULA]). Otherwise, decrease [FORMULA], update the trial solution [FORMULA], and go back to ([FORMULA]).

The iteration process can stop the second time [FORMULA] decreases by a negligible amount. Once the acceptable minimum has been found,

[EQUATION]

is the estimated covariance matrix of the standard errors in the fitted parameters a , calculated by setting [FORMULA].

A.2. Implementation

We have written a computer program to implement the Levenberg-Marquardt method of fitting for the parameters [FORMULA] that minimize [FORMULA], providing the best fit of the resulting model to our data (see Colomer 1996). The program is fed with the spectral line data stored in FITS format, and performs the fitting to a user-defined function (in our case 3D Gaussians), plus a variety of functions such as guessing of initial parameters, RMS calculation, plotting of data and fitted solutions, model substraction and inspection of residuals, etc.

The power of "FG3" is shown in Figs. A.1 and A.2.

[FIGURE] Fig. A1. Spectrum (intensity in Jy as a function of velocity in km s-1) of the H2O masers towards R Crt. (Bottom) Individual Gaussians as obtained by "FG3". (Top) Sum of all Gaussian features, reproducing the observed spectrum.

[FIGURE] Fig. A2. Same as Fig. A.1, at position [FORMULA].

A.3. Using constraints on the parameters

The process of modeling the intensity distribution of a spectral line source as a function of G tridimensional Gaussian sources requires, in our general case, to find [FORMULA] parameters. Sometimes, however, we have additional information that constrains the values those parameters can take. One obvious example is the spatial beam axis [FORMULA] and [FORMULA], and the tilting angle [FORMULA], that we can keep fixed to those of the restoring beam used to obtain the CLEANed data cube for spatially unresolved maser spots.

In other cases, the iterative process may diverge due to an "unfortunate" step in the parameter searching process. We might want to force any parameter value to remain within a given range (what we will call the selected accuracy of that parameter, [FORMULA]). The way to implement this effect is to calculate [FORMULA] in two parts, one involving how well the model fits the data (as before), and another involving how close the current parameter values are to the initial ones. One has to be careful, however, as both contributions are not of the same order of magnitude (there are N data points, but only P parameters), and can only be added if they are normalized before in some way. If we want that every [FORMULA] parameter [FORMULA] changes in an iteration counts the same as every [FORMULA] the intensity [FORMULA] changes, we need to multiply the selected accuracy contribution by the number of data points N, so that

[EQUATION]

In order not to use the selected accuracy feature, it will be enough to assign a large value to [FORMULA], and that term will not contribute to [FORMULA].

A.4. Notes on the reliability of the solutions

The Levenberg-Marquardt method solves a nonlinear problem by an approximation that has some limitations. First, the fitting procedure converges only if the initial values for the parameters are sufficiently close to the real ones. This limitation is overcome in the code by the parameter guessing routines. The number of Gaussian features to fit is a user input parameter, and inspection of the fit residuals is needed to select which value of such number is best. On the other hand, artifacts may appear when the user specifies a very unapropriate number of Gaussians to fit: a number too large produces very narrow features without any physical meaning, while a number too low results in features of large linewidths. Such features can also be seen in regions of low intensity, as a consequence of the large residuals obtained.

The mathematical solutions should thus be inspected to check that these solutions correspond to real features. One test would be that the fitted Gaussian is associated with a spatial or velocity peak in the data. Uncertain solutions are marked in Tables 2 to 6, and should be used with caution.

Previous Section Next Section Title Page Table of Contents

© European Southern Observatory (ESO) 2000

Online publication: March 21, 2000
helpdesk.link@springer.de