This section describes some IRAF
tasks that can be used for analyzing and manipulating spectral data. Some of these tasks operate directly on HST
data files created by the pipeline. However, a number of the most useful IRAF
tasks, such as splot
, require specially prepared data (except for STIS two-dimensional spectra). Before discussing these tasks we will first describe how to recast your data into forms that are more generally accessible.
Alternatively, many other useful tools are now available for the analysis of HST
spectra which operate outside of IRAF
; among them is specview
, a Java tool for viewing and analyzing spectra from a variety of instruments. It is briefly described in the previous section, Section 3.5
Calibrated spectra emerge from the pipeline either as two-dimensional spectral
STIS files) or as one-dimensional spectra stored in tabular form (x1d
files for COS and STIS). You can analyze calibrated two-dimensional spectra in IRAF
as you would analyze any other spectral image, because their headers already contain the necessary wavelength information.
Tabulated COS and STIS spectra can be analyzed directly using STSDAS
tasks that understand the selectors
syntax described in Section 2.2.2
. However, in order to use IRAF
tasks that rely on the multispec format WCS, such as splot
, or other STSDAS
tasks that do not understand three-dimensional tables, you will have to prepare your data appropriately. This section describes some useful tasks for putting your data in the proper form:
: This task is the analog to mkmultispec
and is useful for working with three-dimensional tables. It extracts COS and STIS spectra from tables and writes them as IRAF
spectral images with wavelength information in the header.
: This task extracts specified data arrays from three-dimensional table cells and places them in conventional two-dimensional tables for easier access.
: This task extracts specified data arrays from a 3-D table cells and places them into 1-D images. This task can write single group GEIS files.
task in the stsdas.hst_calib.ctools
package extracts one row (or several) from a COS or STIS table, fits a polynomial dispersion solution to each wavelength array, and stores the spectra in an output file in original IRAF
format (OIF), using the multispec WCS. This task is layered upon the mkmultispec
task, which performs a similar operation for FOS and GHRS calibrated spectra (see “mkmultispec” in Section 3.6.2
). Most of the parameters for tomultispec
echo those for mkmultispec
. As a helpful navigational aid, the STIS spectral order numbers are written to the corresponding beam
numbers in the multispec image; the aperture numbers are indexed sequentially starting from one. You can choose to fit the dispersion solution interactively, but the default fourth-order Chebyshev polynomial will likely suffice for all STIS spectral orders, except for prism-dispersed spectra. However, you cannot use the interactive option if you are selecting more than one order from the input file.
The output file format of tomultispec
will be OIF regardless of the specified extension. This format is similar to GEIS format, (see Section 4.3.6
). OIF format files have a header component (suffix .imh
) and a binary data component (suffix .pix
If you want to select particular rows, rather than writing all the rows to the
multispec file, you will need to use the selectors
syntax. To select only the spectrum stored in row nine of the input table, the previous example would change to:
Note that the double quote marks around the file name and row selector are necessary
to avoid syntax errors. To select a range of rows, say rows nine through eleven, type:
|Column selectors cannot be used with tomultispec.Tomultispec
extracts the calibrated FLUX by default. However, other intensity data (e.g., NET counts) can be extracted by specifying the flux_col
|Choose the type of fitting function for the tomultispec
dispersion solution with care. Using the table option, which writes the entire wavelength array to the image header for each order, will fail if more than three rows are selected. This restriction results from a limit to the number of keywords that can be used to store the dispersion relation.
|If the imdir
parameter in your login.cl
file is set to a directory that does not exist, then tomultispec
will fail when trying to run sarith
. To avoid this error, set imdir
equal to a directory that does exist or HDR$
, which will place files in the same directory as the header file.
COS and STIS spectra are stored as data arrays within individual cells of FITS
binary tables (see Section 2.2.2
). These tables are effectively three-dimensional, with each column holding a particular type of quantity (e.g., wavelengths, fluxes), each row holding a different spectral order, and each cell holding a one-dimensional array of values spanning the wavelength space of each spectral order. The txtable
task in the tables.ttools
package extracts these data arrays from the cells specified with the selectors
syntax and stores them in the columns of conventional two-dimensional binary tables.
For example, suppose the first extension of the FITS file data.fits
contains a STIS echelle spectrum and you want to extract only the wavelength and flux arrays corresponding to spectral order 68. You could then type:
This command would write the wavelength and flux arrays to the columns of the
output table out_table
. To specify multiple rows of a tabulated echelle spectrum, you would type:
This command would generate three separate output files named echl_r0010.tab
, and echl_r0012.tab
. See the online help for more details on txtable
and the selectors
syntax, and remember to include the double quotation marks. The similar tximage
task can be used to generate single-group GEIS files from STIS tabular data, which can then be used as input to tasks such as resample
Similarly, for a file cos_nuv.fits
which contains a COS NUV spectrum and you want to extract only the wavelength and flux arrays for all three stripes, type:
The FOS and GHRS data reduction pipelines store fluxes and wavelengths in
separate files. In GEIS format, the c1h
file contains the flux information and the c0h
file contains the wavelength information. Because IRAF
tasks generally require both the flux and wavelength information to reside in the same file, you will probably want to create a new file that combines these arrays.
: This simple task resamples your flux data onto a linear wavelength scale, creating a new flux file containing the starting wavelength of the new grid in the CRVAL1 keyword and the wavelength increment per pixel in the CD1_1 keyword. Encoding the wavelength information into these standard FITS header keywords makes this format quite portable, but the resampling process loses some of the original flux information. In addition, the error (c2h
) and data quality (cqh
) files cannot be similarly resampled, limiting the usefulness of this technique.
: This task writes wavelength information into the header of a flux file while preserving all the original information. It is therefore a better choice than resample
for most applications, and we describe it in more detail below.
: An alternative to writing wavelength information into the header is to use the imtab
task to create a table recording the wavelength, flux, and if desired, the error data corresponding to each pixel. Many STSDAS
tasks, such as those in the STSDAS fitting
package, can access data in tabular form, so we describe this approach in more detail as well.
The most convenient method of combining wavelength and flux information, and
one that has no effect on the flux data at all, is to use the mkmultispec
task. This task places wavelength information into the headers of your flux files according to the IRAF
multispec format WCS. The multispec coordinate system is intended to be used with spectra having nonlinear dispersions or with images containing multiple spectra, and the format is recognized by many tasks in IRAF
V2.10 or later. For a detailed discussion of the multispec WCS, type help specwcs
at the IRAF
task can put wavelength information into the flux header files in two different ways. The first involves reading the wavelength data from the .c0h
file, fitting the wavelength array with a polynomial function, and then storing the derived function coefficients in the flux header file (.c1h
) in multispec format. Legendre, Chebyshev, or cubic spline (spline3) fitting functions of fourth order or larger produce essentially identical results, all having rms residuals less than 10-4
┼, much smaller than the uncertainty of the original wavelength information. Because these fits are so accurate, it is usually unnecessary to run the task in interactive mode to examine them.
can fit only simple types of polynomial functions to wavelength data, this method will not work well with FOS prism data, due to the different functional form of the prism-mode dispersion solution. For FOS prism spectra, use the header table mode of mkmultispec
(see below) or create an STSDAS table using imtab
There is another method by which mkmultispec
can incorporate wavelength information into a flux file and that is simply to read the wavelength data from the.c0h
file and place the entire data array directly into the header of the flux (.c1h
) file. This method simply dumps the wavelength value associated with each pixel in the spectrum into the flux header and is selected by setting the parameter function=table
. To minimize header size, set the parameter format
to a suitable value. For example, using format=%8.7g
will retain the original seven digits of precision of the wavelength values, while not consuming too much space in the flux header file.
|Be aware that there is a physical limit to the number of header lines
that can be used to store the wavelength array (approximately 1000 lines). This limit cannot be overridden. Under ordinary circumstances this limitation is not an issue. However, if many spectral orders have been spliced together, it may not be possible to store the actual wavelength array in the header, and a fit must be done instead.
Another way to combine wavelengths with fluxes is to create an STSDAS
table from your spectrum. The imtab
task in the STSDAS ttools
package reads a GEIS format spectral image and writes the list of data values to a column of an STSDAS
table, creating a new output table if necessary. The following example shows how to create a flux, wavelength, and error table from group eight of a GEIS-format FOS dataset:
|cl> imtab y0cy0108t.c0h y0cy0108t.tab wavelength
cl> imtab y0cy0108t.c1h y0cy0108t.tab flux
cl> imtab y0cy0108t.c2h y0cy0108t.tab error
Constructing tables is necessary if you plan to use certain tasks—such as those in
the STSDAS fitting
package—that do not currently recognize the multispec format WCS header information. Tabulating your spectra is also the best option if you want to join two or more spectra taken with different gratings into a single spectrum covering the complete wavelength range. Because the data are stored as individual wavelength-flux pairs, you do not need to resample them (thereby degrading the individual spectra to a common linear dispersion scale) before joining them. Instead, you could create separate tables for spectra from different gratings, and then combine the two tables using, for example, the tmerge
Note that you will first have to edit out any regions of overlapping wavelength from
one or the other of the input tables so that the output table will be monotonically increasing (or decreasing) in wavelength. tedit
can be used to edit selected rows of a table.
Photometric correction of COS, FOS, GHRS, and STIS spectra is done by the
pipeline during spectral extraction, resulting in flux-calibrated spectra. For detailed information see the Data Handbooks specific to each of these instruments at:
has many tasks for analyzing both one- and two-dimensional spectral data. Many observers will already be familiar with noao.onedspec
packages, and those who are not should consult the online help. Table 3.6
lists some of the more commonly used IRAF
spectral analysis tasks, and below we briefly describe splot
, one of the most versatile and useful. Remember that many of these tasks expect to find WCS wavelength information in the header, so you should first run mkmultispec
on your data, if necessary.
task in the IRAF noao.onedspec
package is a good general purpose analysis tool that can be used to examine, smooth, fit, and perform simple arithmetic operations on spectra. Because it looks in the header for WCS wavelength information, your file must be suitably prepared. Like all IRAF
can work on only one group at a time from a multigroup GEIS file. You can specify which GEIS group you want to operate on by using the square bracket notation, for example:
If you do not specify a group in brackets, splot
will assume you want the first group. In order to use splot
to analyze your FOS or GHRS spectrum, you will first need to write the wavelength information from your .c0h
file to the header of your .c1h
files in WCS, using the mkmultispec
task (see “mkmultispec”
task has many
available options described in detail in the online help. Table 3.7
summarizes a few of the more useful cursor commands for quick reference. When you are using splot
, a log file saves results produced by the equivalent width or de-blending functions. To specify a file name for this log file, you can set the save_file
parameter by typing, for example:
If you have used tomultispec
to transform a STIS echelle spectrum into .imh/.pix
OIF files with WCS wavelength information (see “tomultispec”
), you can step through the spectral orders stored in image lines using the “)”, “(”, and “#” keys. To start with the first entry in your OIF file, type:
You can then switch to any order for analysis using the “)” key to increment the line
number, the “(” key to decrement, and the “#” key to switch to a specified image line. Note that the beam label, which indicates the spectral order, cannot be used for navigation. See the online help for details.
Table 3.7: Useful splot
The STSDAS fitting
package contains several tasks, as listed in Table 3.8
, for fitting and analyzing spectra and images. The ngaussfit
tasks, in particular, are very good for interactively fitting multiple Gaussians and nonlinear functions, respectively, to spectral data. These tasks do not currently recognize the multispec WCS method of storing wavelength information. They recognize the simple sets of dispersion keywords such as W0, WPC and CRPIX, CRVAL, and CDELT, but these forms only apply to linear coordinate systems and therefore would require resampling of your data onto a linear wavelength scale first. However, these tasks do accept input from STSDAS
tables, in which you can store the wavelength and flux data value pairs or wavelength, flux, error value triples (see Section 3.6.2
When using tasks such as ngaussfit
, you must provide initial guesses for the function coefficients as input to the fitting algorithms. You can either specify these initial guesses via parameter settings in the task’s parameter sets (psets) or enter them interactively. For example, suppose you want to fit several features using the ngaussfit
task. Using the default parameter settings, you can start the task by typing:
This command reads spectral data from the image n4449.hhh
and stores the results of the line fits in the STSDAS
. After you start the task, your spectrum should appear in a plot window and the task will be left in cursor input mode. You can use the standard IRAF
cursor mode commands to redraw the plot window, restricting your display to the region around a particular feature, or features, that you want to fit. You may then want to:
Note that when the ngaussfit
task is used in this way (i.e., starting with all default values), the initial guess for the FWHM of the features will be set to a value of one. Furthermore, this coefficient and the coefficients defining the baseline are held fixed by default during the computation of the fit, unless you explicitly tell the task through cursor colon
to allow these coefficients to vary. It is sometimes best to leave these coefficients fixed during an initial fit, and then to allow them to vary during a second iteration. This rule of thumb also applies to the setting of the errors
parameter which controls whether or not the task will estimate error values for the derived coefficients. Because the process of error estimation is very CPU-intensive, it is most efficient to leave the error estimation turned off until you have a good fit, and then turn the error estimation on for one last iteration.
and Figure 3.7
show the results of fitting the Hβ (
and [OIII] (4959 and 5007 ┼) emission features in the spectrum of NGC 4449. The resulting coefficients and error estimates (in parentheses) are shown in Figure 3.7
Figure 3.6: Fitting Hβ
and [OIII] Emission Features in NGC 4449.
|function = Gaussians
coeff1 = 8.838438E-14 (0.) - Baseline zeropoint (fix)
coeff2 = -1.435682E-17 (0.) - Baseline slope (fix)
coeff3 = 1.854658E-14 (2.513048E-16) - Feature 1: amplitude (var)
coeff4 = 4866.511 (0.03789007) - Feature 1: center (var)
coeff5 = 5.725897 (0.0905327) - Feature 1: FWHM (var)
coeff6 = 1.516265E-14 (2.740680E-16) - Feature 2: amplitude (var)
coeff7 = 4963.262 (0.06048062) - Feature 2: center (var)
coeff8 = 6.448922 (0.116878) - Feature 2: FWHM (var)
coeff9 = 4.350271E-14 (2.903318E-16) - Feature 3: amplitude (var)
coeff10 = 5011.731 (0.01856957) - Feature 3: center (var)
coeff11 = 6.415922 (0.03769293) - Feature 3: FWHM (var)
rms = 5.837914E-16
grow = 0.
naverage = 1
low_reject = 0.
high_reject = 0.
niterate = 1
sample = 4800.132:5061.308
task, in the STSDAS contrib
package, is another powerful interactive facility for fitting a wide variety of emission-line, absorption-line, and continuum models to a spectrum. This task was written at STScI by Gerard Kriss. Extensive online help is available to guide you through the task,2
although because it is a contributed task, little-to-no support is provided by the STSDAS
The input spectrum to specfit
can be either an IRAF
image file or an ASCII file with a simple three-column (wavelength, flux, and error) format. If the input file is an IRAF
image, the wavelength scale is set using values of W0
. Hence, for image input, the spectral data must be on a linear wavelength scale. In order to retain data on a non-linear wavelength scale, it is necessary to provide the input spectrum in an ASCII file, so that you can explicitly specify the wavelength values associated with each flux value. The online help explains a few pieces of additional information that must be included as header lines in an input text file.
By selecting a combination of functional forms for various components, you can fit
complex spectra with multiple continuum components, blended emission and absorption lines, absorption edges, and extinction. Available functional forms include linear, power-law, broken power-law, blackbody, and optically thin recombination continua, various forms of Gaussian emission and absorption lines, absorption-edge models, Lorentzian line profiles, damped absorption-line profiles, and mean galactic extinction.