M

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

There are a few situations where you may need to create an image:

  • A blank image to be used as a drawing surface for overlays (catalog symbols, coordinate grid, etc.
  • An image for a wavelength where we don't have image data, generated from a catalog. This might be used, for instance, in making a color composite with other wavelengths.
  • A coverage map or mask made from image metadata.

And there are bound to be others.

mMakeImg can produce all of the above. The input is an image header template and a collection of datasets with controls on how they are to be rendered: image background (level, slope and noise); catalog source data (scaled by magnitude, either gaussian PSF or uniform disk) or image metadata (filled boxes). There is even a mechanism for creating a true image from a raw file of pixel values.

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

help(mMakeImg)
Help on built-in function mMakeImg in module MontagePy.main:

mMakeImg(...)
    mMakeImg creates FITS images using synthetic data (sloping background, catalogs, coverage info, etc.
    
    Parameters
    ----------
    template_file : str
        Header template describing the image (and to be part of it).
    output_file : str
        Output FITS file.
    layout : str, optional
        JSON structure alternative input to all parameters below.
    mode : int, optional
        0: JSON file, 1: JSON, 2: command string.
    debug : int, optional
        Debugging output level.
    
    
    Returns
    -------
    status : int
        Return status (0: OK, 1:ERROR).
    msg : str
        Return message (for errors).
    srccnt : int
        Number of catalog sources included.
    imgcnt : int
        Number of image regions included.

Example

The number of arguments to mMakeImg is a little large for a standard keyword list so we also be using a JSON rendering of the parameters as the driver. This could be in the form of a file but we will use a JSON string.

Here we create the JSON as a simple string (note the triple quotes which let us make this a multi-line with embedded quotes, etc.) Since this is an active notebook, you can modify this as you like to adjust the final image.

In [2]:
imgjson = """
{ 
   "background": 
   { 
      "noise" : 0.001, 
      "bg11"  : 0.0, 
      "bg1N"  : 0.0, 
      "bgNN"  : 0.0, 
      "bgN1"  : 0.0 
   }, 
 
   "datasets": 
   [ 
      { 
         "type"   : "catalog", 
         "file"   : "SDSS/fp_2mass.tbl", 
         "column" : "j_m", 
         "width"  :  5.0, 
         "csys"   : "Equ J2000", 
         "refval" :  16.0, 
         "mode"   : "mag", 
         "shape"  : "gaussian" 
      }, 
      { 
         "type"   : "imginfo", 
         "file"   : "SDSS/irsmap.tbl", 
         "refval" :  0.2 
      } 
   ] 
}
"""

All of the input options are handled by the above JSON, so the arguments to the call are just that JSON structure and the name of the new output image file:

In [3]:
rtn = mMakeImg('SDSS/SDSS.hdr', 'work/mMakeImg.fits', mode=1, layout=imgjson)

print(rtn)
{'status': '0', 'srccnt': 290, 'imgcnt': 3138}

Here is the resultant image. You wouldn't normally mix all these kinds of data in one place; the catalog simulated image and the image metadata coverage density are usually generated for different purposes.

In [4]:
from IPython.display import Image

mViewer("-ct 1 -gray work/mMakeImg.fits -2s max gaussian-log", 
        "work/mMakeImg.png",
         mode=2)

Image(filename='work/mMakeImg.png')
Out[4]: