StepSkycal

class sofia_redux.instruments.hawc.steps.stepskycal.StepSkycal[source]

Bases: StepMIParent, StepLoadAux

Generate a reference sky calibration file.

This step divides scan mode sky flats by processed INT_CAL data, then combines and normalizes the sky flats to generate a master reference sky cal.

Methods Summary

loadauxname([auxpar, data, multi])

Search for files matching auxfile.

read_refpix()

Read a reference pixel file from the parameters.

run()

Run the data reduction algorithm.

setup()

Set parameters and metadata for the pipeline step.

Methods Documentation

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).

read_refpix()[source]

Read a reference pixel file from the parameters.

The parameter is expected to be defined as a list, with one entry for each HAWC band. The correct value for the input data is selected from the list.

Returns:
pixfilestr

Path to the reference file.

run()[source]

Run the data reduction algorithm.

This step is run as a multiple-in single-out (MISO) step: self.datain should be a list of DataFits, and output will also be a single DataFits, stored in self.dataout.

The process is to make a skyflat for the DRP pipeline:

  1. Divide R and T gains by the INTCAL DCL files closest in time, to derive master sky gains.

  2. Mean combine all sky gains and optionally normalize by the median value.

  3. Sigma clip the gains arrays to identify additional bad pixels.

  4. Scale the T array to the R array.

  5. Compare the produced skyflat with the current default, saving a comparison image to disk with the filename as basename + ‘_comparison.png’.

Then, to make a pixeldata (flat/bad pixel table) for the scan mode pipeline:

  1. Read in pixeldata files.

  2. Mean-combine gains for each pixel.

  3. Or-combine flags for each pixel.

  4. Generate plots comparing the individual and averaged pixel data files to an existing default file. Plot file names are basename + ‘_histogram.png’ and basename + ‘_pix2pix.png’.

  5. Save the combined table to disk, with the filename as basename + ‘.dat’.

setup()[source]

Set parameters and metadata for the pipeline step.

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

Parameters defined for this step are:

normalizebool

If set, sky cals are divided by their median values to normalize them before sigma-clipping.

sigma_lowerfloat

Lower sigma value to use for clipping.

sigma_upperfloat

Upper sigma value to use for clipping.

ttorfloat

Scale factor for the T array to the R array

scalfitkeyslist of str

Keys that need to match between data file reference SCAL file, for comparison.

binningstr

Binning method for comparison histogram.

dclfilestr

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

dclfitkeyslist of str

Keys that need to match between DCL and data file.