DISCLAIMER: This manual for MXU reductions is just a guideline. It is something I have had to learn myself through toil, blood and sweat. If you want to use this manual to reduce FORS2, or maybe even other data, please do so, but be advised that this is *NOT THE* way of reducing multi-object spectra and it is absolutely *NOT* garantueed to be free of errors.

If you enjoyed this manual, have any suggestions/comments/questions/etc, you can send me an email on .

Last update:
15/02/06: Added information on improved id-ing arc spectra.
15/02/06: Updated the text on extracting faint objects.
15/02/06: Added colouring to important settings.
15/02/06: Added readaxis to the tables.
14/02/06: Added comments regarding gain and read noise.
07/02/06: Added information of old CCD used with FORS2.
07/02/06 and before: Written by Eduard Westra.


First the biassubtraction and flatfielding has to be done. In this case the bias is only subtracted using a fit to the overscan region. For CCD 1 this is [*,1:4], for CCD 2 this is [*,1030:1033]. The data sections are for CCD 1 [*,5:967], for CCD 2 this is [*,311:1029].
region CCD 1 CCD 2
overscan [*,1:4] [*,1030:1033]
data [*,5:967][*,311:1029]
gain 1.43 1.43
readnoise2.90 3.15
readaxis column column
It seems that in older periods FORS2 had only 1 CCD. It has both a pre- and an overscan. Info for that CCD is below:
region CCD
prescan [1:16,*]
overscan [2065:2080,*]
data [17:2064,*]
gain 0.52
readnoise5.41
readaxis line
In several routines below the gain and the read noise need to be given. Since I will be using summing, the gain stays the same for each of the routines. But summing also means that the read noise is not constant for a summed image. Here the read noise will be sqrt(n)*RN, where n is the number of images summed together and RN the read noise.

General data reduction

Biassubtraction

This is done in noao.imred.ccdred using ccdproc. The file list contains the following files:
13_3Da0001_1
13_3Da0002_1
13_3Da0003_1
13_3Da0004_1
13_3Da0005_1
13_3Da0006_1
13_3Da0007_1
13_3Da0008_1
13_3Daarc_1
13_3Daflat01_1
13_3Daflat02_1
13_3Daflat03_1
13_3Daflat04_1
13_3Daflat05_1
NOTICE: Since the discovery that in old periods a single CCD was used, one needs to set the readaxis to the correct value. For the new CCDs this is column, for the old CCD this is line.
PACKAGE = ccdred
   TASK = ccdproc

images  =               @list1  List of CCD images to correct
(output =                     ) List of output CCD images
(ccdtype=                     ) CCD image type to correct
(max_cac=                    0) Maximum image caching memory (in Mbytes)
(noproc =                   no) List processing steps only?

(fixpix =                   no) Fix bad CCD lines and columns?
(oversca=                  yes) Apply overscan strip correction?
(trim   =                  yes) Trim the image?
(zerocor=                   no) Apply zero level correction?
(darkcor=                   no) Apply dark count correction?
(flatcor=                   no) Apply flat field correction?
(illumco=                   no) Apply illumination correction?
(fringec=                   no) Apply fringe correction?
(readcor=                   no) Convert zero level image to readout correction?
(scancor=                   no) Convert flat field image to scan correction?

(readaxi=               column) Read out axis (column|line)
(fixfile=                     ) File describing the bad lines and columns
(biassec=              [*,1:4]) Overscan strip image section
(trimsec=            [*,5:967]) Trim data section
(zero   =                     ) Zero level calibration image
(dark   =                     ) Dark count calibration image
(flat   =                     ) Flat field images
(illum  =                     ) Illumination correction images
(fringe =                     ) Fringe correction images
(minrepl=                   1.) Minimum flat field value
(scantyp=            shortscan) Scan type (shortscan|longscan)
(nscan  =                    1) Number of short scan lines

(interac=                  yes) Fit overscan interactively?
(functio=             legendre) Fitting function
(order  =                    3) Number of polynomial terms or spline pieces
(sample =                    *) Sample points to fit
(naverag=                    1) Number of sample points to combine
(niterat=                    1) Number of rejection iterations
(low_rej=                   3.) Low sigma rejection factor
(high_re=                   3.) High sigma rejection factor
(grow   =                   0.) Rejection growing radius
(mode   =                   ql)
If you trust the fitting perfectly you can leave interac on no. Otherwise you get the following displays:

