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: mBgExec¶

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, mBgExec, which is used to modify the backgrounds for a set of images.

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

help(mBgExec)

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

mBgExec(...)
mBgExec takes the background correction for each image (usually from mBgModel) and subtracts it using mBackground.

Parameters
----------
path : str
Path to input image directory.
tblfile : str
Table file list of images to correct.
fitfile : str
Table of background correction parameters.
corrdir : str
Directory for output corrected images.
noAreas : bool, optional
Flag indicating there are no area images.
debug : int, optional
Debugging output level.

Returns
-------
status : int
Return status (0: OK, 1:ERROR).
msg : str
Return message (for errors).
count : int
Total number of images.
nocorrection : int
Number of images with no correction parameters.
failed : int
Number of images where the correction failed.



## mBgExec Example¶

If we coadd a set of reprojected 2MASS images after reprojection but without doing anything about the backgrounds, the differences in background levels are obvious:

In [3]:
from IPython.display import Image

mViewer('-color black -imginfo M17/rimages.tbl \
-ct 1 -gray M17/uncorrected.fits -2s max gaussian-log \
-out work/M17/uncorrected.png',
'', mode=2)

Image(filename='work/M17/uncorrected.png')

Out[3]: