Clone wiki

MMIRS pipeline / Home

MMIRS Data Reduction Pipeline

Pipeline Description and Installation

The MMIRS pipeline is an IDL-based code, and requires IDL 7.x to run, ideally on a machine with at least 8GB of RAM. To install the code, first download the mmirs repository from here. With git, you can do:

git clone

This will download both the pipeline ('pipeline' folder) and dependencies ('deps' folder) required to run the pipeline

  • The 'pipeline' and 'deps' folders both need to be in your IDL path
  • You will also need to install NASA AstroLib ( and add it to the IDL path

Calling Sequence and Options

Currently, the pipeline runs only from its directory (will be changed in the future) because it uses relative path to access stored calibration data.

In order to run the pipeline, you will need to create configuration files (.txt), normally one file per a dithered pair of spectra stored in a directory created for a specific target/setup. The directory should not contain anything else. Configuration files for the MMIRS pipeline are FITS-header like text files, which contain paths to data and working directory, filenames for science and calibration frames, control variables, which define what steps of the reduction have to be executed along with various configuration parameters for every data reduction step. The configuration file format is described in the MMIRS pipeline paper ( and can be created automatically using Python scripts developed and maintained by the MMT staff member Chun Ly and available here (

Reducing one nodded pair

In order to reduce one nodded pair of MMIRS spectra (longslit or MOS) run


This routine does not accept any extra parameters / keywords, it is fully controlled by the 'config_file.txt' file itself

Reducing a full sequence of several nodded pairs

In order to reduce a set of nodded spectra and co-add the result with optional telluric correction, another wrapper called is used. The only required parameter is the parent directory containing several pipeline configuration files:


This call will execute reduce_mmirs on every file it finds inside the directory '/path/to/configs/' and co-add the resulting reduced spectra in a directory 'sum/' one level above the path of individually reduced pairs of spectra, e.g. if the W_DIR parameters in 'config_file_01.txt' and 'config_file_03.txt' point to '/mydata/mmirs/target_01/01/' and '/mydata/mmirs/target_01/03/' correspondingly, where results of data reduction for individual nodded pairs will be stored, then the co-added dataset will be stored in '/mydata/mmirs/target_01/sum/'

The run_pipeline procedure has a number of optional parameters:

  • /noreduce -- a keyword that tells the wrapper not to re-run data reduction for individual pairs but just to perform co-adding and telluric correction for already reduced data. This keyword is useful when one wants to change the alignment star used to adjust object positions or use an alternative telluric star, or disable Kelson style sky subtraction
  • num_tel -- a numeric parameter to specify an alternative telluric star. Defaults to num_tel=1, which means to use a list of telluric star files from the STAR01 parameter from the configuration file. If set to, e.g. 2, the STAR02 parameter will be used.
  • nmin and nmax -- numeric parameters to specify a subset of spectral pairs to reduce and/or co-add. Defaults to nmin=0 and nmax=n_elements(file_search(dir+'/*.txt'))-1
  • /nokelson -- a keyword that tells to use 'obj_diff_lin' rather than 'obj-sky_diff_lin' for co-adding, i.e. no Kelson like sky subtraction
  • box -- a numeric parameter specifying which alignment star to use for correcting shifts of the targets along the slit, defaults to box=0, i.e. the 1st box. Set to -1 to rely on dithering positions from the configuration files (DITHPOS). Can be set to an array in order to enable a more elaborated co-adding by trying to account for differential refraction -- use at your own risk.
  • telluric_dir_idx -- a numeric parameter which defines, where to look for a reduced telluric star and telluric correction function. Defaults to telluric_dir_idx=0, which tells it to look for a telluric star in the directory with the 1st reduced pair of nodded spectra. If no telluric star was observed or reduced in a given directory, no telluric correction will be performed.

Contents of the output data directory

The 'sum/' directory contains:

  1. Co-added, sky subtracted, rectified 2D spectra (indicated with "sum" in the filename) and their uncertainties (indicated with "err" in the filename) stored in the following FITS files:
  • Flat fielded in total counts but not flux calibrated

  • Corrected for telluric absorption and relatively flux calibrated


The 2D data here is stored in the first FITS extension, for commonality with multi-object mask reductions where data from each slitlet is stored in a separate FITS extension.

  1. Un-coadded, sky subtracted, 2D spectra and their uncertainties stored as FITS files, where the first FITS extension is a 3D data cube containing every individual dithered pair (offset to match the dithering position changes). The filenames are:
  • Flat fielded in total counts but not flux calibrated

  • Corrected for telluric absorption and relatively flux calibrated

  • A number of informational files are also included:

      exposure_table.fits - FITS table containing information about the 
        individual MMIRS exposures that went into the
        other data products in this directory.  It is a
        binary FITS table and has the following columns: 
      N_PAIR -- an ID of a dithered pair,
      N_EXP -- an ID of an exposure, 
      FILENAME -- an original filename without extension for the
        science exposure
      DATE_OBS -- the date and time of the observation (UTC),
      EXPTIME -- exposure time for a given observation in seconds,
      DITHPOS -- dithering position of a given observation in arcsec.
  • comb_2d_log.txt - An example parameter file used by the pipeline to reduce a single pair of MMIRS images.

  • correction_tel.fits - The telluric correction applied to corr files.

Every FITS file in this distribution directory contains the SOFTWARE keyword in the primary HDU that provides the pipeline version used to reduce this dataset. Should you have any question/feedback related to the data reduction, please include the pipeline version in the correspondance.