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

Sometimes you may want to find the image in a set that "best" overlaps a specific location on the sky. Best in this case is defined as the image where the location of interest is farthest from the nearest edge. In other words, if you were to do a cutout around your location, this is the image that would give the largest area without hitting an edge.

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

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

    Given a list of images and a position, determine which image covers the location 'best' (i.e. the one where the position is farthest from the nearest edge).
    tblfile : str
        Input image metadata file.
    ra : float
        RA (J2000) of point of interest.
    dec : float
        Dec (J2000) of point of interest.
    debug : int, optional
        Debugging flag.
    status : int
        Return status (0: OK, 1:ERROR).
    msg : str
        Return message (for errors).
    file : str
        'Best' file name.
    hdu : int
        HDU in file.
    url : str
        URL to file (if available).
    edgedist : float
        Distance from point to nearest edge.

In this example, we have a set of image used to make a mosaic around M17 and we wish to find the image in the set that best covers M17 itself (RA = 275.19629, Dec = -16.17153).

In [2]:
rtn = mBestImage('M17/rimages.tbl', 275.19629, -16.17153)

{'status': '0', 'file': b'2mass-atlas-990502s-j1430080.fits', 'hdu': 0, 'url': b'', 'edgedist': 0.022766731904283688}


Here is the full mosaic, with the input images outlines shown in blue and the location of M17 shown as a black circle:

In [3]:
from IPython.display import Image

rtn = mViewer('-color blue -imginfo M17/rimages.tbl \
               -color yellow -symbol 6.0 circle \
               -mark 275.19629 -16.17153 \
               -ct 1 -gray M17/mosaic.fits \
               -2s max gaussian-log -out work/M17/bestimg.png',
              '', mode=2)