StepScanStokes¶
- class sofia_redux.instruments.hawc.steps.stepscanstokes.StepScanStokes[source]¶
Bases:
StepParent
Compute Stokes parameters for scanning polarimetry data.
This step derives Stokes I, Q, and U images with associated uncertainties and covariances from R and T array images.
Since the input data was produced by the scan map algorithm, it has already been resampled into sky coordinates. The R and T images for each HWP angle must be shifted into a common reference frame before addition and subtraction. Shift values are determined from the WCS values recorded in the extension headers, as output by
sofia_redux.instruments.hawc.steps.StepScanMapPol
. Shift interpolations are performed viasofia_redux.toolkit.image.adjust.shift
.Optionally, a zero-level correction may be applied to the R and T images, using a mean- or median-filter to identify the lowest negative region in the image.
Thereafter, R and T arrays are directly added and subtracted to produce Stokes parameter fluxes, as in the standard Stokes algorithm for chop-nod polarimetry data (see
sofia_redux.instruments.hawc.steps.StepStokes
).Input for this step must be a single DataFits that contains 3 image planes (HDUs) for each subarray (R0 and T0), at each of 4 HWP angles. The three images are: DATA, ERROR, and EXPOSURE. Output from this step is a DataFits with 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.
Methods Summary
correct_zero_level_auto
(r_data, t_data, ...)Correct image zero level from automatically determined regions.
correct_zero_level_region
(r_data, t_data, ...)Correct image zero level from specified circular regions.
Read a radius value from the parameters.
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.
wcs_shift
(header, refheader)Calculate the WCS shift between two headers.
Methods Documentation
- correct_zero_level_auto(r_data, t_data, method, radius)[source]¶
Correct image zero level from automatically determined regions.
Data arrays are updated in place.
- Parameters:
- r_dataarray-like
R data to correct.
- t_dataarray_like
T data corresponding to r_data.
- method{‘mean’, ‘median’}
Filter method.
- radiusint
Radius in pixels for filter kernel.
- correct_zero_level_region(r_data, t_data, method, reglist, refheader, robust=5.0)[source]¶
Correct image zero level from specified circular regions.
Data arrays are updated in place.
- Parameters:
- r_dataarray-like
R data to correct.
- t_dataarray_like
T data corresponding to r_data.
- method{‘mean’, ‘median’}
Statistics method.
- reglistlist of list of float
List of regions as [RA, Dec, radius] in degrees, matching length of r_data and t_data lists.
- refheaderastropy.Header
Reference header to use for WCS.
- robustfloat
Sigma value to use for clipping statistics. Set to 0 to turn off clipping.
- Raises:
- ValueError
If any specified region is not on the array.
- read_radius()[source]¶
Read a radius value from the parameters.
The parameters are 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:
- radiusfloat
Radius value for the input data.
- 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:
Check and gather all input data.
Shift all data to a common reference frame.
Compute Stokes I from R+T at all angles.
Compute Stokes Q and U from R-T at angles separated by 45 degrees.
Propagate 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.
- zero_level_method{‘mean’, ‘median’, ‘none’}
Statistic for zero-level calculation. If ‘none’, the zero-level will not be corrected. For the other options, either a mean or median statistic will be used to determine the zero-level value from the region set by the region parameters.
- zero_level_regionstr
If set to ‘header’, the zero-level region will be determined from the ZERO_RA, ZERO_DEC, ZERO_RAD keywords (for RA center, Dec center, and radius, respectively). If set to ‘auto’, a mean- or median-filter will be applied to the R and T images, with the radius specified by the zero_level_radius parameter. The lowest negative local average that is negative in both R and T for all HWP angles is assumed to be the zero level. R and T values are applied separately, from the value of the average at the same pixel. Otherwise, a region may be directly provided as a list of [RA center, Dec center, radius], in degrees.
- zero_level_radiuslist of float
Filter radius for zero-level calculation, in arcseconds (per band). Used only for zero_level_region = ‘auto’.
- zero_level_sigmafloat
Sigma value for statistics clipping. Ignored for zero_level_region = ‘auto’.
- 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:
- idx1
list
of int Index for angle 1.
- idx2
list
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.
- idx1
- 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.
- wcs_shift(header, refheader)[source]¶
Calculate the WCS shift between two headers.
- Parameters:
- headerfits.Header
The header for the data to shift.
- refheaderfits.Header
The reference header to shift to.
- Returns:
- shiftarray-like
The (x, y) shift to apply to the data associated with header (dx = shift[0], dy = shift[1]).