From the unix operating system to access ez_fit as a stand alone program by entering :
ezfit
In order to access ez_fit from other IDL program, a user has to make sure that the following environment variable is set before invoking IDL :
setenv EPICS_EXTENSIONS /usr/local/epics/extensions
and make sure including the directory /usr/local/epics/extensions/bin/$HOST_ARCH in his/her IDL search path.
NAME:
COMFITGRAF
PURPOSE:
This routine packages the IDL gradient-expansion least
square fit COMFIT function to fit the paired data {x(i), y(i)}.
Then calls PLOT1D to graph the calculated results with the raw
data in a pop-up window.
CATEGORY:
Curve fitting with plot.
CALLING SEQUENCE:
COMFITGRAF, X, Y [,A] [,YFIT] [,SIGMA] ,/FIT_TYPE [,/PRINT] [,/TEST]
INPUTS:
X: Position X vector of type integer, float or double.
Y: Data value Y vector of type integer, float or double.
A: Optional input, initial estimates of fitting coefficients.
Number of elements in A depends on the FIT_TYPE specified.
If A given, the number of elements in A must be consistant
with the FIT_TYPE entered.
KEYWORD PARAMETERS:
FIT_TYPE: Six type of COMFIT, it can be any of following
EXPONENTIAL Y = a0 * a1^x + a2
GEOMETRIC Y = a0 * x^a1 + a2
GOMPERTZ Y = a0 * a1^(a2*x) + a3
HYPERBOLIC Y = 1./(a0 + a1*x)
LOGISTIC Y = 1./(a0 * a1^x + a2)
LOGSQUARE Y = a0 + a1*alog10(x) + a2 * alog10(x)^2
PRINT: Specifies whether the output window will be poped up.
TEST: Specifies whether the default test data will be used.
OPTIONAL OUTPUTS:
YFIT: Y vector calculated from the fitted equation.
SIGMA: Standard deviation for the parameters in A.
SIDE EFFECTS:
The computed parameters and the convergence may depend on the data and
the initial parameters of A vector entered.
RESTRICTIONS:
The number of parameters must match exactly to the FIT_TYPE specified.
PROCEDURE:
Before accessing this routine, the 'ez_fit.pro' must be loaded into
IDL and the path to 'ez_fit.pro' must be in the IDL search path.
EXAMPLE:
Run the geometric fitting, and pops up the fitting result window
X = [ ...]
Y = [ ...]
A = [ 0.5, 0.5, 0.5]
COMFITGRAF,X,Y,A,/GEOMETRIC,/PRINT
MODIFICATION HISTORY:
Written by: Ben-chin K. Cha, 08-13-97.
xx-xx-xxbkc comment
(See ez_fit.pro)
NAME:
CURVEFITGRAF
PURPOSE:
Then calls PLOT1D to graph the calculated results with the raw
data in a pop-up window.
CATEGORY:
Curve fitting with plot.
CALLING SEQUENCE:
CURVEFITGRAF,X,Y,Weights [,A ] [,Sigma] [,/PRINT] $
[,FUNCTION_NAME='funct'] $
[,/NODERIVATIVE] [,ITMAX=20] [,TOL=1.e-3]
INPUTS:
X: Position X vector
Y: Data value Y vector
Weights: A row vector of weights, the same length as Y. Defaults to 1.
Instrumental weighting-Gaussian : Weights(i) = 1./sigma(i) ^2
Statistical weighting-Poisson : Weights(i) = 1./y(i)
A: The coefficients of the fit. The number of elements in A
must be exactly the same as that defined in the function_name.
If not specified, the fitting function should provide the
initial default.
KEYWORD PARAMETERS:
PRINT: Specifies whether the output window will be poped up.
FUNCTION_NAME: The name of the procedure function to fit. If omitted,
NODERIVATIVE: If this keyword is set then the partial derivatives will be
calculated by CURVEFIT by forward differences. Otherwise
the procedure function should provide the partial
derivatives calculation. Defaults nodevivative is not set.
The procedure function must be written as in 'FUNCT' as
described in IDL 'CURVEFIT' restrictions.
ITMAX: Maximum number of iterations. Default = 20.
TOL: The convergence tolerance. Default = 1.e-3. The routine
returns when the relative decrease in chi-squared is less
than TOL.
OPTIONAL OUTPUTS:
A: Returns the coefficients of the fit.
Sigma: A vector of standard deviations for the parameters in A.
RESTRICTIONS:
The function to be fit must be defined and called FUNCT,
unless the FUNCTION_NAME keyword is supplied. This function,
(actually written as a procedure) must accept values of
X (the independent variable), and A (the fitted function's
parameter values), and return F (the function's value at
X), and PDER (a 2D array of partial derivatives).
For an example, see FUNCT in the IDL User's Libaray.
A call to FUNCT is entered as:
FUNCT, X, A, F, PDER
where:
X = Variable passed into CURVEFIT. It is the job of the user-written
function to interpret this variable.
A = Vector of NTERMS function parameters, input.
F = Vector of NPOINT values of function, y(i) = funct(x), output.
PDER = Array, (NPOINT, NTERMS), of partial derivatives of funct.
PDER(I,J) = DErivative of function at ith point with
respect to jth parameter. Optional output parameter.
PDER should not be calculated if the parameter is not
supplied in call. If the /NODERIVATIVE keyword is set in the
call to CURVEFIT then the user routine will never need to
calculate PDER.
PROCEDURE:
Before accessing this routine, the 'ez_fit.pro' must be loaded into
IDL and the path to 'ez_fit.pro' must be in the IDL search path.
For more information please refer the PROCEDURE section of the
CURVEFIT in IDL online help.
EXAMPLE:
X = [ ...]
Y = [ ...]
CURVEFITGRAF,X,Y,Weights,A,Sigma,/PRINT
For more information please refer the EXAMPLE section of the CURVEFIT
in IDL online help.
MODIFICATION HISTORY:
Written by: Ben-chin K. Cha, 10-15-97.
xx-xx-xxbkc comment
(See ez_fit.pro)
NAME:
EZ_FIT
PURPOSE:
This routine integrates all the IDL line fitting routines into one
single package. It provides the IDL user with a very easy to use
line fitting tool. It is a standalone widget application. It can
be easily plug into any other IDL program.
It accepts 1D or 2D arrays either from the input binary file or
directly from the command line. It also accepts the spreadsheet
column type ascii input file.
It allows the user to select any vector from the input data and
perform any fitting he/she desires. It lets the user easily
get the hardcopy of fitting graph and tabulated data.
CATEGORY:
Curve fitting Widgets application.
CALLING SEQUENCE:
EZ_FIT
KEYWORD PARAMETERS:
XARRAY: Specifies the independent varialbe X vector if input to be
entered from the command line.
YARRAY: Specifies the dependent varialbe Y array if input to be
entered from the command line. It is used by 1D or 2D data.
For 2D image data, the YARRAY represents the Y vector of the
second dimension.
For 1D data, multiple data vectors can be packed into Y array.
The Y(N,M), the N must have the same dimension as in X vector.
the M represents the number of dependent variables in Y array.
A user can use the cursor in the image area to select the
dependent variable to be fitted, or use the J text field
to specify the dependent variable to be fitted..
IM: Specifies the 2D image array corresponding to XARRAY and
YARRAY. IMAGE(N,M), where dimenstion N is the same as the
number of elements in XARRAY, M is the same as the number
of elements in YARRAY.
GROUP: The widget ID of the group leader of the widget. If this
keyword is specified, the death of the group leader results
in the death of EZ_FIT.
OUTPUTS:
Pops up plot and list window to show fitting results with respect
to the input data.
COMMON BLOCKS:
COMMON EZ_FIT_BLOCK,ezfitData,image
SIDE EFFECTS:
It uses the PLOT1D and XDISPLAYFILE program to show the fitting results.
RESTRICTIONS:
Input binary file must be created by the U_OPERW and U_WRITE rountines.
The input data is in platform independent XDR binary format.
Default input file filter for 1D data is '*.bin1d', the default
input file filter for 2D data is '*.bin'. User may override this
default setting in the file selection dialog.
Input 1D file should contains only two binary objects XARRAY and
YARRAY. Input 2D file should contains only 3 binary objects XARRAY
YARRAY and IMAGE.
Input ASCII type file should contain columns of input data. It
uses the W_READASCII to read in columns of data. The first column
will be independent variable, the remaining columns will be dependent
variables.
EXAMPLE:
Example 1 - Use the File->Open to load input data
EZ_FIT
Example 2 - Use the X,Y keywords to load 1D data
EZ_FIT,XARRAY=X, YARRAY=Y
Example 3 - Use the keywords to load 2D data
EZ_FIT,XARRAY=X, YARRAY=Y, IM=image
MODIFICATION HISTORY:
Written by: Ben-chin K. Cha, 09-12-97.
02-27-98 Inherit color tables from the calling program
(See ez_fit.pro)
NAME:
GAUSSFITGRAF
PURPOSE:
This routine uses the IDL GAUSSIAN fit function 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.
Then calls PLOT1D to graph the calculated results with the raw
data in a pop-up window.
CATEGORY:
Curve fitting with plot.
CALLING SEQUENCE:
GAUSSFITGRAF,X,Y [,A ] [,ESTIMATES=extimates] [,NTERMS=nterms] [,/PRINT]
INPUTS:
X: Position X vector
Y: Data value Y vector
KEYWORD PARAMETERS:
ESTIMATES: Optional starting estimates for the parameters of the
equation. Should contain NTERMS (6 if NTERMS is not
provided) elements.
NTERMS: Set NTERMS of parameters used in Gaussian fit.
PRINT: Specifies whether the output window will be poped up.
OPTIONAL OUTPUTS:
A: The coefficients of the fit. A is a three to six
element vector as described under PURPOSE.
RESTRICTIONS:
The peak or minimum of the Gaussian must be the largest
or smallest point in the Y vector.
PROCEDURE:
Before accessing this routine, the 'ez_fit.pro' must be loaded into
IDL and the path to 'ez_fit.pro' must be in the IDL search path.
EXAMPLE:
X = [ ...]
Y = [ ...]
GAUSSFITGRAF,X,Y,NTERMS=4,/PRINT
MODIFICATION HISTORY:
Written by: Ben-chin K. Cha, 10-03-97.
xx-xx-xxbkc comment
(See ez_fit.pro)
NAME:
LADFITGRAF
PURPOSE:
This routine uses the IDL LADFIT function to fit the paired data
{x(i), y(i)} with the linear model Y = A + Bx.
Then calls PLOT1D to graph the calculated results with the raw
data in a pop-up window.
CATEGORY:
Curve fitting with plot.
CALLING SEQUENCE:
LADFITGRAF, X, Y [,YFIT] [,ABSDEV=absdev] [,/DOUBLE] [,/PRINT] [,/TEST]
INPUTS:
X: Position X vector
Y: Data value Y vector
KEYWORD PARAMETERS:
ABSDEV: Specifies whether the mean absolute deviation to be returned.
PRINT: Specifies whether the output window will be poped up.
TEST: Specifies whether the default test data will be used.
DOUBLE: If set to a non-zero value, computations are done in double
precision arithmetic.
OPTIONAL OUTPUTS:
YFIT: Y vector calculated from the fitted equation.
PROCEDURE:
Before accessing this routine, the 'ez_fit.pro' must be loaded into
IDL and the path to 'ez_fit.pro' must be in the IDL search path.
EXAMPLE:
X = [ ...]
Y = [ ...]
LADFITGRAF,X,Y,/PRINT
MODIFICATION HISTORY:
Written by: Ben-chin K. Cha, 08-13-97.
xx-xx-xxbkc comment
(See ez_fit.pro)
NAME:
LINFITGRAF
PURPOSE:
This routine uses the IDL LINFIT function to fit the paired data
{x(i), y(i)} with the linear model Y = A + Bx. It minimize the
chi-square error statistic.
Then calls PLOT1D to graph the calculated results with the raw
data in a pop-up window.
CATEGORY:
Curve fitting with plot.
CALLING SEQUENCE:
LINFITGRAF, X, Y [,YFIT] [,CHISQ=chisq] [,PROG=prob] [,SDEV=sdev]
[,SIGMA=sigma] [,/DOUBLE] [,/PRINT] [,/TEST]
INPUTS:
X: Position X vector
Y: Data value Y vector
KEYWORD PARAMETERS:
CHISQ: Use this keyword to specify a named variable which returns the
chi-square error statistic as the sum of squared errors between
Y(i) and A + BX(i). If individual standard deviations are
supplied, then the chi-square error statistic is computed as
the sum of squared errors divided by the standard deviations.
PROB: Use this keyword to specify a named variable which returns the
probability that the computed fit would have a value of CHISQR
or greater. If PROB is greater than 0.1, the model parameters
are "believable". If PROB is less than 0.1, the accuracy of the
model parameters is questionable.
SDEV: An n-element vector of type integer, float or double that
specifies the individual standard deviations for {X(i), Y(i)}.
SIGMA: Use this keyword to specify a named variable which returns a
two-element vector of probable uncertainties for the model par-
ameters, [SIG_A,SIG_B].
PRINT: Specifies whether the output window will be poped up.
TEST: Specifies whether the default test data will be used.
DOUBLE: If set to a non-zero value, computations are done in double
precision arithmetic.
OPTIONAL OUTPUTS:
YFIT: Y vector calculated from the fitted equation.
PROCEDURE:
Before accessing this routine, the 'ez_fit.pro' must be loaded into
IDL and the path to 'ez_fit.pro' must be in the IDL search path.
EXAMPLE:
X = [ ...]
Y = [ ...]
LINFITGRAF,X,Y,sigma=sigma,chisq=chisq,prob=prob,/PRINT
MODIFICATION HISTORY:
Written by: Ben-chin K. Cha, 08-13-97.
xx-xx-xxbkc comment
(See ez_fit.pro)
NAME:
LORENTZFITGRAF
PURPOSE:
This routine uses the CURVEFIT function with the non-linear fitting
function_name='lorentzian' specified. y=f(x) where:
F(X) = A0 * A2^2 / ((X-A1)^2 + A2^2) and
A0 = height of exp, A1 = center of exp, A2 = FWHM/2
Then calls PLOT1D to graph the calculated results with the raw
data in a pop-up window.
CATEGORY:
Curve fitting with plot.
CALLING SEQUENCE:
LORENTZFITGRAF, X, Y [,A] [,/PRINT] [,YFIT=yfit]
INPUTS:
X: Position X vector of type float or double.
Y: Data value Y vector of type float or double.
A: Optional input [A0,A1,A2], initial estimates of
fitting coefficients.
KEYWORD PARAMETERS:
PRINT: Specifies whether the output window will be poped up.
YFIT: Y vector calculated from the fitted equation.
SIDE EFFECTS:
The computed parameters and the convergence may depend on the data and
the initial parameters of A vector entered.
RESTRICTIONS:
The number of parameters must be three. The initial value should be
close to the real data value with:
A0 = height of exp, A1 = center of exp, A2 = FWHM/2
Especially the center of expectation must corresponds to the peak
of the lorentzian.
PROCEDURE:
Before accessing this routine, the 'ez_fit.pro' must be loaded into
IDL and the path to 'ez_fit.pro' must be in the IDL search path.
EXAMPLE:
Run the geometric fitting, and pops up the fitting result window
X = [ ...]
Y = [ ...]
A = [ Peak, Mean, FWHM/2 ]
LORENTZFITGRAF,X,Y,A,/GEOMETRIC,/PRINT
MODIFICATION HISTORY:
Written by: Ben-chin K. Cha, 10-15-97.
xx-xx-xxbkc comment
(See ez_fit.pro)
NAME:
LORENTZIAN_CURVE
PURPOSE:
For a given set of lorentzian parameters [a0,a1,a2], this routine
calculate the corresponding {y(i)} for a given set of {x(i)}.
CATEGORY:
Fitted data with plot.
CALLING SEQUENCE:
LORENTZIAN_CURVE, A, X, Y [,/PLOT]
INPUTS:
A: Fitted lorentzian coefficients, [A0,A1,A2].
X: Position X vector of type float or double.
Y: Data value Y vector of type float or double.
KEYWORD PARAMETERS:
PLOT: Specifies whether to plot the Y vector.
PROCEDURE:
Before accessing this routine, the 'ez_fit.pro' must be loaded into
IDL and the path to 'ez_fit.pro' must be in the IDL search path.
EXAMPLE:
Run the geometric fitting, and pops up the fitting result window
X = [ ...]
A = [Peak, Mean, FWHM/2]
LORENTZIAN_CURVE,A,X,Y,/PLOT
MODIFICATION HISTORY:
Written by: Ben-chin K. Cha, 10-15-97.
xx-xx-xxbkc comment
(See ez_fit.pro)
NAME:
MULTI_LORENTZFITGRAF
PURPOSE:
This routine uses the CURVEFIT function to fit a set of multiple
LORENTZIAN functions y=f(x) where:
F(X) = A0 * A2^2 / ((X-A1)^2 + A2^2) + ... and
A0 = height of exp, A1 = center of exp, A2 = FWHM/2
Then calls PLOT1D to graph the calculated results with the raw
data in a pop-up window.
CATEGORY:
Curve fitting with plot.
CALLING SEQUENCE:
MULTI_LORENTZFITGRAF, X, Y, A [,YFIT=yfit] [,/PRINT] [,/SUBPLOT]
INPUTS:
X: Position X vector of type float or double.
Y: Data value Y vector of type float or double.
A: Lorentzian coefficients vector. It consists of a set of
multiple of 3 parameters for each lorentzian.
[ [A0,A1,A2], [A0,A1,A2], ... ]
KEYWORD PARAMETERS:
YFIT: Y vector calculated from the fitted lorentzian equations.
PRINT: Specifies whether the output window will be poped up.
SUBPLOT: If specified, a plot window shows the composition of all
the multiple lorentzian curves.
SIDE EFFECTS:
The computed parameters and the convergence may depend on the data and
the initial parameters of A vector entered.
RESTRICTIONS:
The number of parameters must be multiple of 3. The initial value
should be close to the real data value with:
A0 = height of exp, A1 = center of exp, A2 = FWHM/2
Especially the center of expectation must corresponds to each local
peak of the lorentzian.
PROCEDURE:
Before accessing this routine, the 'ez_fit.pro' must be loaded into
IDL and the path to 'ez_fit.pro' must be in the IDL search path.
EXAMPLE:
Run the geometric fitting, and pops up the fitting result window
X = [ ...]
Y = [ ...]
A = [ Peak1, Mean1, FWHM1/2, Peak2, Mean2, FWHM2/2, ... ]
MULTI_LORENTZFITGRAF,X,Y,A,/GEOMETRIC,/PRINT
MODIFICATION HISTORY:
Written by: Ben-chin K. Cha, 10-15-97.
xx-xx-xxbkc comment
(See ez_fit.pro)
NAME:
POLYFITGRAF
PURPOSE:
This routine uses the IDL least square polynomial fit function
PLOYFIT with optional error estimates. Double precision computation
is assumed.
Then calls PLOT1D to graph the calculated results with the raw
data in a pop-up window.
CATEGORY:
Curve fitting with plot.
CALLING SEQUENCE:
POLYFITGRAF,X,Y,NDEGREE [,A ] [,YFIT] [,YBAND] [,SIGMA] [,CORRM] [,/PRINT]
INPUTS:
X: Position X vector
Y: Data value Y vector
NDEGREE: The degree of polynomial to fit.
KEYWORD PARAMETERS:
PRINT: Specifies whether the output window will be poped up.
OPTIONAL OUTPUTS:
A: Correlation matrix of the coefficients.
YFIT: The vector of calculated Y's. Has an error of + or - Yband.
YBAND: Error estimate for each point = 1 sigma.
SIGMA: The standard deviation in Y units.
CORRM: The correlation matrix of the coefficients.
PROCEDURE:
Before accessing this routine, the 'ez_fit.pro' must be loaded into
IDL and the path to 'ez_fit.pro' must be in the IDL search path.
EXAMPLE:
X = [ ...]
Y = [ ...]
POLYFITGRAF,X,Y,4,A,/PRINT
MODIFICATION HISTORY:
Written by: Ben-chin K. Cha, 10-03-97.
xx-xx-xxbkc comment
(See ez_fit.pro)
NAME:
POLYFITWGRAF
PURPOSE:
This routine uses the IDL least square polynomial fit function
PLOYFITW with optional error estimates.
Then calls PLOT1D to graph the calculated results with the raw
data in a pop-up window.
CATEGORY:
Curve fitting with plot.
CALLING SEQUENCE:
POLYFITWGRAF,X,Y,W,NDEGREE [,A ] [,YFIT] [,YBAND] [,SIGMA] [,/PRINT]
INPUTS:
X: Position X vector
Y: Data value Y vector
W: The vector of weights. This vector should be same length as
X and Y.
NDEGREE: The degree of polynomial to fit.
KEYWORD PARAMETERS:
PRINT: Specifies whether the output window will be poped up.
OPTIONAL OUTPUTS:
A: Correlation matrix of the coefficients.
YFIT: The vector of calculated Y's. Has an error of + or - Yband.
YBAND: Error estimate for each point = 1 sigma.
SIGMA: The standard deviation in Y units.
PROCEDURE:
Before accessing this routine, the 'ez_fit.pro' must be loaded into
IDL and the path to 'ez_fit.pro' must be in the IDL search path.
EXAMPLE:
X = [ ...]
Y = [ ...]
POLYFITWGRAF,X,Y,W,4,/PRINT
MODIFICATION HISTORY:
Written by: Ben-chin K. Cha, 10-03-97.
xx-xx-xxbkc comment
(See ez_fit.pro)
NAME:
READASCII
PURPOSE:
Read data from an ASCII file into an array. It is assumed that each line
with same number of entries. It can extract a sub-rectangle of region
from the ascii file.
CATEGORY:
Input/Output
CALLING SEQUENCE:
READASCII, Filename, Rarray, X, Y [ /DOUBLE, SKIP=skip, LINES=lines,
L_COLUMN=l_column, COLUMNS=columns ]
INPUT:
Filename - Input file name
KEYWORD PARAMETERS:
DOUBLE - specifies output variable in double position
SKIP - skip number of lines at beginning of file
LINES - total number of lines to be read
L_COLUMN - skip number of columns from the input line
COLUMNS - total number of columns to be read from the line
OUTPUTS:
Rarray - Return default column matrix
X - Return the 1st column of Rarray as independent variable
Y - Return transpose of the remaining columns of Rarray as
dependent variables
RESTRICTIONS:
The input file must be in ASCII form. The header lines must be placed
at the beginning of the file. They can be skipped by setting the SKIP
equal to the number of header lines at beginning. Each data line must
contains the exactly same number of columns.
EXAMPLE:
READASCII, 'Filename', RARRAY, X, Y
MODIFICATION HISTORY:
Written by: Ben-chin K. Cha
09-16-98 bkc Allows blank lines at end of ascii file, no blank
lines allowed between data
(See ez_fit.pro)
NAME:
XDISPLAYFILE
PURPOSE:
Display an ASCII text file using widgets and the widget manager.
CATEGORY:
Widgets.
CALLING SEQUENCE:
XDISPLAYFILE, Filename
INPUTS:
Filename: A scalar string that contains the filename of the file
to display. The filename can include a path to that file.
KEYWORD PARAMETERS:
FONT: The name of the font to use. If omitted use the default
font.
GROUP: The widget ID of the group leader of the widget. If this
keyword is specified, the death of the group leader results in
the death of XDISPLAYFILE.
HEIGHT: The number of text lines that the widget should display at one
time. If this keyword is not specified, 24 lines is the
default.
TEXT: A string or string array to be displayed in the widget
instead of the contents of a file. This keyword supercedes
the FILENAME input parameter.
TITLE: A string to use as the widget title rather than the file name
or "XDisplayFile".
WIDTH: The number of characters wide the widget should be. If this
keyword is not specified, 80 characters is the default.
OUTPUTS:
No explicit outputs. A file viewing widget is created.
SIDE EFFECTS:
Triggers the XMANAGER if it is not already in use.
RESTRICTIONS:
None.
PROCEDURE:
Open a file and create a widget to display its contents.
MODIFICATION HISTORY:
Written By Steve Richards, December 1990
Graceful error recovery, DMS, Feb, 1992.
12 Jan. 1994 - KDB
If file was empty, program would crash. Fixed.
4 Oct. 1994 MLR Fixed bug if /TEXT was present and /TITLE was not.
14 Jul. 1995 BKC Increased the max line to variable size.
16 Jun. 1997 BKC Max dispalyable line is 10000 for non-unix OS system.
28 Aug. 1997 BKC Add the printer button, file name label, it uses the
PS_print,file to print.
(See ez_fit.pro)