This is a recipe using SPICE to extract a spectrum from IRS data for the object Herbig-Haro 46/47. We outline the basic steps for using SPICE as a generic example for handling any point source data obtained with Spitzer IRS-Staring Mode. This specific example involves an extraction from the SL2 module, but it is generally applicable to all low-resolution IRS data. This demonstrates only a point source extraction; SPICE is currently capable of extracting spectra for extended sources. For a discussion, see the SPICE Manual on our website.
15.1 Requirements
You will need the Spitzer archive tool to download the example data set.
A recipe for downloading data can be found in Recipe 1. For this example we will use the IRS data for the Herbig Haro object HH 46/47, AOR 7130112. It is sufficient to download the BCD data for this demonstration.
In this recipe, we will focus on SL2 (short-low, order 2) data. Therefore, once the data are downloaded, you will be most interested in the *bcd.fits files in the subdirectory called r7130112/ch0/bcd/. (All the data in ch0/ is from the short-low module, while ch1/ holds short-high data and ch3/ holds long-high data.)
unix% ls *bcd.fits
SPITZER_S0_7130112_0000_0000_6_bcd.fits
SPITZER_S0_7130112_0000_0001_6_bcd.fits
SPITZER_S0_7130112_0000_0002_6_bcd.fits
SPITZER_S0_7130112_0000_0003_6_bcd.fits
SPITZER_S0_7130112_0001_0000_6_bcd.fits
SPITZER_S0_7130112_0001_0001_6_bcd.fits
SPITZER_S0_7130112_0001_0002_6_bcd.fits
SPITZER_S0_7130112_0001_0003_6_bcd.fits
SPITZER_S0_7130112_0002_0000_6_bcd.fits
SPITZER_S0_7130112_0002_0001_6_bcd.fits
SPITZER_S0_7130112_0003_0000_6_bcd.fits
SPITZER_S0_7130112_0003_0001_6_bcd.fits
SPITZER_S0_7130112_0004_0000_6_bcd.fits
SPITZER_S0_7130112_0004_0001_6_bcd.fits
SPITZER_S0_7130112_0005_0000_6_bcd.fits
SPITZER_S0_7130112_0005_0001_6_bcd.fits
To identify each BCD file, examine the "FOVNAME" keyword in the fits headers. An easy way to do this is to use the imhead command available as part of the WCSTools package (http://tdc-www.harvard.edu/wcstools/), but you can use your own favorite method.
unix% imhead *bcd.fits | grep FOVNAME
FOVNAME = 'IRS_Blue_Peak-Up_FOV_Center' / Field of View Name
FOVNAME = 'IRS_Blue_Peak-Up_FOV_Center' / Field of View Name
FOVNAME = 'IRS_Blue_Peak-Up_FOV_Center' / Field of View Name
FOVNAME = 'IRS_Blue_Peak-Up_FOV_Center' / Field of View Name
FOVNAME = 'IRS_Blue_Peak-Up_FOV_Sweet_Spot' / Field of View Name
FOVNAME = 'IRS_Blue_Peak-Up_FOV_Sweet_Spot' / Field of View Name
FOVNAME = 'IRS_Blue_Peak-Up_FOV_Sweet_Spot' / Field of View Name
FOVNAME = 'IRS_Blue_Peak-Up_FOV_Sweet_Spot' / Field of View Name
FOVNAME = 'IRS_Short-Lo_2nd_Order_1st_Position' / Field of View Name
FOVNAME = 'IRS_Short-Lo_2nd_Order_1st_Position' / Field of View Name
FOVNAME = 'IRS_Short-Lo_2nd_Order_2nd_Position' / Field of View Name
FOVNAME = 'IRS_Short-Lo_2nd_Order_2nd_Position' / Field of View Name
FOVNAME = 'IRS_Short-Lo_1st_Order_1st_Position' / Field of View Name
FOVNAME = 'IRS_Short-Lo_1st_Order_1st_Position' / Field of View Name
FOVNAME = 'IRS_Short-Lo_1st_Order_2nd_Position' / Field of View Name
FOVNAME = 'IRS_Short-Lo_1st_Order_2nd_Position' / Field of View Name
You can see that the first eight files are associated with peak-up acquisition, and only the last eight files contain spectroscopic data. As stated above, we are interested in reducing the SL2 data. As part of the normal observations sequence, the target is placed in each of two positions along the SL2 slit. The general procedure is to extract a 1D spectrum for each nod position, and then average the nods. In the following, we will focus on extracting a 1D spectrum from the 2nd nod position. You can follow an analogous procedure to extract a 1D spectrum from the 1st nod position. In the last step, we'll combine the two nods.
15.3 Subtract the background
The next step is to use the downloaded BCDs to create a background-subtracted 2D spectral image on which to perform the extraction. There are two steps to this: building the background and subtracting it. SPICE does not perform either of these steps for you. You will have to use an image processing program, such as IRAF or IDL. When doing so, be sure to retain the FITS header from your BCD image. The basic steps are outlined below.
15.3.1 Building the background
You can build your background for SL2 nod 2 from the other nod position, from the other order, or both.
Build your background from the other nod position. As part of the default observing sequence, staring mode targets are placed in each of two positions along the slit. When the source is in position 1, the sky will be in position 2. Therefore, if we want to build a sky image for position 2, we can use the position 1 frames. In our example, this would mean building sky frames from sources with FOVNAME header values of 'IRS_Short-Lo_2nd_Order_1st_Position'. Thus, our background frames would be:
SPITZER_S0_7130112_0002_0000_6_bcd.fits
SPITZER_S0_7130112_0002_0001_6_bcd.fits
Using IRAF or IDL, you can average these frames to create a background image. In this case, there are only two images, which is not ideal for removing bad pixels.
Build your background from the other spectral order. In this example, both SL1 and SL2 observations were taken. When a target is placed in the SL1 slit, the sky is in the SL2 slit. Therefore, we can use SL1 observations to build up a sky image for SL2 data. In our example, the SL1 images are:
SPITZER_S0_7130112_0004_0000_6_bcd.fits
SPITZER_S0_7130112_0004_0001_6_bcd.fits
SPITZER_S0_7130112_0005_0000_6_bcd.fits
SPITZER_S0_7130112_0005_0001_6_bcd.fits
Using IRAF or IDL, you can average these frames to create a background image. In this case, we have four images to combine, which will result in a sky image with lower noise than the previous option.
Build your background using both the other nod position and the other spectral order. To build a background frame with even higher signal-to-noise, we can use both the SL2 images taken in Position 1 and the SL1 images:
SPITZER_S0_7130112_0002_0000_6_bcd.fits
SPITZER_S0_7130112_0002_0001_6_bcd.fits
SPITZER_S0_7130112_0004_0000_6_bcd.fits
SPITZER_S0_7130112_0004_0001_6_bcd.fits
SPITZER_S0_7130112_0005_0000_6_bcd.fits
SPITZER_S0_7130112_0005_0001_6_bcd.fits
This gives us six images with which to build the sky frame, and therefore better statistics than the previous two methods. This is the option we choose for this recipe. One of the two options above may be sufficient for your needs depending on the number of frames available.
15.3.2 Subtracting the background
The next step is to create a single, background-subtracted 2D image of the SL2 nod 2 spectrum. There are two strategies you can employ:
1. Stack the background-subtracted BCDs. Start by background-subtracting each of the SL2-nod2 BCDs:
SPITZER_S0_7130112_0003_0000_6_bcd.fits
SPITZER_S0_7130112_0003_0001_6_bcd.fits
Make sure you retain the header information from the BCDs (and not from the background image you created), so that SPICE knows that this is a SL2-nod2 spectrum.
Now you have two background-subtracted BCDs. You can combine these using a simple average to create a single, 2D background-subtracted image of the SL2-nod2 spectrum.
2. Stack the BCDs, then subtract the background. Alternatively, you can average together the SL2-nod2 BCDs and then subtract the background from the result. Again, you must make sure that the result carries the header information from the SL2-nod2 BCDs, and not from the background image. This should provide a very similar result to the previous method.
Either way you choose, be sure to create new *unc.fits and *bmask.fits files as well. You should propogate the pixel-by-pixel uncertainties and combine the mask bit flags using the "OR" operator.
15.4 Choose a SPICE extraction template
1. Launch SPICE.
2. Within the SPICE GUI, open a point source extraction flow using File --> Open Spice Generic Template --> Point Source with Regular Extract.
15.5 Run the Initialize Module
1. Load the bcd, uncertainty and mask files into SPICE. This is done by clicking on the "Modify" button for the "Image File" in the Initialize Parameters and Files module. If you are using archive file names, the corresponding mask and uncertainty files will be selected automatically. The BCD image will be displayed in the FITS window, as shown in the image below.
You can change the contrast ("stretch") of the 2-D image on the right by clicking on the color-grid button at the right of the FITS window. You can zoom the image using the controls to the left of the full SPICE window. See figure below -- the controls are circled in red.
2. Select the output directory for the output *.profile.tbl, *.ridge.tbl, *.extract.tbl, and *.spect.tbl files generated by the extraction. The ultimate output table of interest is the *spect.tbl -- this is your extracted 1-D spectrum in (ascii) IPAC table format. You can make the selections by pressing the "Output" button.
3. When you have set all the input parameters, run the Initialize Parameters and Files module, using the run button in the upper left of the module window:
15.6 Run the profile module
To begin the extraction, establish the wavelength-collapsed average profile in the spatial direction across the 2-D background-subtracted spectrum, using the Profile module. See the figure below. Note that for the background-subtracted spectrum, a "positive" profile (your spectrum) and a "negative" profile (the spectrum in the other nod), relative to a zero level, are seen as the output.
15.7 Run the Ridge module
Next, establish the (peak) ridgeline of the spectrum in the dispersion direction along the 2-D spectrum. See bottom figure below. Running the Ridge module will perform the function. You can either allow SPICE to automatically derive the ridge peak or set the ridgeline peak manually.
15.8 Run the Extract module
To extract the spectrum, run the Extract module, which is next in the flow. The extraction can be done with the default parameters for this example. For the low-resolution modules, the spectrum is extracted along the Ridge location, in accordance with the wavelength-dependent Point Spread Function (PSF) and the spectral trace (with pipeline-optimized width). The Extract function can employ a window with a different width ("Manual" width), but the width will still scale with wavelength, unless a full-slit extraction ("ExtSrc" width) is specified. Note that the output of the extraction is still in instrumental units, i.e., electrons/sec.
15.9 Run the Tune module
You still need to "tune" the extraction by applying the flux conversion from instrumental to absolute flux units. To do this, run the Point Source Tune module. This function will correct the slope and curvature of each order by applying the polynomial coefficients in the *_fluxcon.tbl file. This correction is based on an order-by-order comparison of calibration data to standard star model spectra. The flux units are now in Janskys (Jy). This completes the spectral extraction for this module. Note that the so-called "bonus order" of SL2 is somewhat mismatched in flux. You can choose to keep this bonus order, or exclude it (since it overlaps with an order in SL1). Our extraction looks remarkably like the short-wavelength portion of the one in the Spitzer press release and the published paper (Noriega-Crespo et al. 2004, ApJS, 154, 352; see bottom figure below, circled in yellow)... as it should!
15.10 Combine Extractions and Examine Results
You can perform custom extractions on all the modules and orders for these observations, merge the various spect.tbl tables together (outside of SPICE!), and obtain a spectrum similar to what is shown below.