StepFlat

class sofia_redux.instruments.hawc.steps.stepflat.StepFlat[source]

Bases: StepLoadAux

Correct for flat response for chop/nod data.

This pipeline step corrects the flux data for instrumental response, using a flat file made from a reference sky calibration and an internal calibrator file. Flats are made by sofia_redux.instruments.hawc.steps.StepMkflat. Input for this step is the demodulated data, produced by sofia_redux.instruments.hawc.steps.StepDemodulate and sofia_redux.instruments.hawc.steps.StepDmdCut.

In the output from this step, the R array and T array columns of the input demodulated data and their corresponding variances are converted to images and their columns removed from the table. In addition, separate bad pixel masks for the R and T array are copied from the flat file and appended to the output object. Pixels with a value of zero in the mask are good, any other value is bad.

Notes

For the data \(d\) and flat image \(f\) with variances \(\sigma^2\) and \(\sigma_f^2\) respectively, the correction is applied as

\[d' = f d\]

and propagated to the variance as

\[\sigma'^2 = f^2 \sigma^2 + d^2 \sigma_f^2 .\]

Methods Summary

checksize(datashape, flatshape)

Validate data and flux shapes.

flatfield(imgin, varin, flat, flatvar)

Flat field an array.

loadauxname([auxpar, data, multi])

Search for files matching auxfile.

loadflat()

Load the flat images.

run()

Run the data reduction algorithm.

setup()

Set parameters and metadata for the pipeline step.

Methods Documentation

checksize(datashape, flatshape)[source]

Validate data and flux shapes.

Parameters:
datashapetuple

Data shape.

flatshapetuple

Flat image shape.

Raises:
ValueError

If the flat does not match the data.

flatfield(imgin, varin, flat, flatvar)[source]

Flat field an array.

The flux image is multiplied by the flat data.

Parameters:
imginarray-like

Input flux array.

varinarray-like

Input variance array.

flatarray-like

Flat array matching imgin.

flatvararray-like

Variance array matching imgin.

Returns:
imgoutarray-like

Flat fielded image.

varoutarray-like

Updated variance.

loadauxname(auxpar='', data=None, multi=False)[source]

Search for files matching auxfile.

Overrides the default function in order to make flat path relative to data output directory if necessary.

Parameters:
auxparstr, optional

A name for the aux file parameter to use. This allows loadauxfiles to be used multiple times in a given pipe step (for example for darks and flats). Default value is self.auxpar which is set by loadauxsetup().

dataDataFits or DataText, optional

A data object to match the auxiliary file to. If no data is specified, self.datain is used (for Multi Input steps self.datain[0]).

multibool, optional

If set, a list of file names is returned instead of a single file name.

Returns:
str or list of str

The matching auxiliary file(s).

loadflat()[source]

Load the flat images.

The data is stored in self.flats.

run()[source]

Run the data reduction algorithm.

Because this step is single-in, single-out (SISO), self.datain must be a DataFits object. The output is also a DataFits object, stored in self.dataout.

The process is:

  1. Read data from the flat file.

  2. Apply the flat to the R and T arrays.

  3. Propagate the variance on the flux.

  4. Store the data as images in the output object.

setup()[source]

Set parameters and metadata for the pipeline step.

Output files have PRODTYPE = ‘flat’, and are named with the step abbreviation ‘FLA’.

Parameters defined for this step are:

labmodebool

If True, flat correction will be skipped.

flatfilestr

File name glob to match flat files. Default is ‘flats/OFT.fits’ to match flat files in a folder named flats, in the same directory as the input file.

flatfitkeyslist of str

Keys that need to match between flat and data file.

bkupflatstr

File name glob to match a set of backup files. These are used only if the files specified by flatfile are not found.