| sfit | noao.onedspec | sfit |
sfit -- Fit spectra
sfit input output
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.
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
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
The task was expanded to include long slit and spectral cube data.
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.
continuum, fit1d, icfit, ranges