HAWCReduction

class sofia_redux.pipeline.sofia.hawc_reduction.HAWCReduction[source]

Bases: Reduction

HAWC+ reduction steps.

Reduction algorithms are all defined in the sofia_redux.instruments.hawc module.

This reduction object does not define a method for each pipeline step. Rather, it calls run_drp_step each time step is called, and uses the DRP infrastructure to determine which step to run.

Some reduction “steps” are defined in this class as super-steps, combining several DRP steps together. This may be used for convenience (e.g. the make_flats step, which saves the user from running a separate pipeline to produce flat files in nod or nod-pol modes) or for performance (e.g. the demodulate step, which loads one large raw file at a time, so that all data is not in memory at once).

Attributes:
step_classdict

All step classes available from the DRP. Keys are pipeline step names.

step_namedict

Names of all pipeline steps available from the DRP. Keys are pipeline step class names.

param_listsdict

DRP pipeline step parameter lists for all available steps. Keys are pipeline step names.

extra_stepsdict

Locally defined pipeline steps. Keys are step names, values are step descriptions.

override_steplistdict

Pipeline step lists to override the ones defined in the DRP configuration files. These lists should include any locally defined steps that replace DRP steps. Keys are pipeline modes, values are lists of steps to run.

intermediatebool

If True, the input data is an intermediate product, and a subset of the full pipeline recipe is being run.

auxoutlist of str

Auxiliary output files produced by the pipeline, intended for display. These may include PNG images and DS9 region files.

Initialize the reduction object.

Methods Summary

demodulate()

Demodulate chop-nod data.

load(data)

Load input data to make it available to reduction steps.

load_step_packs()

Load DRP pipeline step modules.

make_flats()

Make nod or nod-pol flats from INT_CAL files.

process_intcal()

Process INT_CAL files for skycal generation.

register_viewers()

Instantiate viewers appropriate to the reduction.

run_drp_step([step_name, use_param])

Run a DRP pipeline step.

set_display_data([display, auxout])

Pass data in self.input to display.

step([alt_method])

Run a reduction step.

Methods Documentation

demodulate()[source]

Demodulate chop-nod data.

This super-step calls all steps up to and including the StepDemodulate step defined for the current pipeline mode in the DRP configuration. The full set of steps is called on one file at a time, such that only one raw, un-demodulated data file is in memory at a time. This helps improve performance and memory usage for the early pipeline steps.

load(data)[source]

Load input data to make it available to reduction steps.

Data files are loaded into new DRP DataFits objects. From these objects, the pipeline mode and steps are determined. The configuration file in the DRP package (plus any relevant date-specific or user overrides) is used to determine the default parameters for all pipeline steps.

After loading, headers are read from all input data and stored in the display_data attribute for display in the QAD header viewer. The raw data is not displayed.

Parameters:
datalist of str

Input data file names to be loaded.

load_step_packs()[source]

Load DRP pipeline step modules.

Returns:
step_classdict

All step classes available from the DRP. Keys are pipeline step names.

step_namedict

Names of all pipeline steps available from the DRP. Keys are pipeline step class names.

processing_stepsdict

Display names for pipeline steps. Keys are pipeline step names.

param_listsdict

DRP pipeline step parameter lists for all available steps. Keys are pipeline step names.

make_flats()[source]

Make nod or nod-pol flats from INT_CAL files.

This step is called before the main nod or nod-pol steps, when intcal files (FITS keyword CALMODE = INT_CAL) are loaded along with science files (CALMODE = UNKNOWN). It produces flat files in a location known to the science steps, for later use in the current reduction.

This super-step calls all steps defined for ‘mode_intcal’ in the DRP configuration, on all input files with mode ‘intcal’. At the end of the step, the input attribute is set to include all non-intcal files, for processing the normal science pipeline steps.

process_intcal()[source]

Process INT_CAL files for skycal generation.

This step is an alias for the make_flats step, given a separate name in order to assign different default parameters.

register_viewers()[source]

Instantiate viewers appropriate to the reduction.

This method instantiates and returns a QADViewer object, used to display data from this reduction in DS9. Data for the viewer is stored in the display_data attribute.

Returns:
list of Viewer

All viewers supported by this reduction object.

run_drp_step(step_name=None, use_param=True)[source]

Run a DRP pipeline step.

Pipeline steps are assumed to be implemented in a module of the name ‘step’ + step_name, in the sofia_redux.instruments.hawc.steps package. The step class name is stored in the step_class attribute.

The step class is imported, instantiated, then called on the data in the input attribute. If the data have not yet been loaded from disk, they are loaded at this time. If the pipeline step is a single-input step, it is called in a loop, once per input file. If it is a multi-input step, it is called once on all the input data.

Whether the output data is saved to disk or displayed after the step completes is controlled by a Redux parameter, applied to each step via the HAWCParameters class.

At the end of this method, output data are stored in the input attribute, so that they are available for the next processing step.

Parameters:
step_namestr, optional

Name of the step to run. If not provided, the current step_index will be used to retrieve the step from the recipe.

use_parambool, optional

If False, parameters from the Redux GUI will not be passed to the pipeline step. This is used for some sub-steps in the locally defined reduction steps.

Raises:
ValueError

If the pipeline step is not found in the sofia_redux.instruments.hawc.steps package, or it cannot be imported.

IOError

If an input file cannot be read.

set_display_data(display=False, auxout=None)[source]

Pass data in self.input to display.

Parameters:
displaybool, optional

If True, data should be displayed in DS9. If False, only the headers and auxout are displayed

auxoutlist of str, optional

If provided, will be passed to the QADViewer along with any headers or data the input attribute.

step(alt_method=None)[source]

Run a reduction step.

This method called the reduction step specified in the recipe attribute, at the current step_index. If the step index is out of range for the recipe, this method will just return.

For the HAWC pipeline, redux.Reduction.step is called with default parameters for any step that is defined locally. The parent method is called with alt_method='run_drp_step' for any step that is defined in the DRP package only.

Parameters:
alt_methodstr, optional

This parameter is ignored for HAWC reductions.

Returns:
str

An error message if the reduction step produced any errors; an empty string otherwise.