makeflat¶
- sofia_redux.instruments.exes.makeflat.makeflat(cards, header, variance, robust=4.0, radius=10, black_frame=None, dark=None, fix_tort=False, edge_method='deriv', custom_wavemap=None, start_pixel=None, end_pixel=None, top_pixel=None, bottom_pixel=None)[source]¶
Generate calibrated flat frame; set distortion parameters.
The procedure is:
Black, sky, and shiny frames are identified. Typically, only black frames are present for EXES flats.
The black frame is used to set and test distortion parameters.
A difference frame is calculated (typically black-dark) and normalized by the black-body function at the ambient temperature (hdr[‘BBTEMP’]).
The inverse frame (bb / (black - dark)) is calculated.
Unilluminated pixels are set to zero in the inverse frame.
Calibration is performed by multiplying science data by the output frame.
- Parameters:
- cardsnumpy.ndarray
3D cube [nframe, nspec, nspat] or 2D image [nspec, nspat] containing flat frames (black, sky, or shiny).
- headerfits.Header
FITS header for the flat file.
- variancenumpy.ndarray
Variance array, matching
cards
shape.- robustfloat, optional
Threshold for outlier rejection in robust mean combination, specified as a factor times the standard deviation.
- radiusint, optional
Pixel radius to search for good pixels, used for interpolation over bad pixels in the flat frames.
- black_frameint, optional
Index of the black frame in the input
cards
(typically 0). If not provided, the black frame is set as the card with the highest mean value.- darknumpy.ndarray, optional
Slit dark frame image [nspec, nspat]. If provided, and the input flat has a black card only, it will be subtracted from the black frame to make the difference image.
- fix_tortbool, optional
If True, no attempt will be made to optimize distortion parameters for cross-dispersed modes.
- edge_method{‘deriv’, ‘sqderiv’, ‘sobel’}, optional
Sets the edge enhancement method for optimizing the cross-dispersed distortion parameters. May be one derivative (‘deriv’), squared derivative (‘sqderiv’), or Sobel (‘sobel’). custom_wavemap
- custom_wavemapstr or bool, optional
Filename for a text file containing explicit order edges for a cross-dispersed mode, as whitespace-separated integers indicating bottom, top, left, and right edges for each order (one per line). If set, it is used to directly set the order mask for a cross-dispersed mode. If set to a value other than a string or None, a ‘customWVM.dat’ file is expected in the current directory.
- top_pixelint, optional
If provided, is used to directly set the top edge of the order. Used for single-order modes only (medium, low); ignored for cross-dispersed modes.
- bottom_pixelint, optional
If provided, is used to directly set the bottom edge of the order. Used for single-order modes only (medium, low); ignored for cross-dispersed modes.
- start_pixelint, optional
If provided, is used to directly set the left edge of all orders. May be used for either single-order or cross-dispersed modes.
- end_pixelint, optional
If provided, is used to directly set the right edge of all orders. May be used for either single-order or cross-dispersed modes.
- Returns: