imProc.flat - EranOfek/AstroPack GitHub Wiki
Description
The imProc.flat package contains basic functions to identify flat images, generate master flat images, and divide science images by the master flat. All operations including the generation and propagation of bit mask images associated with the flat images.
An introduction to bias and flat calibration is available here. Additional related packages and classes are: imProc.dark, CalibImages, and tools in the pipeline package.
Functions
- isFlat - Function for identifying flat images based on the header information, and similarity to some flat template image.
- flat - Create a master flat image. If necessary this function will identify the flat images.
- deflat - Divide science images by the master flat image. If necessary this function will create the master flat image.
imProc.flat.isFlat
A=AstroImage('LAST.*_dark.fits');
[Result,Flag] = imProc.flat.isFlat(A)
% you can control many parameters like the header keyword name that contains the FILTER name,
% and an AstroImage that contains a flat template (with variance) to which the flat images will
% be compared:
[Result,Flag] = imProc.flat.isFlat(A, 'FilterKey','FILTER1', 'Template',FlatTemplate)
imProc.flat.flat
To generate a master flat:
% read images to an AstroImage
AI = AstroImage('LAST.*_dark.fits')
% create a master bias image
Bias = imProc.dark.bias(AI);
% read flat images
AI = AstroImage('LAST.*_twflat.fits');
% identify only flat images
imProc.flat.isFlat(AI)
% subtract master bias from individual images
imProc.dark.debias(AI,Bias); % note that with CreateNewObj it fails
% Create a master flat image
[Flat,IsFlat,CoaddN]=imProc.flat.flat(AI);
imProc.flat.deflat
An example for a bias and flat correction of science images.
% read all images
AI = AstroImage('*.fits');
% identify bias images and create master bias:
Bias = imProc.dark.bias(AI);
% subtract master bias from all images
AI = imProc.dark.debias(AI, Bias);
% identify flat images and create master flat (images are bias subtracted)
Flat = imProc.flat.flat(AI);
% divide all images by Flat image
AI = imProc.flat.deflat(A, Flat);
Mask images
Both the dark/bias and flat functions are generating mask images. For the flat images, the default bit masks are:
- FlatHighStd - Mark pixels with large flat std.
- FlatLowVal - Mark pixels with low flat values.
- NaN - Mark NaN pixels (e.g., division by zero).
The user can control the thresholds for these parameters (see imProc.flat.flat help).
Variance images
The master flat creation also generates a variance image of the flat image. This image is stored in the Var property of the AstroImage object. The variance image can be used to estimate the flat field errors and to identify pixels that suffer from large noise.