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

It is often the case that only a small piece of an image is needed for science or visualization purposes. mSubimage provides a way to cut out such a piece and still maintain all the header and projection information.

In [3]:
from MontagePy.main import mSubimage, mViewer

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

    mSubimage extracts a subimage from one FITS file into a new FITS file.
    infile : str
        Input FITS file.
    outfile : str
        Subimage output FITS file.
    ra : float
        RA of cutout center (or start X pixel in PIX mode.
    dec : float
        Dec of cutout center (or start X pixel in PIX mode.
    xsize : float
        X size in degrees (SKY mode) or pixels (PIX mode).
    ysize : float
        Y size in degrees (SKY mode) or pixels (PIX mode).
    mode : int, optional
        Processing mode. The two main modes are 0 (SKY) and 1 (PIX), corresponding to cutouts are in sky coordinate or pixel space. The two other modes are 3 (HDU) and 4 (SHRINK), where the region parameters are ignored and you get back either a single HDU or an image that has had all the blank border pixels removed.
    hdu : int, optional
        Optional HDU offset for input file.
    nowcs : bool, optional
        Indicates that the image has no WCS info (only makes sense in PIX mode).
    debug : int, optional
        Debugging output level.
    status : int
        Return status (0: OK, 1:ERROR).
    msg : str
        Return message (for errors).
    content : str
        String giving an idea of output content (e.e., 'blank', 'flat', or 'normal'.

mSubImage Example

In this example, we will cut a small region from the center of a large mosaic, using the default center coordinate/size mode:

In [4]:
rtn = mSubimage('M17/mosaic_small.fits', 
                275.19629, -16.17153, 0.3, 0.3)
{'status': '0', 'content': b'normal'}

Before and After

Here are the original image and the cutout:

In [5]:
from IPython.display import HTML, display, Image

mViewer('-ct 1 -gray M17/mosaic_small.fits \
         -2s max gaussian-log -out work/M17/mosaic_small.png',
        '', mode=2)