Spectra: Data Reduction Techniques
2 Wavelength Calibration and Coordinate Transformations
Science spectra should always be acquired in conjunction with a pair of arc-lamp calibration spectra.
These arc spectra are needed to establish the dispersion relation (the mapping between wavelength
and pixel) for the science spectrum. To use these spectra to ﬁnd the dispersion solution and then
apply that solution to the science spectra, proceed as follows.
• For each science spectrum, identify which arc spectra are associated with it. Create a ‘master
arc spectrum’ for each science spectrum by combining any associated arc spectra into a single
spectrum (using imarith or imcombine), or by copying the single associated spectrum if
there is only one (using imcopy). Note that a single arc spectrum may provide calibration
for more than one science spectrum (e.g., if you alternated taking science and arc spectra,
then each science spectrum would be associated with the two ﬂanking arc spectra, and each
arc would be associated with two ﬂanking science spectra). It is useful to name the master
arc spectrum for each science spectrum by a readily recognized name (say, the name of the
science spectrum with a ‘c’ appended) 1 . Having produced a master arc spectrum for each
science spectrum, select one of the master arc spectra to begin the wavelength calibration.2
• Load the noao.twodspec.longslit package, and run the identify task on the selected master
arc spectrum (hereafter referred to as the ‘reference arc spectrum’). First, use epar to set
some parameters. The SECTION should be set to “[*,10]” (i.e., the ﬁrst useful line of the
image), and the COORDLIST should be a feature list ﬁle for the type of source you’re using
(e.g., neon, argon). Choose the ﬁtting function and a default ﬁt order to start with. Avoid
spline ﬁts since they can easily ﬁt incorrect features; try using “legendre” or “chebyshev”. A
good default ﬁt order is probably 4; if you ﬁnd later that a higher order would be better, then
you can change it while running the task.
The objective for this task is to identify the emission features in the spectrum with wavelengths
listed in the the coordinate list. This is done by ﬁrst establishing a rough calibration using
a few known and readily recognized features. The identify task will bring up an interactive
graphic tool, showing the spectrum for the ﬁrst section of your image3 . Mark a few known
features using the ‘m’ key, entering the expected wavelength (to within an ˚ or so) at the
E.g., if you have a science spectrum of the object 3C273 in the ﬁle oct1203.ﬁts it is useful to name the master arc
spectrum oct1203c.ﬁts. It isn’t so useful to name it 3C273c.ﬁts, particularly if you have more than one observation
If your master arc spectrum has a lot of continuum contribution in addition to the emission features, you may
want to remove the continuum component by ﬁtting a 2D surface to the image using a task such as imsurﬁt in the
images.imﬁt package. Just make sure that the order of the ﬁt is low enough that you are not removing any of the
desired emission features.
A few hints on using graphic tools in IRAF:
– pressing ‘?’ at any time will call a help ﬁle which explains the various keystroke options.
– You can zoom in to a region of a plot by typing ‘w’, then using ‘e’ and ‘e’ to deﬁne the corners of the region.
Zoom out to full by typing ‘w’, then ‘a’.
prompt. If a matching wavelength is found in the featurelist, it will be reported on the next
line. It is useful to be somewhat imprecise when entering the wavelength, as the change
between what you enter and is then reported makes it obvious that a match has been found.
Repeat this procedure for a few features.
In some cases, such as when working with a grating/spectrograph/wavelength-region you have
never used before, you often do not know ANY feature wavelengths. There are several ways to
get around this problem. One is to go to one of the science spectra and attempt to establish
a low-order dispersion solution by hand by using recognizable sky features. The other is to
use some form of feature atlas, in which someone else has gone to the eﬀort of identifying the
features. The best atlas to use is one from the same telescope/spectrograph as your data,
as the detailed response of each system is somewhat diﬀerent; of course, such an atlas is
not always available. The Kitt Peak Observatory (the primary American national facility in
the continental U.S.A.) maintains an online interactive atlas which may also be useful. See
• Once you have identiﬁed a few features, enter the ﬁtting portion of the identify task using
the ‘f’ key. This activates a standard IRAF ﬁtting package, where the inputs are the pixel
centroids and wavelengths of the features you have identiﬁed. The most instructive plots to
look at are the non-linear component of the ﬁt and the residual (get these using the ‘l’ and
’j’ keys respectively). You can change the order of the ﬁt on the ﬂy in this task; for instance
if you want to change to a third order ﬁt simply type “:order 3”. Features which lie oﬀ the
mean relation can be deleted using the ‘d’ key, and the relation can be re-ﬁt using the ‘f’ key.
When you are satisﬁed with the initial ﬁt, return to feature identiﬁcation mode using the ‘q’
key. Then simply press the ‘l’ key, and identify will try to pick out and match all peaks in
the spectrum. Having done this, return to the ﬁtting routine, and produce a ﬁnal ﬁt to all
the points, deleting outliers as appropriate. It is often useful to go back and forth between
the feature identiﬁcation and ﬁtting several times, to ensure that you converge on the correct
wavelength solution4 . Note that you should also delete features which are very weak, or too
crowded by other features; in either case it may not be possible for the identify task to
calculate an accurate centre for the feature, and your wavelength solution can be less accurate
as a result.
• When you are satisﬁed with the dispersion solution for that line of the image, move on to
the next line by typing ‘k’ (in feature identiﬁcation mode; this won’t work in ﬁtting mode).
Note that you will probably not be moved to the next line — e.g., you may move from line 10
to line 20 rather than to line 11. This depends on the value of NSUM, the parameter which
controls how many lines are averaged in each ﬁt. It is useful to use NSUM> 1, so that any
hot pixels etc. are averaged over, and to increase the feature strength in an image with poor
A few hints for the feature identiﬁcation mode of identify:
– ‘.’ selects the nearest marked feature (whose wavelength etc. will then be printed at the bottom of the plot).
With ‘+’ and ‘-’ you can select the next feature to the right or left. Use ‘z’ to zoom in on a selected feature,
and ‘p’ to pan back out again.
– You can use ‘s’ to shift the feature to a new location, which is especially useful when propagating your solution
from one line to the next — if a feature has moved slightly, you can shift the mark accordingly.
S/N. And there’s no need to ﬁt a new solution to every feature since the dispersion relation
is unlikely to change that fast.
• When you have found the dispersion solution for all lines in the image quit the identify task,
making sure to save the output in the database.
• The next step in establishing the dispersion solution is to propagate the initial solution on
this arc spectrum to all the master arc spectra. This is done using the reidentify task. For
this task, SECTION should be set to that used in the identify task, and NEWAPS should be
set to “yes”. All other parameters are self-explanatory or can be left unchanged.
• With a mapping between x, y and x′ , λ now established at a large number of x, y pairs on
each master arc spectrum, the next step is to produce a polynomial representation of this
mapping. This is done using the ﬁtcoordinates task. The ﬁrst few times you use this task
on a particular dataset, it is best to do so interactively, so as to establish the appropriate
orders to use for the ﬁt. Try to ﬁnd the lowest order ﬁt (there are several types to choose
from) which leaves only random residuals. Having found this, run the task on all the master
arc spectra non-interactively.
• Finally, use the transform task to apply the ﬁtted polynomial to the associated science
spectrum. You should now have a set of 2D wavelength-calibrated, distortion-corrected science