StepStokes

class sofia_redux.instruments.hawc.steps.stepstokes.StepStokes[source]

Bases: StepParent

Compute Stokes parameters for chop/nod polarimetry data.

This step derives Stokes I, Q, and U images with associated uncertainties and covariances from R and T array images. If the data only has one HWP angle, then only Stokes I is computed.

Input for this step is a DataFits object, as produced by the sofia_redux.instruments.hawc.steps.StepNodPolSub pipeline step: R-T and R+T images for each HWP angle, with associated errors, and variance images for R and T arrays.

Output for this step contains the following image extensions: STOKES I, ERROR I, STOKES Q, ERROR Q, STOKES U, ERROR U, COVAR Q I, COVAR U I, COVAR Q U. Also, a table named TABLE DATA is created, and BAD PIXEL MASK is copied from the input file. For Nod-Pol data, the value of the initial HWP angle is saved as a header keyword (HWPINIT), to be read by sofia_redux.instruments.hawc.steps.StepRotate.

Notes

Stokes I is computed by averaging the R+T signal over all HWP angles (where N is the number of HWP angles):

\[I = \frac{1}{N} \sum_{\phi=1}^N (R+T)_{\phi}\]
\[\sigma_I = \frac{1}{N} \sqrt{\sum_{\phi=1}^N \sigma_{R+T,\phi}^2}.\]

The associated uncertainty in I is generally propagated from the previously calculated errors for R+T as above, but may be inflated by the median of the standard deviation of the R+T values across the HWP angles if necessary. In the most common case of four HWP angles at 0, 45, 22.5, and 67.5 degrees, Stokes Q and U are computed as:

\[Q = \frac{1}{2} [(R-T)_{0} - (R-T)_{45}]\]
\[U = \frac{1}{2} [(R-T)_{22.5} - (R-T)_{67.5}]\]

where \((R-T)_{\phi}\) is the differential R-T flux at the HWP angle \(\phi\). Uncertainties in Q and U are propagated from the input error values on R-T:

\[\sigma_Q = \frac{1}{2} \sqrt{\sigma_{R-T,0}^2 + \sigma_{R-T,45}^2}\]
\[\sigma_U = \frac{1}{2} \sqrt{\sigma_{R-T,22.5}^2 + \sigma_{R-T,67.5}^2}.\]

Covariances between the Stokes parameters are derived from the variances in R and T as follows:

\[\sigma_{QI} = \frac{1}{8} [\sigma_{R,0}^2 - \sigma_{R,45}^2 - \sigma_{T,0}^2 + \sigma_{T,45}^2]\]
\[\sigma_{UI} = \frac{1}{8} [\sigma_{R,22.5}^2 - \sigma_{R,67.5}^2 - \sigma_{T,22.5}^2 + \sigma_{T,67.5}^2]\]

The covariance between Q and U (\(\sigma_{QU}\)) is zero at this stage, since they are derived from data for different HWP angles.

Methods Summary

run()

Run the data reduction algorithm.

setup()

Set parameters and metadata for the pipeline step.

stokes(idx1, idx2, rmt_data, rmt_sigma, ...)

Compute stokes Q and U.

Methods Documentation

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. Compute Stokes I from R+T at all angles. Propagate or recalculate errors on Stokes I.

  2. Compute Stokes Q and U from R-T at angles separated by 45 degrees. Propagate associated errors and covariances.

setup()[source]

Set parameters and metadata for the pipeline step.

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

Parameters defined for this step are:

hwp_tolfloat

Tolerance for difference from expected values for HWP angles. HWP angles for Stokes parameters must differ by no more than 45 +/- hwp_tol degrees.

erristr

Inflation method for Stokes I errors. May be ‘median’, ‘mean’, or ‘none’.

erripolmethodstr

Method for calculating Stokes I error. Options are ‘hwpstddev’, to compute them as a standard deviation across the HWP angles, or ‘meansigma’, to propagate them from the input errors (recommended).

removeR1stokesibool

If set, the R1 subarray for Stokes I is removed from the output.

override_hwp_orderbool

If set, then the first two HWP angles will be used for Q, last two for U, regardless of value. This is necessary in the case where the HWP value is incorrectly recorded, but the HWP position as observed was correct.

stokes(idx1, idx2, rmt_data, rmt_sigma, r_var, t_var)[source]

Compute stokes Q and U.

The index parameters control which Stokes parameter image is computed

Parameters:
idx1list of int

Index for angle 1.

idx2list of int

Index for angle 2.

rmt_dataarray-like

R - T flux data array. Should have three dimensions, where the first dimension indexes the HWP angle.

rmt_sigmaarray-like.

R - T error data array. Dimensions should match rmt_data.

r_vararray-like

Variance for the R array. Dimensions should match rmt_data.

t_vararray-like

Variance for the T array. Dimensions should match rmt_data.

Returns:
stokesarray-like

The Stokes Q or U flux image.

dstokesarray-like

The error on the Stokes Q or U flux.

stokes_icovarray-like

The covariance on the Stokes Q or U image, with respect to the Stokes I image.