Personal tools
You are here: Home / COSMOS / Introduction



Back to Table of Contents



COSMOS is a set of programs for the reduction of multislit, spectra obtained with the IMACS and LDSS3 spectrographs on the Magellan Telescopes. It can be used for the quick-look analysis of data at the telescope as well as for pipeline reduction of large data sets. COSMOS is based on a precise optical model of the spectrographs, which allows (after alignment and calibration) an accurate prediction of the location of spectra features. This eliminates the line search procedure which is fundamental to many spectral reduction programs, and allows a robust data pipeline to be run in an almost fully automatic mode, so that large amounts of data can be reduced with minimal intervention. The COSMOS reduction process consists of three steps:

  1. Alignment of the slitmask relative to the CCD focal plane. After proper alignment, the COSMOS optical model can predict the location of slit position/wavelength points on the CCD images to an accuracy of 1 to 2 pixels. If the optical models were perfect, the accuracy of these predictions would be even better. Since they are not, they must be improved by the following step.
  2. Production of an accurate spectral map, during which the optical model predictions are corrected using one or more comparison arcs. This step reduces the errors in predicted positions to a small fraction of a pixel. The map created in this step forms the basis of all following data reduction steps.
  3. Spectral reduction.

Each of these steps consists of several procedures, which are summarized below.

Input Data

The COSMOS reduction process requires the following input data:

  1. A mask definition file which describes the slitmask used. This file was produced by the program maskgen which was used to produce the mask, and will have the name maskname.SMF
  2. A dewar offset file, which describes the positional zero-point of a particular slitmask + instrumental configuration. Default dewar offset files exist for each of the principle configurations and can be used as starting points for the alignment process
  3. An observation definition file which defines the observational setup, including instrument, slitmask (i.e. SMF file), camera, disperser element (and tilt, if a grating), and dewar offset file. These files are created by the program defineobs.
  4. Input data frames, including bias, flat field, comparison arc, and object spectra.


LDSS3 data needs to be stitched together before the alignment. The program stitch will combine the LDSS3 CCD files into one FITS file and makes bias and gain corrections for all the chips.


Although the spectral mapping routines described below are able to correct errors in the COSMOS optical model, they need a reasonably accurate starting point. The processes of mounting masks, inserting them into the focal plane, moving disperser elements in and out, etc inevitably produce some errors in the predicted positions of slit images. The program align-mask uses either a direct or dispersed mask image to correct for errors in x and y position, position angle, and scale of the mask image, by adjusting the values of these parameters in the dewar offset file. Corrections to the dewar offset file can also be made manually using the program adjust-offset.

Spectral mapping

The process of generating and calibrating a spectral map serves two purposes:

  1. It creates a polynomial representation of the mapping from the science coordinate system of slit position and wavelength to the observing coordinate system of CCD coordinates, using the program map-spectra. This polynomial representation allows the data analysis to proceed without the computational machinery involved in the optical model.
  2. It uses one or more comparison arcs to calibrate the spectral map to high precision, using the program adjust-map.

Spectral reduction

Once an accurate spectral map has been produced, reduction of science exposures proceeds in the following steps:

  1. Subtraction of bias, and division by flats, using the programs Sflats and biasflat.
  2. Subtraction of sky, using the program subsky.
  3. Extraction of individual 1 or 2 dimensional spectral exposures using extract, or extract-2dspec. Multiple sets of extracted spectra can be combined, with optional cosmic ray removal, using sumspec

Reduction Pipeline

Execution of the spectral mapping and spectral reduction steps described above can be pipelined together for a set of spectral exposures from a single night using the script-generator process-2spec.

Display and visualization

A number of programs help to display the data and compare them with the predictions of the optical model and spectral map. They include:

  • stitch combines the (2 or 4) LDSS3 CCD files into one FITS file, for processing and for easier viewing.
  • mosaic combines the multiple IMACS CCD files into one FITS file for easier viewing.
  • display8 is an IRAF routine to display the multiple CCD files of an IMACS exposure together as one mosaic
The following routines calculate the predicted location of images in data frames. When used together with one of the above display routines, and the IRAF routine tvmark, they allow one to compare true and predicted location of features.
  • apertures uses the optical model and current alignment to predict the positions of all apertures in the direct image of a slitmask.
  • spectral-lines uses the optical model and current alignment to predict the positions of spectral features in a dispersed image of a slitmask.
  • spectral-map uses a spectral map to to predict the positions of spectral features in a dispersed image of a slitmask.
  • Bugs persist. Please report problems to cosmos[at] We will respond to all emails, but please first ensure that you have read the documentation carefully and are using the software correctly.

Next: Data Files

Back to Table of Contents