Spitzer Documentation & Tools
Spitzer Data Analysis Cookbook

 

Recipe 5.   MOPEX: IRAC Mosaic of the galaxy NGC1097

This example demonstrates how to use MOPEX to create mosaics of a large field of view around the SINGS Legacy Science Program’s galaxy NGC 1097 in IRAC channels 1 through 4. We pay special attention to choosing the appropriate parameters in the MOPEX namelist files, and discuss the effect of various choices of several of these parameters. The final products include the mosaic image, the mosaic uncertainty image, and the mosaic coverage map. Note that this example uses the command line way of running the mosaicer instead of the GUI that was used in previous sections.

5.1  Requirements

You must have MOPEX installed in order to follow along with this recipe (http://irsa.ipac.caltech.edu/data/SPITZER/docs/dataanalysistools/tools/mopex).

You will need to use these namelists:

5.2  Downloading the example data set

Download the BCD and calibration data for channels 1 through 4 from AORs 5515776 and 5516032. Put all the data into directories of your choice - you can choose to rearrange the directories that the Spitzer archive sets up for you, for example, by combining all of the BCD data from two AORs into one directory.

 

You need the input CBCD files, listed in a file (here called image_stack_all.txt, one file per line). Only files with odd expids, (e.g., only the 30 sec frames in the HDR observations), should be included. Here is a nifty unix trick to just get the odd- or even-numbered files in a file, one file per line (assuming you are currently in the directory with all the CBCDs):

unix% ls *cbcd.fits | awk ‘NR % 2 == 0 { print }’ > oddlist.txt

unix% ls *cbcd.fits | awk ‘NR % 2 == 1 { print }’ > evenlist.txt

You also need a similar list of the corresponding uncertainty files (*cbunc.fits files) and imask files (*bimsk.fits files). You can also simply type “ls *cbcd.fits > filelist.txt” and edit out the short exposures, (e.g., keep SPITZER_I1_5515776_0001_0000_4_cbcd.fits but delete SPITZER_I1_5515776_0000_0000_4_cbcd.fits, keep SPITZER_I1_5515776_0003_0000_4_cbcd.fits but delete SPITZER_I1_5515776_0002_0000_4_cbcd.fits etc.). Do the same for the uncertainty and imask files.

 

Do not forget to also download the IRAC Pmask files (http://irsa.ipac.caltech.edu/data/SPITZER/docs/irac/calibrationfiles/).

 

There are several artifact correction software packages at

 

http://irsa.ipac.caltech.edu/data/SPITZER/docs/dataanalysistools/tools/contributed/irac/

 

that you can use to get rid of any remaining artifacts in the CBCD images before making the mosaics.

5.3  Perform Overlap Correction

It is recommended that you run the frames through an overlap correction module before proceeding with mosaicking.

unix% overlap.pl -n ngc1097ch1overlap.nl

unix% overlap.pl -n ngc1097ch2overlap.nl

unix% overlap.pl -n ngc1097ch3overlap.nl

unix% overlap.pl -n ngc1097ch4overlap.nl

 

The links to the namelists to be used (remember to change the paths to input and output files to correspond to your directories) are given above in the "Requirements" section. Make sure that you have specified the input CBCDs in the file pointed to by the IMAGE_STACK_FILE_NAME parameter in the namelist file (including their path on your disk), and similarly the SIGMALIST_FILE_NAME and DCE_STATUS_MASK_LIST should point to files that give the full path and filenames to your uncertainty and imask images, respectively (one path/filename per line). For overlap.pl, you also need to give the OVERLAP_CORR_DIR name in the namelist file. This is the name of the directory, under your specified OUTPUT_DIR, where the final, overlap-corrected CBCDs will be written to. Pay attention to specifying the parameters for the overlap correction:

&COMPUTEOVRLAPCORRIN

  TOP_THRESHOLD = 3,

  BOTTOM_THRESHOLD = 3,

  MIN_IMG_NUM = 4,

&END

 

These parameters are used in the outlier rejection to set the upper and lower limits (multiples of sigmas), and the minimum number of images needed to perform the overlap correction. Also remember to set COMPUTE_OVERLAP_CORRECTION = 1 and APPLY_OVERLAP_CORRECTION = 1 in the namelist file. Finally there is a parameter MASK_BRIGHT. You can set this to 1 to use masks created by the ‘‘detect'' module. In this example, the central parts of the galaxy are very bright, and adjusting the parameters to detect less bright objects only did not help to avoid the masking of the brightest galaxy parts, and therefore the MASK_BRIGHT parameter is set to 0. You can experiment by running the overlap correction module with MASK_BRIGHT set to 1. In addition, the first frame of an AOR often has a bias offset which is very different from the rest of the frames in the AOR. In this example, we leave the first frames (EXPID=1) in channel 3 out from both AORs in generating our overlap-corrected frames and mosaics. Most of the rest of the parameters specified in the namelist of the overlap correction module are discussed below in the context of generating the mosaics. Remember that your IMAGE_STACK_FILE_NAME when making the mosaics below must point to a file that specifies the overlap-corrected filenames (and their path on your disk; filenames starting with ‘‘correct_SPITZER'), not the original CBCDs. Also note that the option MOSAIC_CORRECTED_IMAGES will only give a quick and dirty mosaic to see whether the overlap correction worked okay. A thorough mosaicking with the mosaic.pl script, as described below, is necessary to produce a high quality mosaic.

5.4  Make the mosaic


Generate the fiducial frame.

This creates the file FIF.tbl that gives the header keywords that specify the orientation, size, etc. of the final mosaic (CRVAL,CRPIX,CDELT,NAXIS). It also creates the file header_list.tbl that lists the projected CRVAL, CRPIX etc. values for each input BCD image. Specify the items in the left-hand column below (explanations are on the right) in the namelist file:

 

run_fiducial_image_frame = 1

 

Edge_pagged = 100                    Add 100 arseconds of NaN-valued pixels on each edge.

 

CROTA2 = A                             Orient the final mosaic. Use A for average CROTA values of the input CBCDs, 0 (‘‘zero”) for north up orientation. If not specified, an optimal orientation is used that minimizes the area covered by the mosaic.

 

MOSAIC_PIXEL_SIZE_X =

-0.00016667

MOSAIC_PIXEL_SIZE_Y =

-0.00016667                                      Set the pixel size of the mosaic.

 

Subtract the background in the input images.

Background subtraction is performed by subtracting median-filtered values from pixels. Background subtraction needs to be run only if single or dual outlier rejection is to be run. You need to specify the following in the namelist:

run_medfilter = 1

 

&MEDFILTER

Window_X = 21,

Window_Y = 21,

N_Outliers_Per_Window = 100,

Use_Sbkg_for_Med = 0,

&END

 

Trying a larger Window size (and larger outlier number) does not produce as good results. Trying a smaller Window size did not remove the background.

http://ssc.spitzer.caltech.edu/postbcd/cookbooks/images/ch1bcd.jpghttp://ssc.spitzer.caltech.edu/postbcd/cookbooks/images/medfilterch1.jpg

Ch 1 BCD (left) and Ch 1 image after background subtraction (right).

 

Interpolate the output pixels based on input pixel values.

The following parameters need to be set in the namelist:

run_mosaic_interp = 1

 

&MOSAICINTIN

INTERP_METHOD = 1,

FINERES = 0,

&END

 

It is also possible to do drizzling (INTERP_METHOD = 2) or bicubic interpolation (INTERP_METHOD = 4). For drizzle, specify drizzle factor (DRIZ_FAC < 1). In channels 3 and 4 a better mosaic results if the FINERES parameter is not used, or if you use drizzle or bicubic interpolation.

http://ssc.spitzer.caltech.edu/postbcd/cookbooks/images/interp.jpg

Interpolation using the default option (left) or drizzling (right).

 

 

Outlier rejection

For dual outlier (spatial and temporal) rejection

run_medfilter = 1

run_detect_outlier = 1

run_mosaic_proj = 1

run_mosaic_dual_outlier = 1

run_level = 1

USE_DUAL_OUTLIER_FOR_RMASK = 1

 

For run_detect_outlier, the parameter list is DETECT:

&DETECT

Detection_Max_Area = 100,

Detection_Min_Area = 0,

Detection_Threshold = 4,

&END

 

Try playing with the threshold parameter. Increasing it causes a lot of cosmic rays to not be detected. Lowering it causes too many detections. Leave it at 4.

 

For dual outlier detection, the parameters are

&MOSAICDUALOUTLIERIN

MAX_OUTL_IMAGE = 2,

MAX_OUTL_FRAC = 0.5,

TILE_XSIZ = 500,

TILE_YSIZ = 500,

&END

 

Play with MAX_OUTL_FRAC. Increase it to 0.95. You will see a lot of non-radhit detections. If you lower it to 0.2, very few detections are seen. The best value seems to be 0.5. Tile size parameters can be played with if your computer has problems with insufficient memory.

 

For run_level the parameter is THRESHOLD_RATIO. Use 0.5 to have all the pixels within a cluster to have the same sign (see mosaicker user's guide for more info).

 

For box outlier (spatial and temporal) rejection add the following lines to your namelist file:

run_mosaic_box_outlier = 1

USE_BOX_OUTLIER_FOR_RMASK = 1

 

The parameters to be added to the namelist file are

 

&MOSAICBOXOUTLIERIN

BOX_X = 3,

BOX_Y = 3,

BOX_MEDIAN_BIAS = 1,

TILE_XSIZ = 500,

TILE_YSIZ = 500,

&END

 

Trying a box size of 5 to enlarge the spatial comparison area did not provide a better outlier rejection, so we leave the box size at 3.

 

Create rmask file

Add the following to your namelist file:

run_mosaic_covg = 1

run_mosaic_rmask = 1

 

&MOSAICRMASKIN

BOTTOM_THRESHOLD = 3,

TOP_THRESHOLD = 3,

BOX_BOTTOM_THRESHOLD = 6.0,

BOX_TOP_THRESHOLD = 6.0,

BOX_MIN_COVERAGE = 2,

MIN_COVERAGE = 4,

MAX_COVERAGE = 100,

RM_THRESH = 0.5,

REFINE_OUTLIER = 1,

REFINE_OUTLIER_THRESH = 10

&END

 

The dual outlier flagged pixels are used in the Rmask if an output pixel has been covered fewer than by MAX_COVERAGE input images. BOTTOM and TOP thresholds are not used in our example (they are only used for the temporal outlier method). The refinement parameters are not relevant for our example either. Decreasing the box thresholds to 3 produces too many outliers that do not correspond to real cosmic rays.

http://ssc.spitzer.caltech.edu/postbcd/cookbooks/images/finalmos.jpg

Final mosaic after cosmic ray rejection (left), one of the original CBCDs (right).

 

 

Reinterpolation and coadding

Add the following to your namelist file:

run_mosaic_reinterp = 1

run_mosaic_coadder = 1

run_mosaic_combiner = 1

 

&MOSAICCOADDIN

TILEMAX_X = 1000,

TILEMAX_Y = 1000,

&END

 

Finally, run the mosaicer with

 

unix% mosaic.pl –n ngc1097ch1mos.nl

 

If you want to mosaic background-subtracted BCDs, set RUN_MOSAIC_MEDFILTER = 1

 

http://ssc.spitzer.caltech.edu/postbcd/cookbooks/images/pipelinemosch2.jpghttp://ssc.spitzer.caltech.edu/postbcd/cookbooks/images/mosallch2.jpg

Pipeline-created mosaic in channel 2 (left), custom-tailored mosaic (made in this recipe; right).

 

CAVEAT EMPTOR: More optimally constructed mosaics may possibly be constructed by using a different set of input parameters in the namelists. Use your own judgment and common sense.