STScI Logo

curfit utilities


NAME · USAGE · PARAMETERS · DESCRIPTION · EXAMPLES · SEE_ALSO

NAME

curfit -- fit a curve to a list or an image section

USAGE

curfit input

PARAMETERS

input
The data to be fit. May be an image section, STDIN or a list of file names.
function = legendre
The type of function with which to fit the data. Choices are legendre, chebyshev, spline1 (linear spline) or spline3 (cubic spline).
order = 4
The order of the fit or number of spline pieces.
weighting = uniform
The type of weighting for the fit. The options are:
uniform
The weight w = 1.0. This option may be used for both list input and image input.
user
The weights are supplied by the user. This option may be used for list input only.
statistical
The weight w = 1.0 / y. This option can be used for both list and image data.
instrumental
The user supplies the sigmay for each point and w = 1.0 / sigmay ** 2. This option may be used for list input only.
interactive = yes
If interactive is set to yes, a plot of the fit is drawn and the cursor is available for interactively examining and adjusting the fit.
axis = 1
If input names an image or image section, this parameter specifies the axis along which the image is projected for fitting.
listdata = no
If listdata is set to yes, the only printed output will be the calculated values for the X,Y pairs. This is useful as input to graph or some other list oriented program.
verbose = no
If verbose is set to yes, the fitted (X,Y) pairs are listed in addition to the default output of filename, function type, order, rejection parameters, coefficients and their errors.
power = no
If power is set to yes, the coefficients of the legendre or chebyshev polynomials will be converted to power series coefficients.
calctype = "double"
Calculation datatype. The two datatypes are "real" (single precision) and "double" (double precision).
device = "stdgraph"
The output device for interactive graphics.
cursor = "stdgcur"
The source of graphics cursor input.

DESCRIPTION

A curve is fit to data read from either an image section or a list. The type of curve is set by the function parameter as either a legendre polynomial, chebyshev polynomial, linear spline or cubic spline, with the order of the fit (or number of spline pieces) set by order . If data is read from an image, the axis parameter is used to reduce the dimensionality of the image; it specifies the axis along which the image is projected. For example, when axis = 1, the image is compressed to a column. Axis = 2 would project the image along a line; axis = 3 indicates projection in the z direction, etc.

The input data must be ordered in x because of a restriction in the interactive plotting package. If the input is from a list, the data are sorted prior to fitting; image input data are assumed to be ordered in x and are not explicitly sorted by curfit .

If the input is from a list the user may specify a set of weights, weighting = user or a set of errors, weighting = instrumental. An additional weighting option weighting = statistical can be used for both list and image data. The default is weighting = uniform.

When interactive = yes, the curve is plotted and cursor commands allow for interactive examining and adjustment of the fit. The full range of interactive cursor commands is available including those for changing the function type, order, and rejection criteria, and examining the residuals.

The final fit parameters are written to STDOUT with the format controlled by parameters verbose and listdata . By default, the function type, order, and resulting chi-square are printed as well as the coefficients and their standard deviations. If verbose is set to yes, a list of X, Y_calculated, Y_input, and W_input is also printed. If listdata is set to yes, the only printed output will be a listing of X, Yc, Y and W. This provides a list suitable as input to graph or any other list oriented utility. Setting listdata to yes overrides the verbose option.

When power = yes, the coefficients are converted to power series coefficients of the form a0 + a1*X + a2*X**2 +a3*X**3 .... Only legendre and chebyshev coefficients are converted; a conversion of spline coefficients is meaningless. Also, errors in the coefficients are not converted.

The user has a choice of single or double precision calculations. Generally double precisions is used since the calculation time is only slightly longer. The single precision calculation is used in many other tasks which do many fits. This task provides a test tool to compare the results between the two levels of precision.

EXAMPLES

1. The x,y pairs in file test.data are interactively fit with a fourth order legendre polynomial. The printed output is shown.

cl> curfit test.data

	NOAO/IRAF V2.0 Hammond@lyra Fri 11:45:41 13-Dec-85
	file = test.data
	function = legendre
	grow = 0.
	naverage = 1
	order = 4
	low_reject = 0., high_reject = 0.
	niterate = 1
	sample = *
	total points = 8
	sample points = 8
	nrejected = 0
	deleted = 0
	square root of reduced chi square = 3.008706E-6
		coefficent	  error
 	1	   2.633E1	  1.098E-6
 	2	   3.150E1	  1.820E-6
 	3	   8.167E0	  1.896E-6
 	4	 -1.621E-6	  2.117E-6

2. Fit a cubic spline to the last 12 columns of image "m74".

cl> curfit m74[501:512,1:512] axis=2 func=spline3 order=5

3. Use curfit as a filter to overplot a smoothed curve to an existing plot of the data points. The command line for graph is shown as well as the curfit command. Note the interactive flag for curfit is turned off.

cl> graph points.list point+ mark=box wx1=.13 xlab="X VALUES"\ >>> ylab="Y VALUES" title="Legendre fit to points.list"

cl> type points.list | curfit list+ inter- | graph append+

SEE ALSO

icfit, polyfit


Source Code · Search Form · STSDAS