mProject

Description:

mProject reprojects a single image to the scale defined in a FITS header template file (read more about header templates here). The program produces a pair of images: the reprojected image and an "area" image consisting of the fraction input pixel sky area that went into each output pixel. The "drizzle" algorithm is implemented. The algorithm proceeds by mapping pixel corners (as adjusted by drizzle, if called) from the input pixel space to the output pixel space, calculating overlap area with each output pixel, and accumulating an appropriate fraction of the input flux into the output image pixels. In addition, the appropriate fraction of the input pixel area is accumulated into the area image pixels. Projection of points from input pixel space to output pixel space is calculated in two steps: first map from input pixel space to sky coordinates; second map from sky coordinates to output pixel space.

One situation that has happened often enough to warrant special note: It is possible to define a FITS header with the reference location off the image. In particular, people often reference cylindrical projections (e.g., CAR, CEA) to location (0.,0.) (e.g., the Galactic center). This is not wrong in itself but does lead to extremely large pixel offsets (e.g., in the hundreds of thousands). Related to this, if you extract a header from an image with large offsets of this type, it is unlikely that you can simply change projection types without also adjusting the reference location/offsets. Most likely, you will end up with the reproject data all being off-scale.

Syntax:
mProject [-z factor] [-d level] [-s statusfile] [-h hdu] [-x scale] [-w weightfile] [-W fixed-weight] [-t threshold] [-X] [-b border-string] [-e(nergy-mode)] [-f] in.fits out.fits hdr.template

Switches:

-z factor
Processing is done utilizing the drizzle algorithm. factor is a floating point number; recommended drizzle factors are from 0.5 to 1.
-d level
Causes additional debugging information to be printed to stdout. Valid levels are 1-5 (for higher debugging levels, it is recommended to redirect the output to a file).
-s statusfile
Output and errors are written to statusfile instead of being written to stdout.
-h hdu
Use the specified FITS extension (default is to use the first HDU with image data)
-x scale
Apply a correction factor of scale to each pixel
-w weightfile
Path to a weight map to be used when reading values from the input image.
-W fixed-weight
Use constant weight value for the whole image.
-t threshold
Pixels with weights below threshold will be treated as blank.
-X
Makes the output region (originally defined in the header template) big enough to include all of the input images
-b border-string
Define a border width or border pixel corners outside of which all pixels are set to NaN.
-e
Process the data as total energy rather than the default energy density (scale values by relative pixel areas).
-f
Output the full region requested even if there is a border of NULL values (default is to shrinkwrap to just the pixels with values).

Arguments:

in.fits
Input FITS file to be reprojected.
out.fits
Path of output FITS file to be created.
hdr.template
FITS header template to be used in generation of output image
Results:
Two files are created as output: the reprojected FITS file (out.fits), and an "area" image (out_area.fits) which records the amount of coverage (in output pixel space) provided by the input images.

Examples:

$ mProject rawdir/real_orig.fits projdir/base_unity.fits templates/galactic_orig.txt
[struct stat="OK", time=143]

Return Codes:

  • [struct stat="OK", time=seconds]
  • [struct stat="ERROR", msg="Usage: mProject [-z factor][-d level][-i ypix,xpix][-o ypix,xpix] in.fits out.fits hdr.template"]
  • [struct stat="ERROR", msg="Drizzle factor string (string) cannot be interpreted as a real number"]
  • [struct stat="ERROR", msg="Weight threshold string (string) cannot be interpreted as a real number"]
  • [struct stat="ERROR", msg="Flux scale string (string) cannot be interpreted as a real number"]
  • [struct stat="ERROR", msg="Cannot open status file: statusfile"]
  • [struct stat="ERROR", msg="HDU value (hdu) must be a non-negative integer"]
  • [struct stat="ERROR", msg="No overlap"] (indicates that none of the output pixels are contained in the area defined by the header template)
  • [struct stat="ERROR", msg="Not enough memory for output data image array"]
  • [struct stat="ERROR", msg="Not enough memory for output area image array"]
  • [struct stat="ERROR", msg="Output wcsinit() failed."]
  • [struct stat="ERROR", msg="Input wcsinit() failed."]
  • [struct stat="ERROR", status=n, msg="FITS library error"]
  • [struct stat="ERROR", msg="All pixels are blank"]
  • [struct stat="ERROR", msg="Template file not found"]
  • [struct stat="ERROR", msg="Image file in.fits missing or invalid FITS"]
  • [struct stat="ERROR", msg="Weight file weightfile missing or invalid FITS"]