Dark and Flat calibration - EranOfek/AstroPack GitHub Wiki

Background

Among the first operations performed on a raw science image are bias/dark subtraction and division by a flat image. In some cases, we may be interested in additional operations including masking bad pixels, de-fringing, and multiplying the image by the gain. Further details regarding mask images in AstroPack are discussed in manuals.topic.Masks The terminology and rationale are explained below.

Bias Image

A bias image maps the number of counts in each pixel under zero exposure time and closed shutter (or darkness). In typical detectors, the bias level is added in order to avoid negative values that can appear due to noise in the reading process (read noise).

Dark Image

A dark image is an exposure taken with a closed shutter (or darkness), usually with the same exposure time as the science images. It maps the bias level plus the dark current. It is usually used when the dark current is not negligible.

Overscan

In CCDs overscan refers to continuously reading the pixel values after all the actual pixels in the column were read. Therefore, this process provides an extra bias reading which is specific for the current image. This process allows us to verify, or correct, the bias level of the CCD.

Darkened Pixels

In CMOS detectors, the concept of overscan does not exist. However, we can use darkened pixels to get a typical dark level per image.

Flat Image

A flat image maps the response of the optical system (including the detector) to a uniform illumination.

Fringing

Detectors usually have a non-uniform thickness. Therefore, a mono-chromatic light that hits the detector will suffer constructive and destructive interference. The red-spectrum sky background, in dark sites, is dominated by (e.g., O2 and OH) emission lines. These emission lines provide a monochromatic light source that imprints interference patterns (Newton rings) on the image. Since these lines are strong mainly in the red part of the spectrum fringing artifacts are commonly seen in i-band observations. The intensity of this pattern is proportional to the strength of the emission line compared to the background (i.e., the equivalent widths of the lines).

Gain

Gain is the conversion factor between photo-electrons generated on the detector and counts after the readout process. In astronomy, the gain is commonly measured in units of electrons per ADU. Images that are converted back to units of electrons are useful since, in this case, the variance is equal to the pixel value.

How to apply dark, flat, fringe and overscan calibration

In AstroPack, there are two ways one can implement the basic calibration process:

  1. Using specific functions to create and use bias, dark and flat images.
  2. Using the CalibImages class. This class allows for calibrating images in a single function call.

All these functions are operating on AstroImage objects. The AstroImage object contains not only the dark/flat image but also its variance image and mask image.

Low-level functions

imProc.dark.isBias / imProc.dark.isDark

The imProc.dark.isBias / imProc.dark.isDark allows to select bias/dark images from a list of images. The selection is done by the IMTYPE header keyword and by searching for images that their statistics are consistent with a bias image. A simple example: A=AstroImage('LAST.*_dark.fits'); [Result,Flag] = imProc.dark.isBias(A) imProc.dark.bias The imProc.dark.bias function can be used to create a master bias image from a list of AstroImage objects. The output is an AstroImage containing the master bias image. By default this function will select the bias images in the input images (e.g., using the imProc.dark.isBias function).

A=AstroImage('LAST.*_dark.fits')
Bias = imProc.dark.bias(A)
Bias = imProc.dark.bias(A, 'IsBias',[]);  % assume all input images are bias images.

This function also generates a variance and mask image. The mask image contains information on low read noise pixels (e.g., dead pixels), high readnoise pixels (i.e., hot pixels), high-value pixels, low-value pixels, and flaring pixels. The definitions of these pixels are controlled via the input arguments of the imProc.dark.bias function. This function (imProc.dark.bias) can be used to create a master dark image for some applications (e.g., constant exposure time and temperature). In the future, a dedicated function to create a master dark image will be added.

imProc.dark.debias

This function subtracts the master bias/dark from a set of images. If the master dark/bias is not provided, then it will be generated from the individual bias/dark images in the set of images.

imProc.dark.overscan

Subtract overscan/darkened pixels region from an image.

imProc.flat.isFlat

Search for flat images (similar to isBias).

imProc.flat.flat

Constructing the master flat image (similar to bias). In the mask image, three kinds of problems are detected using the flat images: low-value flat, high-std flat, and NaN pixels. The definitions of these masked pixels are available as input arguments of this function.

imProc.flat.deflat

Dividing a set of images by the master flat image. If the master flat is not provided, then it will be generated from the individual flat images in the set of images.

The CalibImages class

The CalibImages class is a container for bias/dark/flat/fringing images. It also allows for calibrating science images in a single step. Some simple examples:

CI = CalibImages('Bias',Bias, 'Flat',Flat);  % load bias/flat images
% create bias/flat and process:
CI.createBias(Images);
CI.createFlatFilter(Images, 'R');  % create a flat image for a single filter
CI.createFlat(Images);  % create flat images for all filters
CI.processImages(Images); % subtract bias and divide by flat

The class also contains specific functions for the individual steps. Note that the processImages method will also apply other calibration steps (e.g., fringing and multiplication by the gain).