apply_static_flat¶
- sofia_redux.instruments.fifi_ls.apply_static_flat.apply_static_flat(filename, outdir=None, write=None, skip_err=True)[source]¶
Apply pre-reduced and normalized flat to FIFI-LS data.
The procedure is:
Identify a spatial and spectral flat field to use. The code will look for flat files that match the current configuration (channel, dichroic, and order), and the observation date (spatial flats only).
Loop through each grating scan extension in the input file, composing a flat cube from the spatial and spectral flat inputs.
Divide the data cube by the flat cube and optionally propagate the flat error to the error cube.
Create FITS file and (optionally) write results to disk.
The output FITS file contains n_scan * 7 image extensions: FLUX, STDDEV, LAMBDA, XS, YS, FLAT, and FLATERR data cubes, with a ‘_G{i}’ suffix for each grating extension i. For most data, FLUX and STDDEV are 25 x 16 arrays; for OTF data they are 25 x 16 x n_ramp. The XS and YS arrays are usually 25-element 1D arrays; for OTF data they are 25 x 1 x n_ramp. The LAMBDA, FLAT, and FLATERR arrays are always 25 x 16.
- Parameters:
- filenamestr
File to be flat field corrected. Should have been generated by fifi_ls.spatial_calibrate.
- outdirstr, optional
Directory path to write output. If None, output files will be written to the same directory as the input files.
- writebool, optional
If True, write to disk and return the path to the output file. If False, return the HDUL. The output filename is created from the input filename, with the suffix ‘XYC’ replaced with ‘FLF’.
- skip_errbool, optional
If True, flat errors will not be propagated.
- Returns:
- fits.HDUList or str
Either the HDU (if write is False) or the filename of the output file (if write is True)