Joint Astronomy Centre
Show document only
JAC Home
JCMT
UKIRT
Contact info
JAC Divisions
OMP
Outreach
Seminars
Staff-only Wiki
Weather
Web Cameras
____________________

Observing at UKIRT
Service Observing
UKIDSS Survey Operations
Target of Opportunity
Calibration & Utilities
UKIRT Archive
Public wiki
Accessing Flexed Data
Accessing UKIDSS Data
Reduction Cookbooks
Telescope
Site Quality
Instruments
Newsletter/Publications
UKIRT Faults
JAC Safety Manual
List of Arc Spectra
JACH | JCMT | UKIRT | Computer Services | CGS4  
Up: CGS4 Handbook 
 
Post-Reduction of CGS4 data with IRAF

Brad Cavanagh has written a number of scripts to aid with the pre and post-reduction of CGS4 observations of point sources . These may be accessed here . Below we give a few pointers to those who wish to use IRAF to reduce observations of extended line emission features using standard IRAF tasks.

It is assumed that (in CGS4DR) you have already interleaved the individual integrations (if your sampling was anything other than 1x1), subtracted a bias (if necessary), divided by a normalised flat field, subtracted skies from source frames and constructed a "reduced group"; an rg file. You may now wish to:

  • Correct for distortions along the dispersion axis (i.e. curved standard star spectrum),
  • Correct for distortions in the spatial direction (i.e. along the slit, evident as tilted or curved arc or OH sky lines), and/or
  • Extract multiple spectra from your data at different positions along the slit.
The tasks in IRAF that allow you to correct for geometrical distortions are in the noao.twodspec.longslit package. Notably, in correcting for distortions in the spatial direction, we will also WAVELENGTH CALIBRATE the data.

Run up IRAF and access the noao package by typing twodspec and longslit.

1. OPTICAL DISTORTIONS I: CURVED/TILTED CONTINUUM SPECTRUM

Display a standard star observation. Use implot to examine the band of continuum emission in this spectral image by plotting cuts in y at different positions along the x-axis (note that the dispersion axis is assumed to be horizontal). Fitting gaussians to these cross-cuts allows you to measure any variation in the position of the peak along the dispersion axis.

    >> implot stand1 (where "stand1" is the name of your standard file)
With the cursor positioned in the plotting window (click a couple of time to activate) type :c 50 to display column 50. Position the cursor on either side of the "emission peak"; type e at each position to magnify this part of the plot. Now, with the cursor positioned on either side of the line, hit p at each position to fit the line. Repeat this procedure for different columns along the standard spectrum to check for shifts in the peak position. Finally, type q to quit.

Should you need to correct for curvature, then you should employ the identify, reidentify, fitcoords and transform tasks, first to your standard observations, and then to your object spectral images.

Firstly, set the parameters in each task to their default values

    >> unlearn identify
    >> unlearn reidentify
    >> unlearn fitcoords
    >> unlearn transform
To rectify for distortions in the spectral dimention, you should ideally observe the standard at different positions along the slit. You "may" make some improvement (de-tilt) even if you have observed your standard at only one position along the slit. However, you do then assume that the tilt does not vary with position along the slit. Here we assume that the standard has been observed at 3 positions along the slit; these spectra are called stand1, stand2 and stand3.

First, use identify the mark the position of the standard spectrum (in y) along the central column in stand1 . Edit the following parameters in identify :

    >> epar identify
      images = stand1
      section = middle column
      nsum = 3
      function = cheby
      order = 2
To exit from the editor, type :q . The coordlist should be left blank. The default settings for the remaining parameters should be ok. lpar identify will list the parameters you have stored. To run the task:
    >> identify
The plot device will display a cut in y; the central column. Position the cursor on the standard spectrum, type m to mark this position followed by return to accept the coordinate value of the marked position (If there are more standard stars along the slit in the same spectral image, mark the positions of these in the same way). Finally type q twice when you have finished. A file idstand1 will be written to the directory database.

