Montage Montage is an astronomical image toolkit with components for reprojection, background matching, coaddition and visualization of FITS files. It can be used as a set of command-line tools (Linux, OS X and Windows), C library calls (Linux and OS X) and as Python binary extension modules.

The Montage source is written in ANSI-C and code can be downloaded from GitHub ( https://github.com/Caltech-IPAC/Montage ). The Python package can be installed from PyPI ("</i>pip install MontagePy"). The package has no external dependencies. See http://montage.ipac.caltech.edu/ for details on the design and applications of Montage.

MontagePy.main modules: mDiff

The Montage modules are generally used as steps in a workflow to create a mosaic of a set of input images. These steps are: determine the geometry of the mosaic on the sky, reproject the images to a common frame and spatial sampling; rectify the backgrounds to a common level, and coadd the images into a mosaic. This page illustrates the use of one Montage module, mDiffi, which computes the difference between two images.

Visit Building a Mosaic with Montage to see how mDiff is used as part of a workflow to creage a mosaic (or the one shot version if you just want to see the commands). See the complete list of Montage Notebooks here.

In [1]:
from MontagePy.main import mDiff, mViewer

Help on built-in function mDiff in module MontagePy.main:

    mDiff subtracts one image from another (both already in the same projection).
    input_file1 : str
        First input file for differencing.
    input_file2 : str
        Second input file for differencing.  Files have to already have the same projection.
    output_file : str
        Output difference image.
    template_file : str
        FITS header file used to define the desired output.
    noAreas : bool, optional
        Do not look for or create area images as part of the differencing.
    factor : float, optional
        Optional scale factor to apply to the second image before subtracting.
    debug : int, optional
        Debugging output level.
    status : int
        Return status (0: OK, 1:ERROR).
    msg : str
        Return message (for errors).
    time : float
        Total processing time (sec).
    min_pixel : float
        Smallest pixel value in either input.
    max_pixel : float
        Largest pixel value in either input.
    min_diff : float
        Smallest difference pixel (absolute).
    max_diff : float
        Largest difference pixel (absolute).

mDiff Example

Here, two Spitzer Space Telescope IRAC images have been tranformed to a common projection (using mProject). They have similar but not identical sky coverage and originally had slightly different rotations.

mDiff gives us the difference image of the above two. In Montage, this difference is primarily used to determine background offsets by fitting the difference with a plane. Below we stretch the difference to show the noise level and illustrate any residual effects of sky structure. Most noticeble are the bright stars in the lower left and the brightest areas in the galaxies, particularly the center of M51b. However, these are not much brighter than the noise and instrumental data collection effects, so fitting the difference with a plane (mFitplane) gives an reasonable measure of the image background difference, especially if the larger excursions from the plane are excluded in the fit.

In [2]:
rtn = mDiff('IRAC/projected/hdu0_SPITZER_I2_5504000_0000_6_E8758134_maic.fits', 
{'status': '0', 'time': 1.0, 'min_pixel': -0.33841609954833984, 'max_pixel': 269.2658386230469, 'min_diff': 1.4901161193847656e-08, 'max_diff': 142.27021026611328}

  The difference image looks like this:

In [3]:
from IPython.display import Image

rtn = mViewer("-ct 1 -gray work/IRAC/irac_diff.fits \
               -2s max gaussian-log -out work/IRAC/irac_diff.png",
              "", mode=2)