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: mProjectQL

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, mProjectQL, which is one of the modules used to reproject images.

Visit Building a Mosaic with Montage to see how mProjectQL 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 mProjectQL, mViewer

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

    mProjectQL reprojects a single image to the scale defined in a FITS header template file. The program produces a pair of images: the reprojected image and (optionally) an 'area' image consisting of the fraction input pixel sky area that went into each output pixel. This 'quick-look' version (see mProject and mProjectPP for other algorithms) interpolates the input pixels to find an approximate value to us for the output.
    input_file : str
        FITS file to reproject.
    output_file : str
        Reprojected FITS file.
    template_file : str
        FITS header file used to define the desired output.
    hdu : int, optional
        Optional HDU offset for input file.
    interp : int, optional
        Flux interpolation mode: 0 (nearest neighbor), 1 (Lanczos).
    weight_file : str, optional
        Optional pixel weight FITS file (must match input).
    fixedWeight : float, optional
        A weight value used for all pixels.
    threshold : float, optional
        Pixels with weights below this level treated as weight 0.
    borderstr : str, optional
        Single border width number or pixel polygon pair list for masking.
    fluxScale : float, optional
        Scale factor applied to all pixels.
    expand : bool, optional
        Expand output image area to include all of the input pixels.
    fullRegion : bool, optional
        Do not 'shrink-wrap' output area to non-blank pixels.
    noAreas : bool, optional
        Don't generate area image.
    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).

mProjectQL Example

mProjectQL is one of four modules focused on the task of reprojecting an astronomical image. It is by far the fastest of the reprojection options but is not strictly flux conserving (the "QL" stands for "quick look"). The algorithm does not calculate exact pixel overlaps but instead is base on the reprojected locatons of a set of sample points within each pixel.

In spite of this, the algorithm produces output that is usually more than adequate for science analysis, with fluxes indistinguishable from mProject or mProjectPP. It is usually best to start with mProjectQL and analyze the result to determine whether it is accurate enough for your needs.

mProjectQL has a number of extra controls for things like excluding a border (image borders often have bad pixels). But the basic inputs are a FITS image and a FITS header describing the output image we want. In all cases, the only output is a FITS image with the data from the input resampled to the output header pixel space.

The input FITS header (actually an ASCII file that looks like a FITS header but with newlines and unpadded line lengths) can be produced in a number of ways. There are Montage tools to take an image list (or point source list) and determine a bounding box (mMakeHdr) or just a location and size (mHdr). You can also pull the header off another file (mGetHdr) if you want to build a matching mosaic from other data. Or you can just create the output header by hand (e.g., a simple all-sky Aitoff projection).

Here we have pulled the header from the input image and edited it by hand to modify the rotation by 30 degrees.

In [2]:
rtn = mProjectQL('M17/raw/2mass-atlas-990502s-j1340186.fits', 
{'status': '0', 'time': 1.0}

Before and After

Here are the original image and the reprojected one:

In [3]:
from IPython.display import Image

rtn = mViewer("-ct 1 -gray M17/raw/2mass-atlas-990502s-j1340186.fits \
               -2s max gaussian-log -out work/M17/2mass-atlas-990502s-j1340186.png",
              "", mode=2)

{'status': '0', 'type': b'grayscale', 'nx': 512, 'ny': 1024, 'grayminval': 142.85527071691192, 'grayminpercent': 0.0, 'grayminsigma': -2.0, 'graymaxval': 8543.951171875, 'graymaxpercent': 100.0, 'graymaxsigma': 2225.7597600568683, 'blueminval': 0.0, 'blueminpercent': 0.0, 'blueminsigma': 0.0, 'bluemaxval': 0.0, 'bluemaxpercent': 0.0, 'bluemaxsigma': 0.0, 'greenminval': 0.0, 'greenminpercent': 0.0, 'greenminsigma': 0.0, 'greenmaxval': 0.0, 'greenmaxpercent': 0.0, 'greenmaxsigma': 0.0, 'redminval': 0.0, 'redminpercent': 0.0, 'redminsigma': 0.0, 'redmaxval': 0.0, 'redmaxpercent': 0.0, 'redmaxsigma': 0.0, 'graydatamin': 143.695556640625, 'graydatamax': 8543.951171875, 'bdatamin': 0.0, 'bdatamax': 0.0, 'gdatamin': 0.0, 'gdatamax': 0.0, 'rdatamin': 0.0, 'rdatamax': 0.0, 'flipX': 0, 'flipY': 1, 'colortable': 1, 'bunit': b''}
In [4]:
rtn = mViewer("-ct 1 -gray work/M17/2mass-atlas-990502s-j1340186_project.fits \
               -2s max gaussian-log -out work/M17/2mass-atlas-990502s-j1340186_projectQL.png",
              "", mode=2)

{'status': '0', 'type': b'grayscale', 'nx': 949, 'ny': 1142, 'grayminval': 142.85922821780923, 'grayminpercent': 0.0, 'grayminsigma': -2.0, 'graymaxval': 8297.618992713538, 'graymaxpercent': 100.0, 'graymaxsigma': 2141.72617612838, 'blueminval': 0.0, 'blueminpercent': 0.0, 'blueminsigma': 0.0, 'bluemaxval': 0.0, 'bluemaxpercent': 0.0, 'bluemaxsigma': 0.0, 'greenminval': 0.0, 'greenminpercent': 0.0, 'greenminsigma': 0.0, 'greenmaxval': 0.0, 'greenmaxpercent': 0.0, 'greenmaxsigma': 0.0, 'redminval': 0.0, 'redminpercent': 0.0, 'redminsigma': 0.0, 'redmaxval': 0.0, 'redmaxpercent': 0.0, 'redmaxsigma': 0.0, 'graydatamin': 143.87211172653642, 'graydatamax': 8297.618992713538, 'bdatamin': 0.0, 'bdatamax': 0.0, 'gdatamin': 0.0, 'gdatamax': 0.0, 'rdatamin': 0.0, 'rdatamax': 0.0, 'flipX': 0, 'flipY': 1, 'colortable': 1, 'bunit': b''}