-

Spectroscopy


| Preparing data | Data processing | Extraction | Wavelength calibration | Flux calibration | Combination | Computing error bars |

The aim of this page is to give a summary of the spectroscopy reduction scheme we adopted. Many of the sections are linked to a detailed page, where any single step is more carefully explained. The reduction of the data is done using the IRAF package.
For each step we explain also the name convention (NC) we adopted: having a name convention helps exchanges of informations, data and comments.

Preparing data

For the preparation of the data we refer to the photometry section where most of the IRAF tasks are explained.The preparation of the data can be summarized into steps:

BIASSECTION
--> define the overscan region to be used for the overscan correction

TRIMSECTION
--> trim the images

BIASES
--> define a list of biases (hselect can be used for this purpose)
--> write the imagetype (zero) in the header (imred->ccdred->ccdhedit can be used for this purpose)
--> combine the biases in the Zero image (imred->ccdred->zerocombine can be used for this purpose)
(NC) --> Zero.fits

PROCESS THE IMAGES
--> apply the trimsec,biassec and Zero to the images (imred->ccdred->ccdproc is used for this purpose)

FLAT
--> make lists of different Flat (divided by grisms and slits)
--> write the imagetype (flat) in the header
--> combine the flats in the Flat image (imred->ccdred->flatcombine can be used for this purpose)
(NC) --> Flatb.fits (b for blue channel, r for the red one)
--> normalize the Flat (twodspec->longslit->response can be used for this purpose)
(NC) --> Flatbn.fits (b for blue channel, r for the red one)

Data processing



PROCESS THE IMAGES
--> apply the normalized Flatn to the images (imred->ccdred->ccdproc is used for this purpose)

The 'Flat' process has to be applied for any different slits and grisms used.

AIRMASS
If the airmass is not written in the header, then we need to do it in order to use it in the calibration of the data.The task setairmass (both in astutil and onedspec packages) calculates the effective air mass value starting from some keywords in the image headers. If those keywords are not there or, worse, if their format is not the right one, we will get no results or just wrong ones. That's why, before running setairmass, it's necessary to make some checking in the headers. We've already noticed problems in NOT, Lick and ESO's headers. Click NOT,ESO,Lick to see how we solved this problem for the different telescopes.
If everything is ok then
--> run setairmass

BACKGROUND SUBTRACTION
The subtraction of the background is an important step, especially for very faint objects. The task we want to use for it is background. When using apall to both subtract the background and extract the spectrum, there is no way to check if the background subtraction is well done. That's why we prefer to run a specific task for it. This allows to check if the result is good before proceeding to the extraction. Besides there is a bug in the way apall subtracts the background that doesn't allow to use the same order and function for the fit that background uses. The main problem is that we generally prefer to use a spline3 function to fit the background in the whole image, the order depending on the size of the CCD. See in the detailed page for more information. On the other hand the use of a detached task for it, imply that apall will not consider the background when evaluating the errors. To solve this problem Gabriele wrote a script that compute the error due to the background and add it to the third band of the images (see below).
--> run imred->generic -> background
(NC) --> Spectraname.bk.fits

Extraction



SPECTRA EXTRACTION
The spectra are extracted using the task apall in twodspec->apextract of noao package. As we have already said, the subtraction of the background has to be done using the values for the function and the order of it, that gives the best result when running background. The aperture is defined as 90% of the maximum (ylevel=0.1). This is very easy to do when there is no galaxy contamination. When the galaxy and the SN lay on the same spot instead, we define the aperture size by hand, taking the largest possible. We will subtract the galaxy from the spectrum thank to the reference images.
For the extraction we trace the aperture. If the object is very faint, then we suggest to sum several lines together (30 or more depending on how faint is the object). We dont have any particular indication for the function and the order to apply to fit the trace.
--> run twodspec->apextract->apall
(NC)-->Spectraname.ms.fits

ARCLAMPS
If we have more then one arclamp taken at different time during the night, then we try to use all of them. We first copy the arclamps for each of the object we want to calibrate.
(NC) -->arcNN.1.fits
          -->arcNN.2.fits
