StepMerge

class sofia_redux.instruments.hawc.steps.stepmerge.StepMerge[source]

Bases: StepMIParent, BaseMap

Create a map from multiple input images.

This step resamples all input data into a common output 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. It is assumed that all input files already contain the correct WCS.

Input files for this step must contain STOKES and ERROR frames for I, Q and U each, as well as COVAR Q I, COVAR U I, and COVAR Q U images. The output is a single file with the same extensions. In addition, an image mask is created, which gives some information on how much data went into each output pixel in the map. The values are sums over the Gaussian weight of each input data point. The EXPTIME keyword in the merged header is the sum of all exposure times from the individual files. The table values for each input image are stored in the rows of the MERGED DATA table in the output file.

Methods Summary

read_fwhm_radius_cdelt_beam()

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_beam()[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.

beamsizefloat

Beam size value for the input data.

resample_images(radius, fit_order, smoothing, edge, adaptive_threshold, adaptive_algorithm, fit_threshold, errflag, max_cores)[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. Output images are stored in self.pmap.

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.

adaptive_thresholdfloat

Threshold for adaptive smoothing. Range is 0-2; 1.0 is optimal. Set lower for smaller scale adaptive kernel; higher for larger scale.

adaptive_algorithm{‘scaled’, ‘shaped’, None}

Algorithm for adaptive smoothing kernel. If scaled, only the size is allowed to vary. If shaped, the kernel shape and rotation may also vary.

fit_thresholdfloat or None

Threshold for fit rejection, specified in sigma. Set to None to turn off.

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.

run()[source]

Run the data reduction algorithm.

This step is run as a multi-in single-out (MISO) step: self.datain should be a list of DataFits, and output will be a single DataFits, stored in self.dataout.

The process is:

  1. Read in all good pixels from the input data.

  2. Resample all input data into a common map.

  3. Store output images in a DataFits object.

  4. Merge headers and table data from all input files.

setup()[source]

Set parameters and metadata for the pipeline step.

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

Parameters defined for this step are:

beamsizelist of float

Beam FWHM size (arcsec) to write into BMAJ/BMIN header keywords. One value for each HAWC filter band.

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).

widowstokesibool

Use widow pixels (flagged 1 or 2) to compute Stokes I map.

conservefluxbool

If set, a flux conservation factor (due to the change in pixel size) will be applied to all output images.

fwhmlist of float

FWHM of gaussian smoothing kernel in arcseconds (per band).

radiuslist of float

Integration radius for local fits, in arcseconds (per band).

fit_orderint

Polynomial fit order for local regression.

errflagbool

If set, use uncertainties when computing averages.

edge_thresholdfloat

Threshold to set edge pixels to NaN. Range is 0-1; 0 means keep all edge pixels. Higher values keep fewer pixels.

adaptive_algorithm{‘scaled’, ‘shaped’, ‘none’}

If ‘shaped’ or ‘scaled’, adaptive smoothing will be used, varying the kernel size according to the data. If ‘shaped’, the kernel shape and rotation angle may also vary.

fit_thresholdfloat

Deviation from weighted mean to allow for higher order fit. Set to 0 to turn off. Positive values replace bad values with the mean value in the window; negative values replace bad values with NaN.

bin_cdeltbool

If set, and data was previously binned via StepBinPixels, then the input cdelt will be multiplied by the binning factor. If not set, the provided cdelt will be used directly. This allows useful default behavior for binned data, but still allows for tunable output pixel sizes.