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.
mExamine is a utility function that allows the user to retrieve information on an image or a region in an image.
from MontagePy.main import mExamine, mViewer
help(mExamine)
The first example returns basic statistics on a whole image:
rtn = mExamine("M17/raw/2mass-atlas-990502s-j1340186.fits")
import pprint as pp
pp.pprint(rtn)
The return structure contains the image world coordinate system information (pixel dimensions, coordinate system, projection, projection center coordinates, reference pixel coordinates, image rotation), and the location of the four corners of the image on the sky and the center of the image. It also contains a number of fluxes (mean, rms, min, max) with locations.
The alphabetic ordering in the Python dictionary printing tends to obscure some of the relationships. See the bottom of the page for the standard order and descriptions.
If we want a specific area, we can add a cone specification:
rtn = mExamine("M17/raw/2mass-atlas-990502s-j1340186.fits", 1,
ra=274.8747874521937,
dec=-16.03329263885489,
radius=0.003)
import pprint as pp
pp.pprint(rtn)
If mExamine encounters an error, the return structure will just have two elements: a status of 1 ("error") and a message string that tries to diagnose the reason for the error.
For instance, if the user specifies an image that doesn't exist:
rtn = mExamine("M17/raw/unknown.fits")
print(rtn)
mExamine can also be run as a command-line tool in Linux, OS X, and Windows:
Usage: mExamine [-d][-p ra dec radius | -a ra dec] image.fits
If you are writing in C/C++, mExamine can be accessed as a library function:
/*-***********************************************************************/ /* */ /* mExamine */ /* */ /* Opens a FITS file (using the cfitsio library), finds the coordinates */ /* on the sky of the corners (using the WCS library) and converts them */ /* to equatorial J2000 (using the coord library). */ /* */ /* Outputs these corners plus all the image projection information. */ /* */ /* char *infile FITS file to examine */ /* int areaMode We can examine the image in general (0:NONE) */ /* a specific region with radius (1:AREA) or */ /* perform aperture photometry out to a fixed */ /* radius (2:APPHOT) */ /* */ /* int hdu Optional HDU offset for input file */ /* */ /* int plane3 If datacube, the plane index for dimension 3 */ /* int plane4 If datacube, the plane index for dimension 4 */ /* */ /* double ra RA for region statistics */ /* double dec Dec for region statistics */ /* double radius Radius for region statistics */ /* */ /* int locinpix The coordinates are actually in pixels */ /* int radinpix The radius is actually in pixels */ /* */ /* int debug Debugging output level */ /* */ /*************************************************************************/ struct mExamineReturn * mExamine(char *infile, int areaMode, int hdu, int plane3, int plane4, double ra, double dec, double radius, int locinpix, int radinpix, int debug)
Return Structure
struct mExamineReturn { int status; // Return status (0: OK, 1:ERROR) char msg [1024]; // Return message (for error return) char json[4096]; // Return parameters as JSON string char proj [32]; // Image projection. char csys [16]; // Coordinate system. double equinox; // Coordinate system equinox. int naxis; // Number of axes. int naxis1; // First axis size. int naxis2; // Second axis size. int naxis3; // Third axis size (if it exists). int naxis4; // Fourth axis size (if it exists). double crval1; // Axis 1 sky reference value. double crval2; // Axis 2 sky reference value. double crpix1; // Axis 1 reference pixel. double crpix2; // Axis 2 reference pixel. double cdelt1; // Axis 1 pixel scale. double cdelt2; // Axis 2 pixel scale. double crota2; // Image rotation on sky. double lonc; // Longitude of the image center. double latc; // Latitude of the image center. double ximgsize; // Axis 1 size on the sky. double yimgsize; // Axis 2 size on the sky. double rotequ; // Rotation of image relative to Equatorial North double rac; // RA of the image center. double decc; // Dec of the image center. double ra1; // RA of image corner 1 double dec1; // Dec of image corner 1 double ra2; // RA of image corner 2 double dec2; // Dec of image corner 2 double ra3; // RA of image corner 3 double dec3; // Dec of image corner 3 double ra4; // RA of image corner 4 double dec4; // Dec of image corner 4 double radius; // Radius of the examine radius (in degrees). double radpix; // Radius of the examine radius (in pixels). int npixel; // Number of pixel in the examine area. double nnull; // Number of null pixels in the examine area. double aveflux; // Average flux. double rmsflux; // RMS flux. double fluxref; // Flux for center (reference) pixel. double sigmaref; // Reference flux in units of RMS. double xref; // Pixel X of reference. double yref; // Pixel Y of reference. double raref; // RA of reference. double decref; // Dec of reference. double fluxmin; // Flux of pixel with minimum value in examine area. double sigmamin; // Min flux in units of RMS. double xmin; // Pixel X of min. double ymin; // Pixel Y of min. double ramin; // RA of min pixel. double decmin; // Dec of min pixel. double fluxmax; // Flux of pixel with maximum value in examine area. double sigmamax; // Max flux in units of RMS double xmax; // Pixel X of max. double ymax; // Pixel Y of max. double ramax; // RA of max pixel. double decmax; // Dec of m.n pixel. double totalflux; // Aperture phtometry total flux. };