Flatfielding

The bias has been subtracted, so now normalize the frames. Combine the flatfield images into one image. As we know the gain and readnoise we can use crreject for the rejection. The gain is 1.43 e-/ADU and read noise is 2.90 e- for CCD 1. For CCD 2 the gain is 1.43e-/ADU and the read noise is 3.15 e-.
The flatfield images are combined using median and some sigma clipping. The input file list_flats contains the following:
13_3Daflat01_1
13_3Daflat02_1
13_3Daflat03_1
13_3Daflat04_1
13_3Daflat05_1
PACKAGE = immatch
   TASK = imcombine

input   =         @list_flats1  List of images to combine
output  =               flat_1  List of output images
(rejmask=                     ) List of rejection masks (optional)
(plfile =                     ) List of pixel list files (optional)
(sigma  =                     ) List of sigma images (optional)
(logfile=               STDOUT) Log file

(combine=              average) Type of combine operation
(reject =             crreject) Type of rejection
(project=                   no) Project highest dimension of input images?
(outtype=                 real) Output image pixel datatype
(offsets=                     ) Input image offsets
(masktyp=                 none) Mask type
(maskval=                   0.) Mask value
(blank  =                   0.) Value if there are no pixels

(scale  =               median) Image scaling
(zero   =                 none) Image zero point offset
(weight =                 none) Image weights
(statsec=                     ) Image section for computing statistics
(expname=                     ) Image header exposure time keyword

(lthresh=                INDEF) Lower threshold
(hthresh=                INDEF) Upper threshold
(nlow   =                    3) minmax: Number of low pixels to reject
(nhigh  =                    3) minmax: Number of high pixels to reject
(nkeep  =                    1) Minimum to keep (pos) or maximum to reject (neg)
(mclip  =                  yes) Use median in sigma clipping algorithms?
(lsigma =                   5.) Lower sigma clipping factor
(hsigma =                   5.) Upper sigma clipping factor
(rdnoise=                  2.9) ccdclip: CCD readout noise (electrons)
(gain   =                 1.43) ccdclip: CCD gain (electrons/DN)
(snoise =                   0.) ccdclip: Sensitivity noise (fraction)
(sigscal=                  0.1) Tolerance for sigma clipping scaling corrections
(pclip  =                 -0.5) pclip: Percentile clipping parameter
(grow   =                   0.) Radius (pixels) for neighbor rejection
(mode   =                   ql)

Removing lamp shape

As the lamp is not uniform across the wavelength space, you need to correct for this. This is done in noao.twodspec.apextract using apnormalize.
DELETE THE LAST 5 POINTS!!! As these are not fitting the polynomial very well.
Some useful keystrokes to make an aperture that spans the whole width:
PACKAGE = apextract 
TASK = apnormalize

input   =               flat_1  List of images to normalize
output  =          flat_norm_1  List of output normalized images
(apertur=                     ) Apertures
(referen=                     ) List of reference images

(interac=                  yes) Run task interactively?
(find   =                   no) Find apertures?
(recente=                   no) Recenter apertures?
(resize =                   no) Resize apertures?
(edit   =                  yes) Edit apertures?
(trace  =                   no) Trace apertures?
(fittrac=                   no) Fit traced points interactively?
(normali=                  yes) Normalize spectra?
(fitspec=                  yes) Fit normalization spectra interactively?

(line   =                INDEF) Dispersion line
(nsum   =                   10) Number of dispersion lines to sum or median
(cennorm=                   no) Normalize to the aperture center?
(thresho=                  10.) Threshold for normalization spectra

(backgro=                 none) Background to subtract
(weights=                 none) Extraction weights (none|variance)
(pfit   =                fit1d) Profile fitting type (fit1d|fit2d)
(clean  =                   no) Detect and replace bad pixels?
(skybox =                    1) Box car smoothing length for sky
(saturat=                INDEF) Saturation level
(readnoi=                 2.90) Read out noise sigma (photons)
(gain   =                 1.43) Photon gain (photons/data number)
(lsigma =                   4.) Lower rejection threshold
(usigma =                   4.) Upper rejection threshold

