Department of Physics AstroLab

Stacking Images

The combining of several images allow fainter sources to be detected and their apparent magnitudes determined with improved precision.

stackX2.py

  • Create a working directory(folder) and "change" to this directory, e.g.

    >  mkdir mystack  
    >  cd mystack 
    It is helpful, of course, to give this directory a sensible name!

  • Examine the observing logs and select the fits images required. If necessary visually examine the fits images with the Starlink GAIA image display tool and note the numbers of the images that you may which to exclude from the stracking, e.g. those with poor tracking or poor S/N.

    Copy the images you would like to stack to your working directory, e.g.

    > cp /mnt/archive/draco2/2024/24_01_15/d0001.fits .
  • Run the python script /mnt/64bin/stackX2.py .

    The syntax is:

    >  python /mnt/64bin/stackX2.py PSF_limit 

    e.g.

    >  python /mnt/64bin/stackX2.py 5.0

    will attempt to stack all d*.fits in the current directory where the PSF has FWHM<5.0.

    If master_flat.fits is included in the working directory, it will be used to flat field each frame first.

    If successful, an output image called "mosaic.fits" will be produced. This is the average of all the "d" fits images in the sequence. In the stacking process averaging is used rather than summing to allow for pixels with missing values.

  • If this is unsuccessful, try dfstack.py3 below

dfstack.py3

We can also use the routines provided by Peter Draper's CCDPACK package to stack, i.e. register and average, sets of images.

A basic csh script is available that stacks of a set of the "default" AstroLab dark-subtracted images, i.e. the "dxxxx.fits, ..." image files. Follow the same steps as above, but instead run:

  • Run the python script

    >  /mnt/64bin/dfstack.py 

    The syntax is:

    >  python /mnt/64bin/dfstack.py telescope date start end 

    e.g.

    >  python /mnt/64bin/dfstack.py east-14 19_01_30 140 150 

    If you want to exclude files in the sequence put their numbers in a file called "DONT_PROCESS".

    The average of the fits header keyword DATE-OBS, i.e. the UTC (Coordinated Universal Time) of each image, is calculated and stored in the fits header of the output image as the DATE-OBS value. The mean modified julian date is also calculated and is stored as the value of the keyword MJD-OBS.

  • The script will also attempt to determine the astrometry mapping for the image, i.e. the (x, y) pixel to (RA, Dec) mapping, from the auto identification of UCAC4 stars. (This image when displayed with Starlink's GAIA image display tool will give (RA, Dec) positions as well as the (x, y) pixel positions). If successful, an output image called "amosaic_ucac4.fits" will be produced. The code will also attempt to use the ESA-GAIA star catalogue to put an astrometry mapping on the image. If successful, an output image called "amosaic_gaia.fits" will be produced.

Calculation of Photometric Errors in Stack Images

When undertaking aperture photometry with Starlink's GAIA the usual defaults calculate the photometric errors by assuming that the input image has units of "photon" counts and hence photon statistics are used to estimate the error. The stacked image produced by the csh script is the "average" (rather than the summed) image and hence GAIA's default setup parameters will give an erronous estimate of the photometric error.

Consider the following simple case. If an object in an individual image had a total count of ∼100, then ignoring any background/readout noise uncertainties, the statistical error would be the square root of 100, i.e. 10, and hence a 10% error on the flux. If nine images were used in stacking process the total count for this object would still be reported as ∼100, i.e. the images are averaged rather than summed. Now if photon statistics were assumed the same 10% error would be calculated which is incorrect. The stacked image effectively has 900 counts in the object and hence the statistical error is the square root of 900, i.e. 30, and hence a 3.3% error on the flux.

In GAIA the simplest way to get approximately correct photometric errors on a stack image is to change the "aperture photometry parameter" "Measurement errors use:" from "photon statistics" to "sky variance". GAIA will then use the scatter in the pixel counts in the sky annulus to estimate a reasonable "gain" factor to use in the photometric error calculation.


Back to the AstroLab Home Page jrl 2020-Jun-17 12:27:34 UTC