The LAMP Application

Generated by IDLdoc

single page | use frames     summary     class     fields     routine details     file attributes

lamp_mac/DIF/

rectfit.pro


NAME: RECTFIT PURPOSE: Fit the equation y=f(x) where: F(x) = A0*EXP(-z^2/2) + A3 + A4*x + A5*x^2 and z=(x-A1)/A2 A0 = height of exp, A1 = center of exp, A2 = sigma (the width). A3 = constant term, A4 = linear term, A5 = quadratic term. Terms A3, A4, and A5 are optional. The parameters A0, A1, A2, A3 are estimated and then CURVEFIT is called. CATEGORY: ?? - fitting CALLING SEQUENCE: Result = GAUSSFIT(X, Y [, A]) INPUTS: X: The independent variable. X must be a vector. Y: The dependent variable. Y must have the same number of points as X. KEYWORD INPUTS: CHISQ: Set this keyword to a named variable that will contain the value of the chi-square goodness-of-fit. ESTIMATES = optional starting estimates for the parameters of the equation. Should contain NTERMS (6 if NTERMS is not provided) elements. NTERMS = Set NTERMS to 3 to compute the fit: F(x) = A0*EXP(-z^2/2). Set it to 4 to fit: F(x) = A0*EXP(-z^2/2) + A3 Set it to 5 to fit: F(x) = A0*EXP(-z^2/2) + A3 + A4*x SIGMA: Set this keyword to a named variable that will contain the 1-sigma error estimates of the returned parameters. YERROR: The standard error between YFIT and Y. OUTPUTS: The fitted function is returned. OPTIONAL OUTPUT PARAMETERS: A: The coefficients of the fit. A is a three to six element vector as described under PURPOSE. COMMON BLOCKS: None. SIDE EFFECTS: None. RESTRICTIONS: The peak or minimum of the Gaussian must be the largest or smallest point in the Y vector. PROCEDURE: The initial estimates are either calculated by the below procedure or passed in by the caller. Then the function CURVEFIT is called to find the least-square fit of the gaussian to the data. Initial estimate calculation: If NTERMS>=4 then a constant term is subtracted first. If NTERMS>=5 then a linear term is subtracted first. If the (MAX-AVG) of Y is larger than (AVG-MIN) then it is assumed that the line is an emission line, otherwise it is assumed there is an absorbtion line. The estimated center is the MAX or MIN element. The height is (MAX-AVG) or (AVG-MIN) respectively. The width is found by searching out from the extrema until a point is found less than the 1/e value. MODIFICATION HISTORY: DMS, RSI, Dec, 1983. DMS, RSI, Jun, 1995, Added NTERMS keyword. Result is now float if Y is not double. DMS, RSI, Added ESTIMATES keyword. CT, RSI, Feb 2001: Change the way estimates are computed. If NTERMS>3 then a polynomial of degree NTERMS-4 is subtracted before estimating Gaussian coefficients. CT, RSI, Nov 2001: Slight change to above modification: Because a Gaussian and a quadratic can be highly correlated, do not subtract off the quadratic term, only the constant and linear terms. Also added CHISQ, SIGMA and YERROR output keywords.

top Rectfit

result = Rectfit(x, y, a, WEIGHTS=WEIGHTS, CHISQ=CHISQ, ESTIMATES=ESTIMATES, NTERMS=NTERMS, SIGMA=SIGMA, YERROR=YERROR, ITMAX=ITMAX)

Parameters

x
y
a

Keywords

WEIGHTS
CHISQ
ESTIMATES
NTERMS
SIGMA
YERROR
ITMAX

File attributes

Modification date: Tue Oct 1 14:42:22 2013
Lines: 164