Now, measure the position of the same standard spectrum along different columns in stand1 using reidentify . Edit the following parameters:

    >> epar reidentify
      reference = stand1
      images = stand1
      section = middle column
      step = 3
      nsum = 3
Again, the coordlist should be left blank. Run this task by typing reidentify verbose+ ; this will display on the screen the position of the standard spectrum found along each column (these data are also stored in your logfile).

Now, repeat identify and reidentify on the other two standard star spectral images, stand2 and stand3.

We must next find the transformation parameters that will correct for the distortion in the dispersion direction evident in these standard spectra; we will use the task fitcoords to do this:

    >> epar fitcoords
      images = stand1,stand2,stand3
      fitname = stars
      interactive = yes
      combine = yes
      function = chebyshev
      xorder = 2
      xorder = 2
Run the task by typing fitcoords ; because we have chosen combine to be yes, the data from the three entries in the database will be combined. We are running this task interactively; the fit will therefore be displayed on the plotting device. To increase the order of the fit type :x 3 and :y 3 ; to remove bad points position the cursor on the point and type d . Type f to re-fit; Type q to quit. Answer yes to writing the coordinate map to the database; the file database/fcstars will then be created.

All that remains now is for us to transform first the standard star spectral images, and then the data themselves. Edit the parameters in transform .

    >> epar transform
      input = stand1
      output = stand1t
      fitname = stars
Typing transform will thus generate a new spectral image stand1t which you can blink against the untransformed file stand1 , or examine as described above using implot .

2. OPTICAL DISTORTIONS II: TILTED ARC/SKY LINES

In a very similar way we may correct for distortions in the spatial direction. We will also simultaneously wavelength calibrate our data.

Briefly: run identify on your arc spectrum, though this time the middle section must be set to the central line and the coordlist set to linelists$argon.dat , assuming you're using an argon calibration lamp. (To check the other lists available, type page linelists$README ). Mark each specral line on your argon spectrum with m and each time type in the wavelength of the line (in microns) before hitting return. Once you've marked at least a half-dozen lines, hit f to make the fit. The residuals will be displayed. Delete/undelete wayward points with d/u and refit. To display the linearity of the transformation type h . Once you're happy with the fit type q ; the lines remaining in the fit will be displayed; and q again to quit. The file idarc will be written (assuming your arc spectrum was called "arc").

Next run reidentify on your arc. Again, the middle section must be set to the central line and the coordlist set to linelists$argon.dat .

Then fit the coordinates with fitcoords ; do this interactively since you may wish to change the order of the fit and/or delete points. If you are using just one arc spectrum, set combine to no and leave the fitname blank; the task will then automatically write the file fcarc to the database.

Finally, transform your arc spectrum with transform . If the input, output and fitnames are arc, arcr and arc respectively, the task will use the file fcarc and produce the transformed spectral image arcr . Again, examine your data with implot and, if you're happy with the transformation, run transform on your object spectral images. Note that in implot to display the spectra in world coordinates (i.e. microns) type :w world in the plotting window.

NOTE: If you wish to transform in both spectral AND spatial directions ; run identify , reidentify and fitcoords on your standard star images and arc spectrum as described above. This will yield the fit parameter files fcstand and fcarc in your database. These can then be used SIMULTANEOUSLY in transform to make the two-dimentional transformation of your data. E.G.:

    >> epar transform
      input = arc,stand1,stand2,stand3
      output = arctr,stand1tr,stand2tr,stand3tr
      fitnames = arc,stars
Here we first transform the arc and standard spectral images, so that we can check the transformations in x and y with implot before proceeding to transform the data.

3. EXTRACTING SPECTRA AT DIFFERENT POSITIONS ALONG THE SLIT

