User guide

Donuts computes the translational shift between two images of the same star field. It has been used with great success for multiple instruments including defocused observations.

To measure the shifts present in a series of images requires the definition of a reference frame. An image must be chosen from the series to be the reference. This is treated as 0,0 in the translational coordinate syst. Donuts then measures the shift of each subsequent image with respect to the reference. Reference images should be free from unwanted artefacts (satellite trails etc.)

Example usage

The example below shows typical usage of the donuts api:

>>> from donuts import Donuts
>>> reference_image_name = 'image1.fits'
>>> science_image_names = ['image2.fits', 'image2.fits']
>>> # Construct a donuts object
>>> d = Donuts(
...   refimage=reference_image_name,
...   image_ext=0,
...   overscan_width=20,
...   prescan_width=20,
...   border=64,
...   normalise=True,
...   exposure='EXPOSURE',
...   subtract_bkg=True,
...   ntiles=32)
>>> # for each image, compute the x/y translation required
... # to align the images onto the reference image
>>> for image in science_image_names:
...     shift_result = d.measure_shift(checkimage=image)
...     x = shift_result.x
...     y = shift_result.y
...     # Also check out shift_result.sky_background
...     print(x, y)

Further detail

More explanation of the Donuts constructor parameters are given below.

Defining the reference image

The following section describes some settings that can be applied to each image. It is important that the process applied to the reference image is applied to each science image to ensure that only the field position changes between images, hence the settings chosen during initialization are used for each subseqient image.

Image extension

The fits image extension to be used in the calculation is set with the image_ext parameter, which defaults to 0 (the primary HDU). If your image is in another extension, specify it here.

Prescan and overscan removal

If your images contain either prescan or overscan regions, set the width of each using the prescan_width and overscan_width values (both default to 0).

Summary of object settings

A summary of the object’s settings can be seen using:

>>> d.print_summary()

Computing per-image offsets

With a Donuts object, the x/y translation required to align the image into the reference image is given by the measure_shift() method, which returns an Image object. e.g.:

>>> shift_result = d.measure_shift(checkimage='image.fits')
>>> x, y = shift_result.x, shift_result.y

x and y are returned in pixel units.

Looking at the computation intermediate products

The Image object returned by measure_shift() contains some products of the image normalisation procedure. Products available are:

  • raw_region: the image pixels used, contained in the trimmed region of the chip
  • sky_background: the computed sky background in raw_region
  • backsub_region: the sky-subtracted region used for image alignment
  • proj_x/proj_y: the 1-D image projection arrays calculated from backsub_region