StepBgSubtract¶
- class sofia_redux.instruments.hawc.steps.stepbgsubtract.StepBgSubtract[source]¶
Bases:
StepMOParent
,BaseMap
Subtract residual background across multiple input files.
This step iteratively solves for additive offsets between the input files, then subtracts the offset from each flux image.
The input data expected is a DataFits with STOKES and ERROR frames for I, Q and U each, as well as COVAR Q I, COVAR U I, and COVAR Q U images. For total intensity data, only STOKES I and ERROR I are expected. Input is typically produced by the
sofia_redux.instruments.hawc.steps.StepCalibrate
pipeline step.The output image from this step contains the same image frames as the input image. The STOKES frames have been background corrected.
Methods Summary
Read a fwhm, radius, and cdelt value from the parameters.
resample_images
(radius, fit_order, ...[, ...])Resample input images into a common grid.
run
()Run the data reduction algorithm.
setup
()Set parameters and metadata for the pipeline step.
Methods Documentation
- read_fwhm_radius_cdelt()[source]¶
Read a fwhm, radius, and cdelt 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:
- fwhmfloat
FWHM value for the input data.
- radiusfloat, float, float
Radius value for the input data.
- cdeltfloat
Pixel scale value for the input data.
- resample_images(radius, fit_order, smoothing, edge, errflag, max_cores, separate=False)[source]¶
Resample input images into a common grid.
Resampling is performed via a distance-weighted, low-order polynomial surface fit to the input data within a window around each output grid point.
- Parameters:
- radiusfloat
Fit window to consider for local fits.
- fit_orderint
Polynomial surface order to fit.
- smoothingfloat
Smoothing radius for distance weighting, expressed as a fraction of the fit window.
- edgefloat
Threshold for setting edge pixels to NaN. Higher values block more pixels, a zero values allows all edge pixels through.
- errflagbool
If True, errors on the flux values will be used to weight the fits to the data. If False, only distance weights will be used.
- max_coresint, or None
If a number larger than 1, the data processing will proceed in parallel on max_cores CPUs. Multiprocessing requires that joblib is installed.
- separatebool, optional
If True, separate maps will be made for each input file (all on the same coordinate grid), and returned in a list of dictionaries. If False, a single map will be made, and stored in self.pmap
- Returns:
- list of dict
The map(s) generated from the input. Keys for the dictionary are the Stokes values and associated errors: I, dI for all; and Q, dQ, U, dU if more than one HWP is present.
- run()[source]¶
Run the data reduction algorithm.
Because this step is multi-in, multi-out (MIMO), self.datain must be a list of DataFits objects. The output is also a list of DataFits objects, stored in self.dataout.
The process is:
Read in all good pixels from the input data.
Make a map out of all input data for reference.
Make a map out of each input data file to compare to the reference.
Compute and subtract the average offset for all corresponding pixels, from the individual map to the reference map.
Repeat steps 2-4 until convergence or the maximum number of iterations is reached.
Store offset-subtracted images in self.dataout.
- setup()[source]¶
Set parameters and metadata for the pipeline step.
Output files have PRODTYPE = ‘bgsubtract’, and are named with the step abbreviation ‘BGS’.
Parameters defined for this step are:
- cdeltlist of float
Pixel size in arcseconds of output map. One value for each HAWC filter band.
- projstr
Projection of output map.
- sizelimitint
Upper limit on output map size (either axis, in pixels).
- fwhmlist of float
FWHM of gaussian smoothing kernel in arcseconds (per band).
- radiuslist of float
Integration radius for local fits, in arcseconds (per band).
- errflagbool
If set, use uncertainties when computing averages.
- widowstokesibool
Use widow pixels (flagged 1 or 2) to compute Stokes I map.
- edge_thresholdfloat
Threshold to set edge pixels to NaN. Range is 0-1; 0 means keep all edge pixels. Higher values keep fewer pixels.
- fit_orderint
Polynomial fit order for local regression.
- bgoffsetint
Maximum number of iterations of background subtraction.
- chauvenetbool
If set, use Chauvenet’s criterion (sigma clipping for outlier rejection) in background averages.
- fitflagbool
If set, use errors in intensity for weighting background averages.
- qubgsubtractbool
If set, apply background correction to Stokes Q and U images as well as Stokes I.