The previous section showed how to create an arc line map (specifically, a list of arc line wavelengths and the pixel positions of their centriods on the master arc spectrum) and how to apply that to one or more extracted science spectra. This is fine for some uses, but situations often occur in which you have a large set of arc line spectra and only some are relevant to each science spectrum. This can be the case when you have spectra of many different objects from the same night, each observation having one or two associated arc spectra. In this case, you want to wavelength-calibrate many different arc spectra and then select the appropriate one(s) to apply to each science spectrum. The result of this and the previous reduction procedure will (at last!) be a set of one-dimensional wavelength-calibrated science spectra.
Whilst pamela handles the extraction of one-dimensional spectra from two-dimensional images, molly handles the wavelength calibration of the spectra (and many other functions). Below I will gradually work through an example set of molly commands (enclosed in a shell script which can be accessed here) to load a set of arc spectra, wavelength-calibrate them, and selectively apply the calibration to science spectra.
This script changes a lot depending on the precise observational procedure in each case. There is therefore no single script which will handle most observing run, so you will normally need to adapt the script yourself. This is easily done by starting molly and pasting in each command (or several commands) to see whether it needs modification. The script below was written by Tom Marsh for a WHT/ISIS run, but other examples can be found on other pages in these instructions.
First of all, start the script and create a set of lists of the sdf files of the extracted spectra. Then start molly in such a way that it takes input automatically from the script as if it were typed in (and does so until it encounters the string "EOF"):
#!/bin/csh \ls *arco.sdf > arco.lis \ls *opt.sdf > opt.lis \ls *skyo.sdf > skyo.lis \ls *arcn.sdf > arcn.lis \ls *nor.sdf > nor.lis \ls *skyn.sdf > skyn.lis molly << EOF
Now make it confirm all commands (i.e. write them to the terminal) and set the maximum spectrum length to 4000 pixels. Load all the optimally-extracted arc spectra given in the list arco.lis. The abort command makes it fail if anything goes wrong, so problems will not go unnoticed. Then load the file which connects pixel positions of arc lines with their rest wavelengths (here called arcmaster.lis), fit it with a fourth-order polynomial, and fix the values of the two higher-order coefficients (so further arc line fits only change the two lower-order coefficients).
confirm mxpix 4000 SURE lndf arco.lis 1 arc 1 abort load arcmaster.lis f c 4 10000 master confirm c 2 10000 [empty line needed here]
On the WHT/ISIS, it is a good idea to take long arc-lamp exposures during the day to which a high-order wavelength calibration polynomial can be fitted. Then at night you can take shorter exposures and leave the higher-order polynomial terms fixed whilst fitting for the lower-order ones. The shorter exposures mean that fewer lines are available but that less time is lost from observing the science spectra. In this case, the file arctweak.lis is used for the shorter-exposure arc spectra. This file is like arcmaster.lis but does not include the weaker lines, which are not good enough to use at shorter exposure times. Tweak the fit to match the arc spectrum.
load arctweak.lis tweak 0.2 1 28 3.5 0
Now combine the tweak and fit to apply a wavelength calibration to all the loaded arcs (up to a maximum of 1000 here). Then fix the headers (which calculates the HJD and the heliocentric velocity correction) for the WHT, and write the calibrated arc spectra to a file arco.mol.
co 1 1000 0.2 q hfix 1 1000 WHT write arco 1 1000 n
Now load the optimally-extracted science spectra and fix their headers. The acal line is very important. This applies arc calibrations to individual spectra by selecting those only within a certain position in time and on the sky to the each spectrum. Additional selection is applied based on the extraction position of the arc and science spectra from the images. You can tell it to choose, for each science spectrum, the nearest arc (by putting "N"), or interpolate between arcs (if two or more are available) by putting "I", or to extrapolate if needed (if two or more arcs are available) by putting "E". The final three numbers of the acal line are the maximum allowed differences in sky position (arcminutes), time (minutes) and image extraction position (pixels) between the science spectrum and the arc spectra. The wavelength-calibrated science spectra are then written to the file opt.mol.
lndf opt.lis 1001 hfix 1001 2000 WHT acal 1001 2000 1 1000 N 1 60 0.0001 write opt 1001 2000 n
Now load the sky spectra which were generated during extraction of the science spectra. Fix the headers as before and wavelength-calibrate. As sky spectra contain features from the Earth's atmosphere, the velocity of the Earth through space is irrelevant to them. Remove this keyword from the header with the edit command and then write the calibrated sky spectra to file skyo.mol. If the Vearth keywords were not removed from the headers, then this velocity shift would automatically be applied by molly if the spectra were velocity-binned, even though it is irrelevant to the sky spectra.
lndf skyo.lis 1001 hfix 1001 2000 WHT acal 1001 2000 1 1000 N 1 60 0.0001 edit 1001 2000 del Vearth D q write skyo 1001 2000 n
Now load and calibrate the normally-extracted arc, science and sky spectra and output the results to the files arcn.mol, nor.mol and skyn.mol, then close molly and finish:
lndf arcn.lis 1 arc 1 co 1 1000 0.2 q hfix 1 1000 WHT write arcn 1 1000 n lndf nor.lis 1001 hfix 1001 2000 WHT acal 1001 2000 1 1000 N 1 60 0.0001 write nor 1001 2000 n lndf skyn.lis 1001 hfix 1001 2000 WHT acal 1001 2000 1 1000 N 1 60 0.0001 edit 1001 2000 del Vearth D q write skyn 1001 2000 n q y EOF exit