(functio=            chebyshev) Fitting function for normalization spectra
(order  =                  200) Fitting function order
(sample =                    *) Sample regions
(naverag=                    1) Average or median
(niterat=                   10) Number of rejection iterations
(low_rej=                   3.) Lower rejection sigma
(high_re=                   3.) High upper rejection sigma
(grow   =                   0.) Rejection growing radius
(mode   =                   ql)

Normalization

Now the flatfielding and the lampshape removal can be applied. This is done in noao.imred.ccdred using ccdproc
PACKAGE = ccdred
   TASK = ccdproc

images  =            @science1  List of CCD images to correct
(output =      @science1//norm) List of output CCD images
(ccdtype=                     ) CCD image type to correct
(max_cac=                    0) Maximum image caching memory (in Mbytes)
(noproc =                   no) List processing steps only?

(fixpix =                   no) Fix bad CCD lines and columns?
(oversca=                   no) Apply overscan strip correction?
(trim   =                   no) Trim the image?
(zerocor=                   no) Apply zero level correction?
(darkcor=                   no) Apply dark count correction?
(flatcor=                  yes) Apply flat field correction?
(illumco=                   no) Apply illumination correction?
(fringec=                   no) Apply fringe correction?
(readcor=                   no) Convert zero level image to readout correction?
(scancor=                   no) Convert flat field image to scan correction?

(readaxi=               column) Read out axis (column|line)
(fixfile=                     ) File describing the bad lines and columns
(biassec=              [*,1:4]) Overscan strip image section
(trimsec=            [*,5:967]) Trim data section
(zero   =                     ) Zero level calibration image
(dark   =                     ) Dark count calibration image
(flat   =          flat_norm_1) Flat field images
(illum  =                     ) Illumination correction images
(fringe =                     ) Fringe correction images
(minrepl=                   1.) Minimum flat field value
(scantyp=            shortscan) Scan type (shortscan|longscan)
(nscan  =                    1) Number of short scan lines

(interac=                  yes) Fit overscan interactively?
(functio=             legendre) Fitting function
(order  =                    3) Number of polynomial terms or spline pieces
(sample =                    *) Sample points to fit
(naverag=                    1) Number of sample points to combine
(niterat=                    1) Number of rejection iterations
(low_rej=                   3.) Low sigma rejection factor
(high_re=                   3.) High sigma rejection factor
(grow   =                   0.) Rejection growing radius
(mode   =                   ql)

Image combining

For this I have written an IDL script, which removes cosmic rays and then sums the images. This took me a lot of effort to get working. Unfortunately, you have to write something there yourself. I can give you some advice: a reason to do summing is that the gain stays the same for the combined images!!

Spectra specific data reduction

Cutting up

Now the images have to be cut up into pieces. This is done using imcopy.
cl> imcopy 13_3Da_1_comb[*,275:291] spect32
13_3Da_1_comb[*,275:291] -> spect32
cl> imcopy 13_3Daarc_1[*,275:291] arc32
13_3Daarc_1[*,275:291] -> arc32
Check with display and implot (using :c colno) to find the center and the background regions. In this case the 'center' is 13 and the background will run over [2:9].

Add a wavelength solution to the spectrum using identify from noao.onedspec on the arc.

A suggestion for all fitting routines, if it is 1D, 2D or whatever-D, always try to use as low as possible order.
PACKAGE = onedspec
   TASK = identify
    
images  =               arc_01  Images containing features to be identified
(section=          middle line) Section to apply to two dimensional images
(databas=             database) Database in which to record feature data
(coordli= ./highresfors2henear.dat) User coordinate list
(units  =                     ) Coordinate units
(nsum   =                    5) Number of lines/columns/bands to sum in 2D image
(match  =                  -3.) Coordinate list matching limit
(maxfeat=                  100) Maximum number of features for automatic identif
(zwidth =                 100.) Zoom graph width in user units
(ftype  =             emission) Feature type
(fwidth =                  10.) Feature width in pixels
(cradius=                   5.) Centering radius in pixels
(thresho=                1000.) Feature threshold for centering
(minsep =                   2.) Minimum pixel separation
(functio=            chebyshev) Coordinate function
(order  =                    5) Order of coordinate function
(sample =                    *) Coordinate sample regions
(niterat=                    0) Rejection iterations
(low_rej=                   3.) Lower rejection sigma
(high_re=                   3.) Upper rejection sigma
(grow   =                   0.) Rejection growing radius
(autowri=                  yes) Automatically write to database
(graphic=             stdgraph) Graphics output device
(cursor =                     ) Graphics cursor input
crval   =                       Approximate coordinate (at reference pixel)
cdelt   =                       Approximate dispersion
(aidpars=                     ) Automatic identification algorithm parameters
(mode   =                   ql)
Some of these parameters you have to be decided on before doing the reduction of a whole stack of data (also for one, but it saves time when more of the same are done).
fwidth The full width at the base of the arc spectra. Check this with implot. It is very important to have this value correct, since for very broad arclines (due to a wide slit) the finding of the maximum is much more accurate.
cradius Detection radius of new feature. Half of fwidth can do it.
thresholdNecessary to block out the false detections of noise as lines. Can be set as well during the process using :thresh 1e3
minsep Minimum separation between two detections.
order Fitting order of your function. You should usually not go higher than 4.
Get the solution for the complete arc-frame using reidentify.
PACKAGE = onedspec
   TASK = reidentify
    
referenc=               arc_01  Reference image
images  =               arc_01  Images to be reidentified
(interac=                   no) Interactive fitting?
(section=          middle line) Section to apply to two dimensional images
(newaps =                  yes) Reidentify apertures in images not in reference?
(overrid=                  yes) Override previous solutions?
(refit  =                  yes) Refit coordinate function?

(trace  =                   no) Trace reference image?
(step   =                   10) Step in lines/columns/bands for tracing an image
(nsum   =                    5) Number of lines/columns/bands to sum
(shift  =                INDEF) Shift to add to reference features (INDEF to sea
(search =                INDEF) Search radius
(nlost  =                    5) Maximum number of features which may be lost

(cradius=                   5.) Centering radius
(thresho=                1000.) Feature threshold for centering
(addfeat=                   no) Add features from a line list?
(coordli= ./highresfors2henear.dat) User coordinate list
(match  =                  -3.) Coordinate list matching limit
(maxfeat=                  100) Maximum number of features for automatic identif
(minsep =                   2.) Minimum pixel separation

(databas=             database) Database
(logfile=              logfile) List of log files
(plotfil=                     ) Plot file for residuals
(verbose=                  yes) Verbose output?
(graphic=             stdgraph) Graphics output device
(cursor =                     ) Graphics cursor input

answer  =                   NO  Fit dispersion function interactively?
crval   =                       Approximate coordinate (at reference pixel)
cdelt   =                       Approximate dispersion
(aidpars=                     ) Automatic identification algorithm parameters
(mode   =                   ql)
Calculate the 2-D solution to the database using noao.twodspec.longslit.fitcoords
PACKAGE = longslit
   TASK = fitcoords

images  =                arc_01  Images whose coordinates are to be fit
(fitname=                     ) Name for coordinate fit in the database
(interac=                  yes) Fit coordinates interactively?
(combine=                   no) Combine input coordinates for a single fit?
(databas=             database) Database
(deletio=         deletions.db) Deletion list file (not used if null)
(functio=            chebyshev) Type of fitting function
(xorder =                    6) X order of fitting function
(yorder =                    2) Y order of fitting function
(logfile=       STDOUT,logfile) Log files
(plotfil=             plotfile) Plot log file
(graphic=             stdgraph) Graphics output device
(cursor =                     ) Graphics cursor input
(mode   =                   ql)
Fit, of course, it interactively. With the keys `x' and `y' the data on the x- and y-axis can be set, respectively. It's useful to start with the x pixels on x and y pixels on y. Always do a redraw `r' after a change in axes.
Then plot on x the x-axis and on y the `r'esiduals. Set the fitting function to Chebyshev with :function cheb. Then play around with :xorder 4 and/or :yorder 2 to get the best fit. Do exactly the same for y on the x-axis and the `r'esiduals on y. You might `d'elete certain `p'oints or even columns using `z', `y' or `z', but then it's fine.

Apply transform to both the arc and the spectrum and it should be straightened. This should work for rotated slits as well.
transform arc32 arc32t arc32
transform spect32 spect32t arc32
(Set it up the first time as follows:
PACKAGE = longslit
   TASK = transform
    
input   =              spect08  Input images
output  =             spect08t  Output images
(minput =                     ) Input masks
(moutput=                     ) Output masks
fitnames=                arc08  Names of coordinate fits in the database
(databas=             database) Identify database
(interpt=              spline3) Interpolation type
(x1     =                INDEF) Output starting x coordinate
(x2     =                INDEF) Output ending x coordinate
(dx     =                INDEF) Output X pixel interval
(nx     =                INDEF) Number of output x pixels
(xlog   =                   no) Logarithmic x coordinate?
(y1     =                INDEF) Output starting y coordinate
(y2     =                INDEF) Output ending y coordinate
(dy     =                INDEF) Output Y pixel interval
(ny     =                INDEF) Number of output y pixels
(ylog   =                   no) Logarithmic y coordinate?
(flux   =                  yes) Conserve flux per pixel?
(blank  =                INDEF) Value for out of range pixels
(logfile=       STDOUT,logfile) List of log files
(mode   =                   ql)
The spectra are straightened now. Let's remove the background with noao.twodspec.longslit.background.
PACKAGE = longslit
   TASK = background

input   =             spect09t  Input images to be background subtracted
output  =            spect09tb  Output background subtracted images
(axis   =                    2) Axis along which background is fit and subtracte
(interac=                  yes) Set fitting parameters interactively?
(sample =                    *) Sample of points to use in fit
(naverag=                    1) Number of points in sample averaging
(functio=            chebyshev) Fitting function
(order  =                    2) Order of fitting function
(low_rej=                   2.) Low rejection in sigma of fit
(high_re=                   2.) High rejection in sigma of fit
(niterat=                    1) Number of rejection iterations
(grow   =                   0.) Rejection growing radius
(graphic=             stdgraph) Graphics output device
(cursor =                     ) Graphics cursor input
(mode   =                   ql)
Now the spectra are ready to be extracted.

Extraction of spectra

Bright object

For all extraction we use noao.twodspec.apextract.
PACKAGE = apextract
   TASK = apall

input   =          data_1normt  List of input images
(output =                     ) List of output spectra
(apertur=                     ) Apertures
(format =            multispec) Extracted spectra format
(referen=                     ) List of aperture reference images
(profile=                     ) List of aperture profile images

(interac=                  yes) Run task interactively?
(find   =                   no) Find apertures?
(recente=                   no) Recenter apertures?
(resize =                   no) Resize apertures?
(edit   =                  yes) Edit apertures?
(trace  =                  yes) Trace apertures?
(fittrac=                  yes) Fit the traced points interactively?
(extract=                  yes) Extract spectra?
(extras =                  yes) Extract sky, sigma, etc.?
(review =                   no) Review extractions?

(line   =                INDEF) Dispersion line
(nsum   =                   50) Number of dispersion lines to sum or median

                                # DEFAULT APERTURE PARAMETERS

(lower  =                  -5.) Lower aperture limit relative to center
(upper  =                   5.) Upper aperture limit relative to center
(apidtab=                     ) Aperture ID table (optional)

                                # DEFAULT BACKGROUND PARAMETERS

(b_funct=            chebyshev) Background function
(b_order=                    1) Background function order
(b_sampl=                    *) Background sample regions
(b_naver=                    1) Background average or median
(b_niter=                    1) Background rejection iterations
(b_low_r=                   2.) Background lower rejection sigma
(b_high_=                   2.) Background upper rejection sigma
(b_grow =                   0.) Background rejection growing radius

                                # APERTURE CENTERING PARAMETERS

(width  =                   5.) Profile centering width
(radius =                  10.) Profile centering radius
(thresho=                   0.) Detection threshold for profile centering

                                # AUTOMATIC FINDING AND ORDERING PARAMETERS

nfind   =                    1  Number of apertures to be found automatically
(minsep =                   5.) Minimum separation between spectra
(maxsep =                1000.) Maximum separation between spectra
(order  =           increasing) Order of apertures

                                # RECENTERING PARAMETERS

(aprecen=                     ) Apertures for recentering calculation
(npeaks =                INDEF) Select brightest peaks
(shift  =                  yes) Use average shift instead of recentering?

                                # RESIZING PARAMETERS

(llimit =                INDEF) Lower aperture limit relative to center
(ulimit =                INDEF) Upper aperture limit relative to center
(ylevel =                  0.1) Fraction of peak or intensity for automatic widt
(peak   =                  yes) Is ylevel a fraction of the peak?
(bkg    =                  yes) Subtract background in automatic width?
(r_grow =                   0.) Grow limits by this factor
(avglimi=                   no) Average limits over all apertures?

                                # TRACING PARAMETERS

(t_nsum =                   25) Number of dispersion lines to sum
(t_step =                   50) Tracing step
(t_nlost=                    5) Number of consecutive times profile is lost befo
(t_funct=            chebyshev) Trace fitting function
(t_order=                    2) Trace fitting function order
(t_sampl=                    *) Trace sample regions
(t_naver=                    1) Trace average or median
(t_niter=                    0) Trace rejection iterations
(t_low_r=                   3.) Trace lower rejection sigma
(t_high_=                   3.) Trace upper rejection sigma
(t_grow =                   0.) Trace rejection growing radius

                                # EXTRACTION PARAMETERS

(backgro=                  fit) Background to subtract
(skybox =                    1) Box car smoothing length for sky
(weights=                 none) Extraction weights (none|variance)
(pfit   =                fit1d) Profile fitting type (fit1d|fit2d)
(clean  =                   no) Detect and replace bad pixels?
(saturat=                INDEF) Saturation level
(readnoi=                 2.90) Read out noise sigma (photons)
(gain   =                 1.43) Photon gain (photons/data number)
(lsigma =                   4.) Lower rejection threshold
(usigma =                   4.) Upper rejection threshold
(nsubaps=                    1) Number of subapertures per aperture
(mode   =                   ql)

Faint/continuumless object

For all extraction we use noao.twodspec.apextract. For this you need a reference spectrum, preferably closeby of a bright object, from which you have a good trace. Then the settings are all the same, except:
PACKAGE = apextract
   TASK = apall
    
input   =             spect31t  List of input images
(output =                     ) List of output spectra
(apertur=                     ) Apertures
(format =            multispec) Extracted spectra format
(referen=             spect32t) List of aperture reference images
(profile=                     ) List of aperture profile images

(interac=                  yes) Run task interactively?
(find   =                   no) Find apertures?
(recente=                   no) Recenter apertures?
(resize =                   no) Resize apertures?
(edit   =                  yes) Edit apertures?
(trace  =                   no) Trace apertures?
(fittrac=                  yes) Fit the traced points interactively?
(extract=                  yes) Extract spectra?
(extras =                  yes) Extract sky, sigma, etc.?
(review =                  yes) Review extractions?
.
.
.

The trick comes now in how you proceed after inserting these values. Use `s' to use the same data of the aperture defined in your reference spectrum. Then with buttons such as `l'ower and `u'pper limit you can set the aperture size. Just check the `b'ackground sections to see if IRAF took the right values. If this is all right, then you can just `q'uit the routine and save everything to the database and you will have an extracted spectrum.

Flux calibration

This is for every object (bright, faint, continuumless) the same. There should be a sensitivity function derived from a standard star. If not available, the work has to be done in ADU...

This process is done with onedspec.calibrate. Exposure time depends on how you combined your images. For median/average, look in the header, for sum, add all your exposures together.

For airmass I usually use the average of all airmasses.
PACKAGE = onedspec
   TASK = calibrate

input   =          spect32t.ms  Input spectra to calibrate
output  =         spect32tf.ms  Output calibrated spectra
(extinct=                  yes) Apply extinction correction?
(flux   =                  yes) Apply flux calibration?
(extinct= onedstds$ctioextinct.dat) Extinction file
(observa=               esovlt) Observatory of observation
(ignorea=                  yes) Ignore aperture numbers in flux calibration?
(sensiti=                 sens) Image root name for sensitivity spectra
(fnu    =                   no) Create spectra having units of FNU?
airmass =                 1.15  Airmass
exptime =              59.9901  Exposure time (seconds)
(mode   =                   ql)