StepDmdPlot

class sofia_redux.instruments.hawc.steps.stepdmdplot.StepDmdPlot[source]

Bases: StepParent

Produce diagnostic plots for demodulated data.

This pipeline step produces a set of diagnostic plots from demodulated chop/nod data. For data that are not from the internal calibrator, the data is checked for possible door vignetting. For data that are from the internal calibrator, images of phase differences from expected values are displayed.

This step requires demodulated data as input, as produced by the sofia_redux.instruments.hawc.steps.StepDemodulate step. The input table should include columns for Chop Mask and Samples, RA, Dec, TrackErrAoi3, TrackErrAoi4, and either CentroidAoi or SofiaHkTrkAoi; R array, R array Imag, T array, T array Imag; CentroidExpMsec; HWP Angle, HWP Index and Nod Index.

The output from this step is identical to the input. As a side effect, a PNG file is saved to disk to the same base name as the input file, with ‘DPL’ replacing the product type indicator.

Methods Summary

calc_phase(real_part, imag_part, chop_freq, ...)

Calculate a phase image.

get_gapindex(timeseries[, thresh])

Find indices of time gaps above a threshhold.

run()

Run the data reduction algorithm.

setup()

Set parameters and metadata for the pipeline step.

sigma_mask(array[, sigma, iters])

Mask array along axis 0 using sigma-clipping and median.

Methods Documentation

calc_phase(real_part, imag_part, chop_freq, user_freq, phaseref=None)[source]

Calculate a phase image.

Parameters:
real_partarray-like

Array of real values.

imag_partarray-like

Array of imaginary values.

chop_freqfloat

Chopper frequency of the data.

user_freqfloat

User-specified frequency.

phaserefastropy.units.Quantity with units of degrees, optional

If specified, subtract this reference phase.

Returns:
phasearray of astropy.units.Quantity with units of degrees

Phase in degrees, in range -180 deg to 180 deg.

get_gapindex(timeseries, thresh=0.12)[source]

Find indices of time gaps above a threshhold.

Parameters:
timeseriesarray-like

Sorted array of times.

threshfloat, optional

Threshold for determining a gap.

Returns:
gapindexarray-like of int

index at which to insert None values to indicate gaps

run()[source]

Run the data reduction algorithm.

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

The process is:

  1. For all data types, plot the RA and Dec in one panel; TrackErrAoi3 and TrackErrAoi4 in another panel; HWP angle in yet another panel; and the sigma-clipped data values of the user-specified detector in the final panel. If present, CentroidAoi or SofiaHkTrkAoi are used to indicate which of TrackErrAoi3 and TrackErrAoi4 are active. Green shading indicates which samples will be passed by StepDmdCut; for this purpose, this step reads the StepDmdCut parameters from the configuration.

  2. For all data not taken with the internal calibrator, calculate the ratio of real to imaginary data in a 5x5 pixel box centered on the user-specified pixel used for plotting. The signals are sigma-clipped before the ratios of medians are computed. The values are output in a table at the upper left corner of the plot. If either the R ratio or T ratio exceeds the parameter door_threshold, warnings are output to the plot and to the logger that possible door vignetting may have occurred. In separate panels, CentroidExpMsec, and both Nod Index and HWP Index, are plotted.

  3. For data taken with the internal calibrator, images of the detector phase are plotted. If the ref_phase_file is specified, it is subtracted from the calculated phases. The algorithm includes these steps:

    • Discard the first and last chops and any NaN values, then calculate the mean along the first (time) axis of the R and T arrays, for both real and imaginary signals.

    • For each of R and T, compute -arctan2(imaginary, real) and convert to degrees.

    • Subtract the reference phase if it is provided.

    • Multiply by the ratio of 10.2 Hz to the value of ‘CHPFREQ’ in the file header (about 3 Hz).

    • Add or subtract multiples of 360 degrees to put values in the branch -180 degrees to +180 degrees

setup()[source]

Set parameters and metadata for the pipeline step.

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

Parameters defined for this step are:

door_thresholdfloat

Ratio of real to imaginary median stds, for door vignetting warnings.

detector_iint

i-location of detector pixel to plot.

detector_jint

j-location of detector pixel to plot.

data_sigmafloat

Value for sigma-clipping of detector data in computing averages.

data_itersint

Number of iterations for sigma-clipping.

ref_phase_filestr

Path to a FITS file containing reference phase values, for comparison with CALMODE = INT_CAL data. Set to ‘0.0’ to skip the comparison.

user_freqfloat

Expected chop frequency for science data. Used to compute phases in degrees from CALMODE = INT_CAL data.

phase_threshfloat

Threshold for phase outliers. Values above this number are ignored.

save_phasebool

If set, phase images are saved as FITS files to the input base name with ‘PHS’ replacing the product type indicator.

savefolderstr

Folder to save plots to. An empty string indicates the same folder as the input file.

sigma_mask(array, sigma=5, iters=3)[source]

Mask array along axis 0 using sigma-clipping and median.

Parameters:
arrayarray-like

Data array.

sigmafloat, optional

Threshold for sigma-clipping, with median.

itersint, optional

Number of iterations.

Returns:
msk_arraymasked array

Masked array with mask from sigma-clipping.