OM data reduction with SAS: grism data processing chain


The processing chain omgchain, used to obtain OM grism spectra from the ODF, is a concatenation of several SAS tasks run consecutively. All these steps are described in detail.

Expected Outcome

OM UV or optical grism spectra in fits format. Spectra will be given on a wavelength grid in count rates and absolute flux units.

SAS Tasks to be Used


The SAS has to be setup following the SAS Startup Thread.

Useful Links


Last Reviewed: 25 MAY 2023, for SAS v21.0

Last Updated: 21 October 2014



OM grism data are obtained as image mode data. The different nature of this type of data, dispersed spectra of each object in the field of view instead of their "sky" image, requires special processing of grism images. A series of tasks, some of them common with "normal" images, have been developed. They are concatenated in a perl script, omgchain, which works in a similar way to the image and fast mode chains.

A detailed description of each task can be found in the SAS documentation, both in HTML and Postscript format. A step by step description of the grism extraction chain and examples of the processing by individual execution of all tasks is given in the SAS User's Guide.

The omgchain applies all necessary corrections to the grism data files. The images are rotated to have the dispersion direction aligned with the image columns. Then a source detection algorithm is used to identify the spectra (zero and first dispersion orders) of the sources present in the grism image.

By default, omgchain will extract the spectrum of the target located at the boresight. All spectra present in the grism image (obtained in full frame or with a rectangular window) can be extracted using the parameter extractfieldspectra=yes when invoking omgchain. Then the spectra for which a correlation can be established between zero and first orders are extracted and fully calibrated. Astrometric corrections are applied to the zero order position of the extracted spectra to determine the sky coordinates of the corresponding object.

The individual steps performed by omgchain are listed below.

For illustration of the steps, we use only one grism image with exposure number ${ENUM}$ to be defined via an environment (three digits with leading zeros) variable (see step0). Also, the revolution in which the observation was taken and the ObsID need to defined as environment variables REV and OBSID in order to perform the steps below via simple copy-paste.

OM grism data are image mode data to which tracking corrections are not applied, and we therefore need in addition to spacecraft and summary files:

  ${REV}_${OBSID}_OMS${ENUM}00WDX.FIT - Exposure priority window file
  ${REV}_${OBSID}_OMS${ENUM}00IMI.FIT - Exposure image file with grism data

We refer to the Data Files Handbook for definition of ODF file names.

It is assumed throughout this example that the ODF data are in: ${MYDATA}/
and we are running the tasks and writing their results in a subdirectory: ${MYDATA}/grism/

The steps below process a single grism exposure and needs to be repeated for each exposure separately to process all exposures within the observation.

step 0

Set environment variables in order to copy-paste the commands below. Here exposure number 006 in ObsID 0650300201, taken in revolution 1868 is used as an example.

Revolution in which observation was taken:

setenv REV 1868

ObsID of observation:

setenv OBSID 0650300201

Exposure number to be processed:

setenv ENUM 006

Directory where uncalibrated raw (=ODF) data are located

setenv MYDATA .....

Then produce output directory:

mkdir ${MYDATA}/grism/

step 1


The input image here corresponds to a user defined window. In case we had a full frame low resolution exposure, then omcomb must be run beforehand and its output image be used as input for omprep,

omprep set=${MYDATA}/${REV}_${OBSID}_OMS${ENUM}00IMI.FIT \
 pehset=${MYDATA}/${REV}_${OBSID}_OMX00000PEH.FIT \
 nphset=${MYDATA}/${REV}_${OBSID}_OMX00000NPH.FIT \
 wdxset=${MYDATA}/${REV}_${OBSID}_OMS${ENUM}00WDX.FIT \
 outset=${MYDATA}/grism/g${OBSID}OMS${ENUM}IMAGEI0000.FIT \

step 2

Modulo_8 fixed pattern noise is corrected,

ommodmap set=${MYDATA}/grism/g${OBSID}OMS${ENUM}IMAGEI0000.FIT \
 mod8product=yes \
 mod8set=${MYDATA}/grism/g${OBSID}OMS${ENUM}MOD8MP0000.FIT \
 outset=${MYDATA}/grism/g${OBSID}OMS${ENUM}IMAGE_0000.FIT \
 outflatset=${MYDATA}/grism/g${OBSID}OMS${ENUM}FLAFLD0000.FIT \
 nsig=3 \
 nbox=16 \

step 3

We obtain now the undistorted and rotated image from which the spectrum, or spectra, will be extracted.

omgprep set=${MYDATA}/grism/g${OBSID}OMS${ENUM}IMAGE_0000.FIT \


step 4

The source spectra are now detected. They can be checked by overplotting the region file on the rotated image, using ds9.

omdetect set=${MYDATA}/grism/p${OBSID}OMS${ENUM}RIMAGE0000.FIT \
 regionfile=${MYDATA}/grism/g${OBSID}OMS${ENUM}REGION0001.ASC \
 outset=${MYDATA}/grism/p${OBSID}OMS${ENUM}SWSRLI0001.FIT \

step 5

Astronomical coordinates, RA & Dec, are computed for the detected spectra,

omatt set=${MYDATA}/grism/p${OBSID}OMS${ENUM}RIMAGE0000.FIT \
 sourcelistset=${MYDATA}/grism/p${OBSID}OMS${ENUM}SWSRLI0001.FIT \

Step 6

Detected spectra are extracted and calibrated.

omgrism set=${MYDATA}/grism/p${OBSID}OMS${ENUM}RIMAGE0000.FIT \
 sourcelistset=${MYDATA}/grism/p${OBSID}OMS${ENUM}SWSRLI0001.FIT \
 outset=${MYDATA}/grism/p${OBSID}OMS${ENUM}SPECTR0000.FIT \
 bkgoffsetleft=6 bkgwidthleft=-6 bkgoffsetright=6 \
 bkgwidthright=-6 spectrumhalfwidth=-6 \
 spectrumsmoothlength=0 extractionmode=0 extractfieldspectra=no \
 outspectralistset=${MYDATA}/grism/p${OBSID}OMS${ENUM}SPECLI0000.FIT \
 regionfile=${MYDATA}/grism/p${OBSID}OMS${ENUM}REGION0001.ASC \


step 7

Finally, we can plot the results.

omgrismplot set=${MYDATA}/grism/p${OBSID}OMS${ENUM}SPECTR0000.FIT \
 plotfile=${MYDATA}/grism/g${OBSID}OMS${ENUM}SPECTR0000.PS \
 spectraregionfile=${MYDATA}/grism/p${OBSID}OMS${ENUM}SPCREG0001.ASC \
 regionplotfile=${MYDATA}/grism/p${OBSID}OMS${ENUM}SPCREG0001.PS \
 rotatedimageset=${MYDATA}/grism/p${OBSID}OMS${ENUM}RIMAGE0000.FIT \
 binsize=1 plotdevice=/PS scalebkgplot=no plotflux=2


step 8

The same checks of resulting products need to be performed as in the omgchain thread.



The steps have to be performed in the order given because the input depends on the output produced by previous steps.