You may now wish to extract a spectrum from your spectral image (and ratio this by a standard star). However, the popular task apall cannot be used directly because there is no continuum spectrum to trace and extract in your line-emission data. Fortunately, we can use apall to extract a REFERENCE spectrum from a standard star exposure and use this trace to extract a spectrum from the line-emission data. In using this reference trace we will of course only extract a spectrum from the same row in the line-emission data. To extract spectra from many locations up and down the slit, we need to employ an additional trick. We can use the task imshift to shift the standard continuum specrum up and down the slit by the desired amount, and then use apall to extract separate reference traces at these location. You will then have a set of reference traces up and down the slit that can be used to extract spectra from your line-emission data. A cautionary note, however: here we assume that the actual trace does not vary up and down the slit (i.e. that the optical distortions are not very large).

So, having used imshift to shift the standard star spectrum to the desired location on the slit, next use apall to find the trace along the dispersion axis. Apall is a particularly sophisticated task with many parameters; below we suggest a few values which you may wish to change from the default.

    >> epar apall
      input = stand.91
      output = 1dspec/stand.91
      format = onedspec
      line = INDEF
      nsum = 3
      radius = 5
      width = 3
      llimit = -4
      ulimit = 4
      b_sample = -15:-7,7:15
      b_naver = -3
      b_order = 1
      t_nsum = 5
      t_step = 10
      t_funct = spline3
      t_order = 3
      t_niter = 0
      background = fit
      weights = none
      clean = yes
      satur = INDEF
In the above, a 1-D spectrum will be extracted from the spectral image stand.91 and written to the directory 1dspec as stand.91.0001 (the nomenclature denotes the fact that the continuum spectrum has been shifted to row 91). The trace is written to the database as apstand.91 . However, before actually running apall, we must first tell the software that the dispersion axis is in x;
    >> apextract.dispaxis=1
With line = INDEF the task will then use the middle column.

Now we can run apall . Replying yes to the first few questions will yield the result of the search for an extraction aperture on the plot screen. If the selection is wrong, delete the choice with d and remark with m. You can also increase or decrease the lower and upper bounds used ( llimit; ulimit) by positioning the cursor and hitting l and u respectively; hit f to refit. Now type b to check that the background has been set correctly; type z to delete a background region that, say, overlaps the star's emission profile, and use s to mark the lower and upper bounds of a new region. Again type f to refit. Type q a couple of times to continue and reply yes to the questions regarding tracing and fitting the trace. The fit will then be displayed. You may wish to change the fitting function or the order, or delete any deviant points from the fit. Try :order 2 and :func cheby; to delete points position the cursor and type d. Once again, type f to re-fit. Once you're happy with the fit, hit q to continue and reply yes to the remaining questions. You should now have a trace that you can use to extract a spectrum from your line emission data.

Again we will use apall . However, since we will use our standard reference spectrum to establish both the trace and the center in our line-emission data, you can either type

    >> apall source reference=stand.91 trace- recenter-
Or edit the appropriate parameters in apall . With output set to 1dspec/source.91 a 1-D spectrum from the line-emission spectral image will be written to disk.

Finally, you may want to ratio the line-emission spectrum by a standard star spectrum to flux-calibrate the data and remove atmospheric absorption features. In running apall the first time, you have already extracted the standard star spectrum, stand.91.0001 and wrote this to disk. Now use Brad Cavanagh's very neat script , irflux , to ratio the object (source.91.0001) and standard (stand.91.0001) spectra. You should finish with a nice flux-calibrated spectrum.

AND FINALLY...

For a very thorough description of the tasks mentioned above, and an excellent discussion on reducing long slit spectroscopic data, we heartily recommend the excellent User's Guide to Reducing Slit Spectra with IRAF by Massey, Valdes and Barnes; available here .
 


Last Modification Date: 1998/02/25 - Last Modification Author: Chris Davis
Chris Davis (c.davis)
Contact: Tom Kerr. Updated: Wed Oct 6 11:58:01 HST 2004

Return to top ^