You are here: Home / Surveys & Projects / Software Release / Image Stacking

Image Stacking

imstack performs a WCS-based stack of a given set of input FITS images, infiles, writing the output to outfile. Confidence maps (essentially an inverse variance weight map modulo bad pixel mask, scaled to a median value of 100 with bad pixels set to 0) must be used in stacking. The input images and confidence maps can be specified as a comma-separated list on the command-line. Alternately if the parameter begins with an @ character it is assumed that the string following the @ is the name of a text file with an ASCII list of input files, one per line. The list of confidence maps may consist of a single file (in which case the same confidence map will apply to all the input images) or a list of identical length to the to infiles. Single or multi-extension FITS images may be processed, but images must match their corresponding confidence maps in terms of the number of extensions and the sizes of their data arrays. In the case of multi-extension input, each extension is stacked separately and written to the corresponding extension in the output image and confidence map.

An optional list of catalogues (as generated by imcore) can also be specified in the parameter cats on the command line. These are used to do either of 4 or 6 coefficient plate constant fit (depending on the value of --nplate) in pixel space. The resulting transformation can help refine the WCS defined in the input image header relative to that of the first image and can improve the final result if there are enough stars in each catalogue. This list can be specified in the same way as the image lists above. If this option is not to be used, then a pair of double quotes ("") should be specified.

The first FITS image in infiles is used as a reference and the other input images are resampled onto a grid specified by its WCS. The (clipped) average of the pixel values from all of the files, scaled by their exposure times (given by the keyword specified in --expkey) and weighted by the confidence value from each corresponding confidence map, is computed and recorded in the output map. Outliers specified by the clipping thresholds --lthr and --hthr will be removed from the averaging. Currently two interpolation schemes are available for use. These are specified by the --method command line parameter (see below for allowed values and their meanings). The output confidence map (outconf) contains the sum of the confidence values at each pixel, renormalised to a median value of 100.

At present the only WCS projections allowed are TAN and ZPN.


imstack infiles confmaps cats outfile outconf


Input files separated by comma or a file list as in @list.
Respective confidence maps for each of the input files.
Catalogues for each image, generated by imcore.
Output stacked image
Output confidence map


The following options are supported.  Default values are specified after the equal sign. In the case of a boolean switch no value is required the default state is specified in brackets.

The lower threshold for clipping in units of background sigma.
The upper threshold for clipping in units of background sigma
The interpolation method to be used -- the following integer values are allowed:
0: (nearest neighbour) An input pixel is mapped to the location on the output grid that is nearest to its equatorial position
1: (bi-linear interpolation) An input pixel is divided up into the four pixels on the output grid that surround the input equatorial position. The   fraction going into each output pixel depends on the amount of overlap of the input pixel.
If a catalogue list is specified in cats then this is the number of plate constants to fit to the pixels space coordinates of the matched objects.
Name of the keyword which stores the exposure time.
--(no)seewt (no)
Weight the images by the inverse of the square root of the average seeing.