This file summarizes several instrument specific settings that are related to the Keck/MOSFIRE spectrograph.

PypeIt File

Here is some advice on how to setup your PypeIt Reduction File. First, run:

pypeit_setup -r absolute_path -s keck_mosfire -b -c A

where -b indicates that the data use sky subtraction and the calib, comb_id, and bkg_id columns are added to the Data Block. See pypeit_setup and A-B image differencing for the syntax used for the data in these columns and how PypeIt uses them.

Here is an example of the Data Block of the PypeIt file:

# Read in the data
data read
 path raw/
          filename |                 frametype |           ra |         dec |          target |       dispname |           decker | binning |            mjd |    airmass | exptime | filter1 | lampstat01 |  dithpat | dithpos | dithoff | frameno | calib | comb_id | bkg_id
 m120910_0410.fits | pixelflat,illumflat,trace |          7.8 |        45.0 |     Dome Phlatz | H-spectroscopy | MOSFIRE_DRP_MASK |     1,1 |  56180.6945327 | 1.41291034 | 14.5479 |       H |         on |    Stare |  object |     0.0 |     410 |     3 |      -1 |     -1
 m120910_0411.fits | pixelflat,illumflat,trace |          7.8 |        45.0 |     Dome Phlatz | H-spectroscopy | MOSFIRE_DRP_MASK |     1,1 |  56180.6948371 | 1.41291034 | 14.5479 |       H |         on |    Stare |  object |     0.0 |     411 |     3 |      -1 |     -1
 m120910_0412.fits | pixelflat,illumflat,trace |          7.8 |        45.0 |     Dome Phlatz | H-spectroscopy | MOSFIRE_DRP_MASK |     1,1 | 56180.69517159 | 1.41291034 | 14.5479 |       H |         on |    Stare |  object |     0.0 |     412 |     3 |      -1 |     -1
 m120910_0175.fits |          arc,science,tilt | 344.98215835 | 33.00561651 | MOSFIRE_DRP_MAS | H-spectroscopy | MOSFIRE_DRP_MASK |     1,1 | 56180.53134073 | 1.27528573 | 29.0958 |       H |        off | Mask Nod |       A |     2.5 |     175 |     3 |      16 |     17
 m120910_0176.fits |          arc,science,tilt | 344.98372629 | 33.00516929 | MOSFIRE_DRP_MAS | H-spectroscopy | MOSFIRE_DRP_MASK |     1,1 | 56180.53198772 | 1.27866912 | 29.0958 |       H |        off | Mask Nod |       B |    -2.5 |     176 |     3 |      17 |     16

data end

frametype is automatically assigned to each frame using the values of various header keywords, see Automated typing of Keck/MOSFIRE frames. The dither pattern, position and offset associated to each fame is reported here. PypeIt tries to automatically set the calib, comb_id, and bkg_id using the dither information (see Automated sorting of Keck/MOSFIRE frames by instrument configuration); however, the user can edit these columns according to the preferred reduction.


Edge Tracing


PypeIt is able to match the traced slit to the slit-mask design information contained as metadata in the MOSFIRE observations. This functionality at the moment is implemented only for these Slit-mask design Spectrographs and is switched on by setting use_maskdesign flag in EdgeTracePar Keywords to True. This is, already, the default for MOSFIRE, except when the LONGSLIT mask is used.

PypeIt also assigns to each extracted 1D spectrum the corresponding RA, Dec and object name information from the slit-mask design, and forces the extraction of undetected object at the location expected from the slit-mask design. This functionality is also the default for MOSFIRE and can be controlled through the flags assign_obj and extract_missing_objs in SlitMaskPar Keywords. See Additional Reading .

By default, PypeIt uses the dither offset recorded in the header of the science frames to find the objects in the slits. However, a better approach would be to let PypeIt compute the offset using a bright object in one of the slits in the slit-mask. To do so, the user should provide in the PypeIt Reduction File the maskdef_id (corresponding to “Slit_Number” in the MOSFIRE slit-mask design) of the slit containing the bright object. Here is an example:

        use_dither_offset = False
        bright_maskdef_id = 1

Note that maskdef_id is an ID associated to each slit in the slit-mask design, therefore it is instrument specific, and it differs from SPAT_ID, which is generated by PypeIt and assigned to each slit.

When the extraction of undetected objects is performed, the user can input a value of the FWHM for the optimal extraction by setting the parameter missing_objs_fwhm in SlitMaskPar Keywords. If missing_objs_fwhm = None (which is the default), PypeIt will use the median FWHM of all the detected objects.


This a custom CSU mask with two slits that are offset from the field center (plus a center alignment box), which allows MOSFIRE observers to acquire standard star spectra that cover the entire accessible wavelength range. Besides these two slits and the central alignment box, the rest of the mask is filled with random slits. Often, the calibration frames don’t have the same number of random slits as in the science frame, causing bad calibration or the code to crash.

