Department of Physics AstroLab

Flat Fielding

What is flat fielding and why do it?

A flat field is the response of the telescope-camera system to a source of uniform illumination. Flat field frames are used to correct for anomalies in the optical path, such as specs of dust on the optical surfaces, sensitivity variances between pixels in the CCD, and illumination variations within the optical system (vignetting).
A flat field frame is basically an image of a uniformly illuminated field. Since this flat contains the variations in illumination due to variations within the optial system, dividing the science image by the normalised flat filed frame will correct the image for these variations.
This procedure is referred to as flat fielding.

When to do flat fielding?

Flat fielding to remove inhomogeneities in the filed illumination is always performed in astronomy research; however, within the scope of AstroLab is not always necessary. Flat fielding is particularly useful when precise photometry is required, such as for light curve determination projects. Ideally one would like to use one flat field per night.

Typical example of a CCD image with dust specks in front of the lens.
If your data looks like this, you might want to perform flat fielding.

While the flat field is usually produced from a uniformly illuminated field such as the dome, it can also be made by averaging several images made with the same telescope-camera set-up.
Over the course of a typical observing period, the stars will appear to drift along the image due to the poor tracking of the telescope, whereas dark patches due to the dust speckles will remain in the same position.
Taking the median intensity of several images from the night will produce a frame containing the dark dust speckles, but not the stars.
Needless to say, this method can only be used for a data sequence taken over a longer period. You should have more than 50 images before attempting to create a flat field from them!

Performing flat fielding - the step-by-step guide

Flat fielding can be done using the CCD Data Reduction Package CCDPACK by Peter Draper, which is installed locally.

Useful references are:

Step 1 - Set-up

Define Starlink CONVERT commands:


Setup the Starlink KAPPA commands:


Step 2 - Using CCDPACK

To access CCDPACK commands, type:


Then run:


Page for makeflat description and further options can be found here:

Specify the input (e.g., 'ad*') and output (e.g., 'flat').

Hint: Multiple images can be loaded by using the wildcard symbol *.

You may get an error stating that your input file has not been debiased; ignore this.

When prompted for method to combine the data components of the input images, choose the weighted median:


Now check that the flat field image contains only valid pixels by using the Kappa stats command.

If this reports that the "No. of pixels excluded" is greater than 0, you will need to "nomagic" the flat field image, i.e.

nomagic master_flat new_master_flat 1

Step 3 - Applying your flat field to images

Access div command from KAPPA:


Enter your .sdf image name followed by your flat field name as required.

Now look at your new output and be impressed!


your image
simple flat field frame made from only 5 images
result: wow!

FlatFielding and the "" script

If the "" script finds a file called "master_flat.sdf" in the processing directory this is applied.

Back to the AstroLab Home Page jrl 2020-Jun-17 13:37:22 UTC