SSC Home Page

Mosaicking of the SINGS Galaxy NGC 1097:
IRAC, channels 1-4

Requirements:

Outline of the demo:

This example demonstrates how to run the Spitzer mosaicker to create mosaics of a large field of view around the SINGS galaxy NGC 1097 in IRAC channels 1 through 4. We pay special attention to choosing the appropriate parameters in the mosaicker namelist files, and discuss the effect of various choices of several of these parameters. For channels 3 and 4, we show how to run the overlap correction script before mosaicking. The final products include the mosaic image, the mosaic uncertainty image and the mosaic coverage map.

Here is a summary with links to all the examples that use NGC 1097 data, including a detailed step-by-step presentation of mosaicking in pdf format.

In general, it is a good idea to run your data through the IRAC artifact mitigation software before mosaicking. Your input would then be the overlap and artifact corrected BCDs (over_cor_sfx*bcd.fits), updated uncertainty images (cor_sfx*bunc.fits) and the original imask files. However, in this example we will mosaic the pipeline-produced BCDs which in this case are relatively artifact-free.

You will need to run these scripts:

You will need to use these namelists:

Step by Step Guide

In the MOPEX namelist (see sample namelists above), you have the option to run all the modules at once (set run* = 1) or select some/one module (set all others run* = 0). If you want to see what happens in each step, then you should set all the run* = 0, except the ones that are discussed currently or have been set before.

  1. Download all the relevant data (see example). You should be sure to download two AORs, reqkeys 5515776 and 5516032. You should download the BCD data and the calibration data for channels 1 through 4. Put all the data into directories of your choice -- you can choose to rearrange the directories that Leopard sets up for you, for example, by combining all of the BCD data from two AORs into one directory.

    You need the input BCD 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 BCDs):

     unix% ls *bcd.fits | awk 'BEGIN{i=0}{if (i%2) print $0; i++}' > oddlist.txt
     unix% ls *bcd.fits | awk 'BEGIN{i=1}{if (i%2) print $0; i++}' > evenlist.txt
    
    You also need a similar list of the corresponding uncertainty files (*bunc.fits files) and imask files (*bimsk.fits files). You can also simply do "ls *bcd.fits > filelist.fits" and edit out the short exposures, (e.g., keep SPITZER_i1_5515776_0001_0000_1_bcd.fits but delete SPITZER_I1_5515776_0000_0000_4_bcd.fits, keep SPITZER_I1_5515776_0003_0000_4_bcd.fits but delete SPITZER_I1_5515776_0002_0000_4_bcd.fits etc. Same for the uncertainty and imask files.

    Don't forget to also download the IRAC Pmask files.

  2. Specifically for channels 3 and 4, it is strongly recommended that you run the frames through an overlap correction module before proceeding with mosaicking.

     unix% overlap.pl -n ngc1097ch3overlap.nl 
     unix% overlap.pl -n ngc1097ch4overlap.nl 

    The links to namelists to be used (remember to change the paths to input and output files to correspond to your directories) are given above. Make sure that you have specified the input BCDs in the file pointed to by 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 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 BCDs will be written to. Pay attention to specifying the parameters for 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 namefiles of the overlap correction module are discussed below in the context of generating the mosaics below. Remember that your IMAGE_STACK_FILE_NAME when making the mosaics for channels 3 & 4 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 BCDs (for channels 1 & 2 it is ok to use the BCDs as input files). Also note that the option mosaic_corrected_images will only give a quick and dirty mosaic to see whether the overlap correction worked ok. A thorough mosaicking with the mosaic.pl script, as described below, is necessary to produce a high quality mosaic.

  3. The next step is to 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 following in the namelist file:

    run_fiducial_image_frame = 1

    Edge_padding = 100 (add 100 arcsec of NaN-valued pixels on each edge)

    CROTA2 = A (orientation of the final mosaic, use A for average CROTA2 value of the input BCDs, 0 ("zero") for north up orientation). If not specified, an optimal orientation is used that minimizes the area covered by the mosaic.

    MOSAIC_PIXEL_RATIO_X =1, MOSAIC_PIXEL_RATIO_Y = 1 (mosaic has the same pixel size as the input BCDs). To get equal pixel sizes in the final mosaic, use MOSAIC_PIXEL_SIZE_X, MOSAIC_PIXEL_SIZE_Y instead (in degrees).

    Run the mosaicker:

     unix% mosaic.pl -n ngc1097ch1mos.nl 

  4. 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:

    run_medfilter = 1

    &MEDFILTER
    Window_X = 21,
    Window_Y = 21,
    N_Outliers_Per_Window = 100,
    &END

     unix% mosaic.pl -n ngc1097ch1mos.nl 

    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.


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

  5. Next step is to interpolate the output pixels based on input pixel values.

    The following parameters need to be set:

    run_mosaic_interp = 1

    &MOSAICINTIN
    INTERP_METHOD = 1,
    FINERES = 4,
    &END

     unix% mosaic.pl -n ngc1097ch1mos.nl 

    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. Also try setting MOSAIC_PIXEL_RATIO_X, MOSAIC_PIXEL_RATIO_Y to 2 and compare to what you get by setting the pixel ratios to 1.


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

  6. Next step is 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
    run_mosaic_outlier = 1
    USE_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 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). To run multiframe outlier rejection, the parameter list is

    &MOSAICOUTLIERIN
    THRESH_OPTION = 1,
    MIN_PIX_NUM = 3,
    TILE_XSIZ = 500,
    TILE_YSIZ = 500,
    &END

    THRESH_OPTION = 1 is now preferred (see mosaicker user's guide for more information). In case of low coverage, uncertainty images are used for sigma estimation if coverage is less than MIN_PIX_NUM.

     unix% mosaic.pl -n ngc1097ch1mos.nl 
  7. Next step is to create rmask file.

    run_mosaic_covg = 1
    run_mosaic_rmask = 1

    &MOSAICRMASKIN
    BOTTOM_THRESHOLD = 3,
    TOP_THRESHOLD = 3,
    MIN_COVERAGE = 4,
    MAX_COVERAGE = 100,
    RM_THRESH = 0.5,
    REFINE_OUTLIER = 1,
    REFINE_OUTLIER_THRESH = 10
    &END

    Both dual and multiframe outlier are run between MIN_COVERAGE to MAX_COVERAGE. Below MIN_COVERAGE only dual outlier detection is run. RM_THRESH needs to be changed if mosaic has a different pixel size from the BCDs. BOTTOM and TOP thresholds allow the projection of outlier pixels only if they are a certain number of sigmas above or below mean. The refinement allows pixels inside real point sources not to be marked as outliers unless their deviation is very high.


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

  8. Final step of reinterpolation and coadding.

    run_mosaic_reinterp = 1
    run_mosaic_coadder = 1
    run_mosaic_combiner = 1

    Note that for most accurate photometry you should not use the uncertainty images as weights when performing the coaddition (otherwise the point sources in the resulting mosaic are likely to have flux values that are too low, due to the weigthing by the inverse squared of the sigma values which themselves are essentially the square root of the pixel flux in most cases, following Poisson statistics). So set

    sigma_weighted_coadd = 0

    which is also the default in MOPEX.

    &MOSAICCOADDIN
    TILEMAX_X = 1000,
    TILEMAX_Y = 1000,
    &END

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


    Pipeline-created mosaic in channel 2 (left), custom-tailored mosaic (made in this demo; 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 judgement and common sense.

Return to the Data Analysis Demos main page.