PypeIt is able to exclude those random slits from the slit tracing process. The parameter that controls the exclusion of detector regions from the slit edge tracing is exclude_regions in EdgeTracePar Keywords. By default, PypeIt excludes the regions where the random slits are for a long2pos mask, but if the users want to modify that, they can do it in the PypeIt Reduction File in the following way:

        exclude_regions = 1:0:880,1:1190:2040

This example would select two regions in detector 1 between pixels 0 and 880 and between 1190 and 2040 in the x direction of the detector.

Moreover, similarly to the multi-slits mask, PypeIt by default will match the traced slit to the slit-mask design information contained as metadata in the MOSFIRE observations, and assign to each extracted 1D spectrum the corresponding RA, Dec and object name information from the slit-mask design. However, forcing the extraction of undetected object is not performed by default. Note that the RA and Dec recorded in the MOSFIRE observations of long2pos masks are mock numbers, therefore the users should not use them.


Similar to long2pos, LONGSLIT masks with a single slit that is shorter than the length of the detector will have random slits that fill the mask. By default, PypeIt is capable of excluding from the edge tracing process the regions where the random slits are for a LONGSLIT mask. However, if the automatic selection of the regions to exclude does not look right, the users can still modify that adding the exclude_regions parameter in the PypeIt Reduction File (as shown above), making sure that the flag bound_detector is set to True.

Flat Fielding

The MOSFIRE calibration GUI provides the option to take flats with the lamps off. This is the default in the GUI only for the K-band, but we recommend taking these lampoffflats for all MOSFIRE spectroscopic observations. The purpose of the lampoffflats is to remove the increase and/or variation in zero level caused by persistence from the high counts in the flats and/or thermal emission from the telescope/dome (in the K-band). PypeIt is able to recognize flat frames taken with the lamps off, and it will assign them the lampoffflats frame type. Whenever lampoffflats frames are identified in the PypeIt file, PypeIt will subtract them from the frames taken with the lamps on before creating the Edges and Flat frames. The user is responsible for ensuring that the lampoffflats frames in the PypeIt file have the same exposure times as the trace, pixelflat and illumflat frames.


The lampoffflats frames are always subtracted from the trace, pixelflat and illumflat frames. The default mode for MOSFIRE is to use the spectroscopic domeflats for trace, pixelflat and illumflat. If the user wants to use other images (e.g. spectroscopic twilight flats) for the illumflat, then the current implementation would likely fail. If distinct frames are desired for trace, pixelflat and illumflat, we currently advise users to simply not use the lampoffflats.

Wavelength calibration

As default, the wavelength calibration is performed using the OH lines in science frames and the Full Template algorithm. The templates are created in the same way as done for Keck/DEIMOS (see DEIMOS Wavelength Calibration) and kept in the data/arc_lines/reid_arxiv directory. There are five templates, one per each of the most commonly used MOSFIRE filters:

  • keck_mosfire_OH_Y.fits

  • keck_mosfire_OH_J.fits

  • keck_mosfire_OH_J2.fits

  • keck_mosfire_OH_H.fits

  • keck_mosfire_OH_K.fits

and PypeIt will automatically choose the right template according to the specific dataset.

When long2pos_specphot mask is used, the wavelength calibration using OH lines will not be successful. Therefore, five additional templates using arcs lines (Ar, Ne) are also available:

  • keck_mosfire_arcs_Y.fits

  • keck_mosfire_arcs_J.fits

  • keck_mosfire_arcs_J2.fits

  • keck_mosfire_arcs_H.fits

  • keck_mosfire_arcs_K.fits

PypeIt will use as default the arcs template if the mask used for the science/standard frames is long2pos_specphot. Arc frames must be provided.

If there are other cases in which the user prefers to perform the wavelength calibration using the arc frames, instead of using the OH lines, this can be done by adding in the PypeIt Reduction File:

        sigdetect = 5
        method = full_template
        reid_arxiv = keck_mosfire_arcs_Y.fits
        lamps = Ar_IR_MOSFIRE,Ne_IR_MOSFIRE


A standard run of PypeIt, i.e., run_pypeit, produces 2 reduced spectra per each pair of science-background frames. Assuming that the science frame is taken at the dither position “A” and the background frame is taken at the the dither position “B”, the 2 output spectra would be A-B and B-A. To combine these 2 output spectra and obtain a 2D spectrum that shows negative-positive-negative traces, the user can run pypeit_coadd_2dspec, which will also extract the combined 1D spectra. See Coadd 2D Spectra and Coadd2D HOWTO.

Note that, during run_pypeit, science frames can be combined (see Combining Science Exposures and A-B image differencing), but in this case no optimal weighting and drift correction are applied.

long2pos mask

Observations taken with a long2pos mask are generally used for flux calibration. To maximize the wavelength coverage of the observed standard star, 2 spectra are taken in 2 different wavelength regions. PypeIt standard reduction and the subsequent run of pypeit_coadd_2dspec for data taken with a long2pos mask will not combine the 2 wavelength regions, but the user can run pypeit_coadd_1dspec script to combine the 2 output 1D spectra into a single one.

Additional Reading

Here are additional docs related to Keck/MOSFIRE. Note all of them are related to the development of PypeIt for use with MOSFIRE data: