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.
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, mProject, which is one of the modules used to reproject images.
Visit Building a Mosaic with Montage to see how mProject 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.
from MontagePy.main import mProject, mViewer
help(mProject)
mProject is one of four modules focused on the task of reprojecting an astronomical image. It is totally general (any projection and coordinate system) and flux-conserving but is also the slowest. The algorithm is based on pixel overlap in spherical sky coordinates rather than in the input or output planar pixel space.
mProject has a number of extra controls for things like toggling from the normal flux-density mode to total energy mode or 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.
rtn = mProject('M17/raw/2mass-atlas-990502s-j1340186.fits',
'work/M17/2mass-atlas-990502s-j1340186_project.fits',
'M17/rotated.hdr')
print(rtn)
Here are the original image and the reprojected one:
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)
print(rtn)
Image(filename='work/M17/2mass-atlas-990502s-j1340186.png')
rtn = mViewer("-ct 1 -gray work/M17/2mass-atlas-990502s-j1340186_project.fits \
-2s max gaussian-log -out work/M17/2mass-atlas-990502s-j1340186_project.png",
"", mode=2)
print(rtn)
Image(filename='work/M17/2mass-atlas-990502s-j1340186_project.png')