Spitzer Documentation & Tools
Spitzer Data Analysis Cookbook


Recipe 4. MOPEX: Mosaic IRAC Galactic FLS Data

Here we use one of several AORs which comprise the Galactic First Look Survey (GFLS;  http://irsa.ipac.caltech.edu/data/SPITZER/docs/spitzermission/observingprograms/firstlooksurvey/). This survey was taken in IRAC's high dynamic range (HDR) mode (see the IRAC Instrument Handbook for more information on this mode). This means the even (odd) numbered CBCD files will contain images taken with, in this case, 0.4 (10.4) second exposure times, or, equivalently, 0.6 (12) second frame times. We explain how to make a channel 3 (5.8 micron) mosaic from the longer frame times. In particular, we focus on the delta offset correction that must commonly be made for channel 3 data. We also describe which outlier rejection and image interpolation schemes are appropriate for low coverage data (in this case, 4 images per point on the sky).


You may also be interested in reading the IRAC COSMOS recipe (Recipe 3), which demonstrates how to reduce IRAC channel 1 data with medium coverage. The COSMOS recipe goes into greater detail about the different parameters that can be set, so will be helpful even to those users with low coverage data.

4.1  Requirements

You must have the Spitzer software package MOPEX installed in order to follow along with this recipe (http://irsa.ipac.caltech.edu/data/SPITZER/docs/dataanalysistools/tools/mopex/). This demonstration was originally tested using MOPEX 18.2. Use the Spitzer archive to download the BCD and post-BCD data for AOR 4960000 for this example. See Recipe 1 for instructions on downloading the data.

4.2  Correct BCDs for residual offset

What is the residual offset? Even in the absence of any photons, IRAC images will exhibit non-zero (usually positive) flux. The amount of flux varies across a given image. It also depends on the frame time and the Fowler number, as well as the history of readouts and array over the previous several hours. The effect is largest in the first frame of an observation, which is why the first frame is always taken in HDR mode, wherein a very short exposure (which you should definitely discard) is followed by a long one (which you may be able to use). However, the residual offset exists at a lower level for all frames, especially in IRAC channel 3, but it is substantial also in channels 4 and 1. Thus, you may need to correct for this residual offset. For more information, see the IRAC Instrument Handbook.


How can you tell if your data require a residual offset correction? In general, it is not a good idea to make a correction that you do not really need, as this may actually make your data worse by introducing noise. Therefore, it is important to determine whether your particular data set requires a residual offset correction. An easy way to make this assessment is to first try reducing your data without the correction, and look for problems.


A significant (uncorrected) residual offset in your data can result in a gradient across your overlap-corrected mosaic. This is because the residual offset tends to vary systematically across an individual CBCD. Therefore, when the overlap module tries to figure out a single offset for each CBCD in order to match overlapping regions, a systematic gradient across the whole mosaic results. Here is a cartoon illustrating the effect:

The top image above the arrow represents two overlapping CBCDs, each with its own residual offset gradient. The dotted rectangle highlights the overlapping region. The image below the arrow represents the mosaic made after applying an overlap correction. The overlap correction required a relative decrease in the flux in the right-hand CBCD in order to make the overlapping region the same in both CBCDs.


What would our example data set look like if we did not correct for residual offsets? We can take the ch 3 pipeline mosaic (PBCD file SPITZER_I3_4960000_0000_8_E8349728_maic.fits) or run our original downloaded CBCDs through the overlap pipeline, and sure enough, we see a strong gradient, justifying the need for a residual offset correction:

If you would like to reproduce the image above, follow the instructions in Section 3.6, but change the output directory to overlap_output (so you do not overwrite it later) and use the following files for your Image Stack File, your Sigma List File, and your DCE Status Mask List, respectively (do not forget to edit them with the path to the data on your computer):




How do I correct for residual offsets? To get rid of the artificial gradient seen above, we recommend creating a delta offset frame, subtracting it from each BCD, and using the results in all subsequent processing (i.e. MOPEX overlap and mosaic pipelines).


As described in the following list, there are several ways to create a delta offset frame. Regardless of which way you choose, for this example you should not use any of the even-numbered frames, which have short exposure times. Remember that we are making a mosaic of the long exposure times (header keyword HDRFRAME = long), so you must use a subset of the odd-numbered frames. Also keep in mind that MOPEX does not create residual offset frames. You must use the image manipulation software of your choice, e.g. IRAF, IDL.


  1. The simplest possible delta offset frame is a median of all of the input CBCDs. This requires all CBCDs to have nearly the same overall sky level. Also, this method will subtract the background as well as the residual offset.


  1. Another slightly more complicated option is to first subtract the median of each frame from itself. Then compute the delta residual offset as the stack median of the resulting frames. Finally, subtract this stack median from the original downloaded CBCDs. Using this method removes the slope associated with both the residual offset and the background. However, this method will not remove any constant offset due to the residual offset or the background.


  1. As mentioned above, the residual offset is a function of the time between subsequent frames. For instance, if you take two images in a row, the residual offset in the second frame will be larger if you are doing a repeat rather than dithering between frames. If you have enough frames, you can try making multiple delta offset frames (using either of the above procedures), one for each repeat. A simple IDL code (http://irsa.ipac.caltech.edu/data/SPITZER/docs/files/spitzer/repeat_delta_dark.pro) for doing this is available. An example of how to use the code on IRAC data is provided in the header of the IDL procedure.


In this example, we use the first method, as our frames have about the same background level; we are not interested in the background intensity; and we do not have any repeats. We encourage you to try the different methods to see the effect on your final mosaic. We gave the delta residual offset subtracted CBCDs the same names as the original CBCDs with an added do_ prefix, for "delta offset".

4.3  Set up files in preparation to run MOPEX

Before we can run MOPEX to compute the overlap correction and remosaic the data, we need to do a little preparation.


  • In the directory /where/you/unpacked_data/, make subdirectories cal/ and cdf/. The cal directory will hold all of our calibration files, and the cdf directory will hold the namelists which save our MOPEX parameters.



  • Download the pmask calibration files (http://irsa.ipac.caltech.edu/data/SPITZER/docs/irac/calibrationfiles/) to your cal/ directory. These files will be used to mask out bad pixels in the array, so that they are not included in your final mosaic. These pmasks are updated intermittently, on timescales of weeks to months, depending on how rapidly the bad pixels are seen to change.

4.4  Compute the overlap correction

The Overlap Pipeline removes any remaining offsets in CBCD background by calculating an additive correction for each cbcd image to bring them to a common background level. Follow these steps to run the overlap pipeline on the residual offset corrected CBCDs.


  1. Start up the MOPEX GUI.


  1. Open up a MOPEX Overlap Flow. Click on "File"-->"New Overlap Pipeline..."-->"Overlap, IRAC ch3"--"OK". You will see the previously empty MOPEX window fill up with the Overlap flow.


  1. Set parameters in MOPEX Overlap Flow.
    Below is the minimum set of parameters that should be set in running overlap. A full description of each of the parameters is provided in the MOPEX manual and is also discussed in the IRAC COSMOS Recipe (Recipe 3).

a.       Image Stack File should be the ch3_10.4_cbcd_offsetcorr.list file you downloaded and edited previously.

b.      Output Directory is your choice, but here we choose /where/you/unpacked_data/overlap_offsetcorr_output

c.       Optional Input & Mask Files-->Sigma List File should be the ch3_10.4_cbunc.list file you downloaded and edited previously.

d.      Optional Input & Mask Files-->DCE Status Mask List should be the ch3_10.4_bimsk.list file you downloaded and edited previously.

e.       Pmask FITS file - To decide which pmask to use, you must look at the date your CBCDs were observed. Looking at the DATE_OBS keyword in the fits header of one of the CBCD files, we find that these data were taken on December 6, 2003. Therefore, we should use the file /where/you/upacked_data/cal/mar04/mar04_ch3_bcd_pmask.fits.

f.          Click on the Quick Look Mosaic in MOPEX to add that module


  1. Save your Overlap Flow parameters. In the main MOPEX menu, choose "File"-->"Save 'untitled' As...". Then choose the directory /where/you/unpacked_data/cdf/overlap_offsetcorr.nl


  1. Run the Overlap Flow. Simply click on the green arrow at the top left of the MOPEX window. The GUI will keep you appraised of its progress.


The resulting mosaic produced by overlap can be found in /where/you/unpacked_data/overlap_offsetcorr_output/mosaic.fits.


It should look something like this:

Notice that there is no longer a systematic gradient across the field, as there was when we ran overlap on CBCDs that had not been corrected for the residual offset. The mosaic still has imperfections, but the overlap mosaic is not meant to be science-grade. It is merely meant to compute the offsets between CBCDs. We can see from this image that it has been successful. In the next step, we will make a science-grade mosaic.

4.5  Produce a Science Mosaic

Now that we have corrected the CBCDs for both the residual offset and mismatched backgrounds, the next step is to use the corrected CBCDs to produce a new mosaic.


1.      Start up the MOPEX GUI.


2.      Open up a Mosaic Pipeline. From the main menus, select File-->New Mosaic Pipeline-->Mosaic, IRAC ch3-->OK.


3.      Set Mosaic Parameters.

a.       For the image stack file, you should select the stack of overlap-corrected images. This will appear in the overlap output directory. In our case, this /where/you/unpacked_data/overlap_offsetcorr_output/Overlap_corr/overlapCorrectionList.txt

b.      For the output directory, choose /where/you/unpacked_data/mosaic_default_output.

c.       In "Optional Input & Mask Files"-->"Sigma List File", choose /where/you/upacked_data/ch3_10.4_cbunc.list.

d.      In "Optional Input & Mask Files"-->"DCE Status Mask List", choose /where/you/upacked_data/ch3_10.4_bimsk.list.

e.       In "Optional Input & Mask Files"-->"Pmask FITS File", choose /where/you/upacked_data/cal/mar04/mar04_ch3_bcd_pmask.fits.

f.           The most important parameters in the rest of the flow are those that control outlier rejection and image interpolation.


As described in the "Basic Concepts: Outlier Detection" section of the online MOPEX manual, MOPEX has four algorithms for identifying bad pixels: single frame, multiframe temporal, dual outlier, and box outlier. The default IRAC namelist uses dual outlier. For low coverage data like ours (the AOR we have chosen has a coverage of 4), we recommend using either dual outlier or box outlier. Since both methods tend to produce similar results, we will remove the "Mosaic Outlier" module and in the Mosaic R Mask module will uncheck the "Use Outlier for Rmask" option.


As described in the MOPEX manual, four interpolation schemes are implemented: Default, Drizzle, Grid and Cubic. General guidelines for choosing the interpolation scheme appropriate for your data set are provided in the Helpdesk knowledgebase:  "How do I decide which interpolation method in MOPEX to use to create my science mosaic?". A rule of thumb is that if you have a coverage of 10 or less (as we do), you will probably want to use the default interpolation scheme.


If you have higher coverage data than the low coverage data we are analyzing here, you may wish to use a different outlier rejection scheme and a different interpolation method. For a medium coverage example, see the IRAC COSMOS recipe (Recipe 3).


4.      Run the Mosaic Pipeline. Simply click on the green arrow.


5.      Examine the results. After running the mosaic pipeline, you can find the output in


6.      The image looks fairly good. Here is a zoomed-in section in the middle of the image, demonstrating that the outlier rejection worked properly: