STScI Logo

sfit noao.onedspec


NAME · USAGE_ · PARAMETERS · DESCRIPTION · PROMPTS · EXAMPLES
REVISIONS · BUGS · SEE_ALSO

NAME

sfit -- Fit spectra

USAGE

sfit input output

PARAMETERS

input
Input spectra to be fit. These may be any combination of echelle, multispec, onedspec, long slit, and spectral cube format images.
output
Output fitted spectra. The number of output spectra must match the number of input spectra. Output may be omitted if listonly is yes.
lines = "*", bands = "1"
A range specifications for the image lines and bands to be fit. Unspecified lines and bands will be copied from the original. If the value is "*", all of the currently unprocessed lines or bands will be fit. A range consists of a first line number and a last line number separated by a hyphen. A single line number may also be a range and multiple ranges may be separated by commas.
type = "fit"
Type of output spectra. The choices are "fit" for the fitted function, "ratio" for the ratio of the input spectra to the fit, "difference" for the difference between the input spectra and the fit, and "data" for the data minus any rejected points replaced by the fit.
replace = no
Replace rejected points by the fit in the difference, ratio, and data output types?
wavescale = yes
Wavelength scale the X axis of the plot? This option requires that the spectra be wavelength calibrated. If wavescale is no, the plots will be in "channel" (pixel) space.
logscale = no
Take the log (base 10) of both axes? This can be used when listonly is yes to measure the exponent of the slope of the continuum.
override = no
Override previously fit spectra? If override is yes and interactive is yes, the user will be prompted before each order is refit. If override is no, previously fit spectra are silently skipped.
listonly = no
Don't modify any images? If listonly is yes, the output image list may be skipped.
logfiles = "logfile"
List of log files to which to write the power series coefficients. If logfiles = NULL (""), the coefficients will not be calculated.
interactive = yes
Perform the fit interactively using the icfit commands? This will allow the parameters for each spectrum to be adjusted independently. A separate set of the fit parameters (below) will be used for each spectrum and any interactive changes to the parameters for a specific spectrum will be remembered when that spectrum is fit in the next image.
sample = "*"
The ranges of X values to be used in the fits. The units will vary depending on the setting of the wavescale and logscale parameters. The default units are in wavelength if the spectra have been dispersion corrected. The sample range syntax consists of pairs of values separated by colons and multiple ranges can be given separated by commas.
naverage = 1
Number of sample points to combined to create a fitting point. A positive value specifies an average and a negative value specifies a median.
function = spline3
Function to be fit to the spectra. The functions are "legendre" (legendre polynomial), "chebyshev" (chebyshev polynomial), "spline1" (linear spline), and "spline3" (cubic spline). The functions may be abbreviated. The power series coefficients can only be calculated if function is "legendre" or "chebyshev".
order = 1
The order of the polynomials or the number of spline pieces.
low_reject = 3., high_reject = 3.
Rejection limits below and above the fit in units of the residual sigma.
niterate = 0
Number of rejection iterations.
grow = 1.
When a pixel is rejected, pixels within this distance of the rejected pixel are also rejected.
markrej = yes
Mark rejected points? If there are many rejected points it might be desired to not mark rejected points.
graphics = "stdgraph"
Graphics output device for interactive graphics.
cursor = ""
Graphics cursor input.

DESCRIPTION

A one dimensional function is fit to spectra in a list of echelle, multispec, or onedspec format images. The first two formats will fit the spectra or orders (i.e. the lines) in each image. In this description the term "spectrum" will refer to a line of an image while "image" will refer to all spectra in an image. The parameters of the fit may vary from spectrum to spectrum within images and between images. The fitted function may be a legendre polynomial, chebyshev polynomial, linear spline, or cubic spline of a given order or number of spline pieces. The output spectra are formed from the fit, the ratio between the pixel values and the fit, the difference of the spectra to the fit, and the original data with rejected points possibly replaced. The output image is of pixel type real.

The line/band numbers (for two/three dimensional images) are written to a list of previously processed lines in the header keywords SFIT and SFITB of the output image. A subsequent invocation of SFIT will only process those requested spectra that are not in this list. This ensures that even if the output image is the same as the input image that no spectra will be processed twice and permits an easy exit from the task in the midst of processing many spectra without losing any work or requiring detailed notes.

The points to be fit in each spectrum are determined by selecting a sample of X values specified by the parameter sample and taking either the average or median of the number of points specified by the parameter naverage . The type of averaging is selected by the sign of the parameter with positive values indicating averaging, and the number of points is selected by the absolute value of the parameter. The sample units will vary depending on the settings of the wavescale and the logscale parameters. Note that a sample that is specified in wavelength units may be entirely outside the domain of the data (in pixels) if some of the spectra are not dispersion corrected. The syntax of the sample specification is a comma separated, colon delimited list similar to the image section notation. For example, the sample , "6550:6555,6570:6575" might be used to fit the continuum near H-alpha.

If low_reject and/or high_reject are greater than zero the sigma of the residuals between the fitted points and the fitted function is computed and those points whose residuals are less than -low_reject * sigma and greater than high_reject * sigma are excluded from the fit. Points within a distance of grow pixels of a rejected pixel are also excluded from the fit. The function is then refit without the rejected points. This rejection procedure may be iterated a number of times given by the parameter niterate .

If replace is set then any rejected points from the fitting are replaced by the fit in the data before outputing the difference, ratio, or data. For example with replacing the difference will be zero at the rejected points and the data output will be cleaned of deviant points.

A range specification is used to select the lines and bands to be fit. These parameters may either be specified with the same syntax as the sample parameter, or with the "hyphen" syntax used elsewhere in IRAF. Note that a NULL range for lines/bands expands to no lines, not to all lines. An asterisk (*) should be used to represent a range of all of the image lines/bands. The fitting parameters (sample, naverage, function, order, low_reject, high_reject, niterate, grow ) may be adjusted interactively if the parameter interactive is yes. The fitting is performed with the icfit package. The cursor mode commands for this package are described in a separate help entry under "icfit". Separate copies of the fitting parameters are maintained for each line so that interactive changes to the parameter defaults will be remembered from image to image.

PROMPTS

If several images or lines are specified, the user is asked whether to perform an interactive fit for each spectrum. The response may be yes, no, skip, YES, NO or SKIP . The meaning of each response is:

	yes   - Fit the next spectrum interactively.
	no    - Fit the next spectrum non-interactively.
	skip  - Skip the next spectrum in this image.

	YES   - Interactively fit all of the spectra of
		all of the images with no further prompts.
	NO   	Non-interactively fit all chosen spectra of all images.
	SKIP  - This will produce a second prompt, "Skip what?",
		with the choices:

		spectrum - skip this spectrum in all images
		image    - skip the rest of the current image
		all      - \fBexit\fR the program
		           This will \fBunlearn\fR the fit parameters
			   for all spectra!
		cancel  - return to the main prompt

EXAMPLES

1. To normalize all orders of the echelle spectrum for hd221170

cl> sfit hd221170.ec nhd221170.ec type=ratio

Each order of the spectrum is graphed and the interactive options for setting and fitting the continuum are available. The important parameters are low_rejection (for an absorption spectrum), the function type, and the order of the function; these fit parameters are originally set to the defaults in the SFIT parameter file. A ? will display a menu of cursor key options. Exiting with q will update the output normalized order for the current image and proceed to the next order or image.

The parameters of the fit for each order are initialized to the current values the first time that the order is fit. In subsequent images, the parameters for a order are set to the values from the previous image. The first time an order is fit, the sample region is reset to the entire order. Deleted points are ALWAYS forgotten from order to order and image to image.

2. To do several images at the same time

cl> sfit spec*.imh c//spec*.imh

Note how the image template concatenation operator is used to construct the output list of spectra. Alternatively:

cl> sfit @inlist @outlist

where the two list files could have been created with the sections command or by editing.

3. To measure the power law slope of the continuum (fluxed data)

cl> sfit uv.* type=ratio logscale+ listonly+ fun=leg order=2

REVISIONS

SFIT V2.10.4
The task was expanded to include fitting specified bands in 3D multispec spectra.

The task was expanded to include long slit and spectral cube data.

SFIT V2.10
This task is new.

BUGS

The errors are not listed for the power series coefficients.

Spectra that are updated when logscale is yes are written with a linear wavelength scale, but with a log normalized data value.

Selection by aperture number is not supported.

SEE ALSO

continuum, fit1d, icfit, ranges


Source Code · Search Form · STSDAS