(where NN is numbers or letters from the object's file name, and 1,2...is depending on how many arclamps are available.)
Then we extract each arclamps following the extracted spectra of the object.
--> run apall arcNN.1  ref=SpectranameNN.bk  recent-  trace-  back-  interac-
--> run apall arcNN.2  ref=SpectranameNN.bk  recent-  trace-  back-  interac-
-->   "
-->   "
-->  

Wavelength calibration



ARCLAMPS
We want to use the extracted arclamps to define the function that transforms from pixels to wavelengths. The reason why we do it for each of the spectra is to get rid of possible deformations of the spectrograph that can be different depending on the position observed in the sky. For this reason it would be good to have one arclamp for each of the object observed, taken immediately after or before the exposure. This is of course very difficult to have. That's why we suggest to extract the spectrum of the sky from the same 2D image and check if the wavelength calibration make any sense.
In order to calibrate in wavelength we need to identify the spectral lines from the arclamp and then fit them as a function pixels vs wavelengths. The task for doing this is called identify. We suggest to try not to increase the order of the fit to much (up to 3 or 4 depending on the number of the lines identified)
--> run onedspec->identify
The identification of the lines can be done in one of the arclamps only, and then it can be used to fit the dispersion function for the other arclamps. This is done running reidentify, and using the first one as reference.
--> run onedspec->reidentify

CALIBRATION OF THE SPECTRA
Now to proceed with the wavelength calibration we want to assign a dispersion function to each spectrum. This is done writing in the header the name of the acrlamps to be used. If more then one arclamp is used then it's possible to give a weigth to them, otherwise they are considered at the same importance.
-->run onedspec->refspec
Now we are ready to calibrate our spectra. This is done running dispcor.
-->run onedspec->dispcor
(NC)-->Spectraname.w.fits
As we already said, it's possible to use the sky spectrum to check if the wavelength calibration is well done. This is the right moment for doing it. So do it now!

Flux calibration



STANDARD
The first step of this process is to compare the standard stars with their tabulated fluxes. The tables can be find in http://panisse.lbl.gov/nearsearch.One more think we need is the extiction file e.g. a file containing the atmospheric extinction vs wavelength of the telescope site. Some of the files can be downloaded here,NOT, Lick,CTIO. Now we have to run the task standard. One thing we recommend is to specify the width and the bandpass separation, in order to have the same number of points for each standard star. It's also possible to delete points interactively. This can be done in order to delete the atmospheric absorption lines. Click here to see them. This task has to be run on all the standard stars we have, with the same output file.
-->run onedspec->standard
(NC)-->std.b (b for blue channel, r for the red one)

THE SENSITIVITY FUNCTION
Now we can construct the sensitivity function. We have to set the same extinction file that we used in standard in the parameters. We suggest to use a spline3 to fit the function. This helps to fit the different slope of the curve. It's of course also possible to use an high order legendre in some of the cases.
-->run onedspec->sensfunc
(NC)-->sens.b.fits (b for blue channel, r for the red one)

FLUX CALIBRATION
Now we can use the sensitivity function to flux calibrate the spectra. We have again to set the same extinction file in the parameters.
-->run onedspec->calibrate
(NC)-->Spectraname.c.fits

Combination



If we have more then one spectra for each object, then we want to combine them in order to increase the signal to noise ratio. We want to average points corresponding to the same wavelength, for this reason it's important to use scombine rather then combine or imcombine.
-->run onedspec->scombine
(NC)-->for ex.: sn99aa.NOT.990313.b.fits

Computing the errors



CONSIDERING THE BACKGROUND IN THE SIGMA
As we already pointed out, our method of subtracting the background leads to underestimating the statistical errors written in the third band by apall. Gabriele wrote a script to correct this problem, following the formula for the variance given in the help of apvariance and following what is explained in 1986PASP 98 609H. Here is the help for that script. If you followed our convention with names, the script should run without any problems (in principle). If you used different names, then you have to change the script itself. NOTE: changing the filenames at this point is not a good idea because the script looks for information in various logfiles.

EVALUATING THE SYSTEMATIC ERRORS
We refer to the document Check and errors estimation on reduced spectra for general information about the methodology we have chosen. For evaluating the systematics we wrote a program in IDL, that can be downloaded here. You need also this and this. If you have any problems with them you can contact Serena.

EVALUATING THE STATISTICAL ERRORS
When combining the spectra using scombine the third band disappears from the fits file. For this reason we wrote a program in IDL that computes the statistical uncertainty. That is here, but you need this also. If you have any problems with it you can contact Serena.




This page will be under construction FOREVER.
Serena is writing it,but for questions or comments you can write to any of us:
serena@physto.se
gabri@physto.se
gaston@physto.se

Last update: Apr. 6, 2001