StepIP¶
- class sofia_redux.instruments.hawc.steps.stepip.StepIP[source]¶
Bases:
StepParent
Remove instrumental polarization from Stokes images.
This step subtracts instrumental polarization in the detector frame, either with a different value for each detector pixel, or with a uniform value assigned to all pixels.
Input for this step is DataFits containing Stokes and Error images for each of I, Q, and U, as well as COVAR Q I and COVAR U I images, a bad pixel image, and a table of data.
This step is typically run after
sofia_redux.instruments.hawc.steps.StepWcs
and beforesofia_redux.instruments.hawc.steps.StepRotate
. Output from this step contains the same extensions as the input, with values modified for the Stokes Q and U images, along with their associated error and covariance images.Notes
The correction is applied as
\[Q' = Q - q' I\]\[U' = U - u' I\]and propagated to the associated error and covariance images as
\[\sigma_Q' = \sqrt{\sigma_Q^2 + (q' \sigma_I)^2 + 2q'\sigma_{QI}}\]\[\sigma_U' = \sqrt{\sigma_U^2 + (u' \sigma_I)^2 + 2u'\sigma_{UI}}\]\[\sigma_{Q'I} = \sigma_{QI} - q' \sigma_I^2\]\[\sigma_{U'I} = \sigma_{UI} - u' \sigma_I^2\]\[\sigma_{Q'U'} = -u' \sigma_{QI} - q' \sigma_{UI} + qu\sigma_I^2.\]Note that the input \(\sigma_{QU}\) is assumed to be identically zero, since this correction is applied before rotation of the Q and U parameters.
Methods Summary
fill_nan_median
(array)Fill in NaNs in an array with its median value.
read_file_ip
(fileip)Read IP values from a file.
read_ip
()Read IP q and u values from the parameters.
run
()Run the data reduction algorithm.
setup
()Set parameters and metadata for the pipeline step.
Methods Documentation
- fill_nan_median(array)[source]¶
Fill in NaNs in an array with its median value.
- Parameters:
- arrayarray-like
The array to process.
- Returns:
- array-like
The array with NaN values replaced.
- read_file_ip(fileip)[source]¶
Read IP values from a file.
Extract correct arrays given the observing wavelength, and return them. For waveband X, the file must contain extensions ‘IP q band X’, ‘Error IP q band X’, ‘IP u band X’, and ‘Error IP u band X’.
- Parameters:
- fileipstr
Path to an IP FITS file.
- Returns:
- qiarray-like
IP q value matching the input data.
- uiarray-like
IP u value matching the input data.
- eqiarray-like
Error on the IP q value.
- euiarray-like
Error on the IP u value.
- bandstr
Filter band name.
- read_ip()[source]¶
Read IP q and u values 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:
- qifloat
IP q value for the input data.
- uifloat
IP u 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:
Determine the IP correction from the parameters.
Apply it to Q and U images, and propagate errors and covariances.
- setup()[source]¶
Set parameters and metadata for the pipeline step.
Output files have PRODTYPE = ‘ip’, and are named with the step abbreviation ‘IPS’.
Parameters defined for this step are:
- qinstlist of float
Fractional instrumental polarization in q (one value for each waveband).
- uinstlist of float
Fractional instrumental polarization in u (one value for each waveband).
- fileipstr
If set to ‘uniform’, then the qinst and uinst values will be applied uniformly to all pixels. Otherwise, this parameter is expected to be a path to a FITS file containing IP values for each pixel, at each waveband.