ScalingFactorComputer

class jwst.background.background_sub_wfss.ScalingFactorComputer(p=1.0, maxiter=5, delta_rms_thresh=0, dispersion_axis=None)[source]

Bases: object

Handle computation of scaling factor.

Parameters:
pfloat, optional

Percentile for sigma clipping on both low and high ends per iteration, default 1.0. For example, with p=2.0, the middle 96% of the data is kept.

maxiterint, optional

Maximum number of iterations for outlier rejection. Default 5.

delta_rms_threshfloat, optional

Stopping criterion for outlier rejection; stops when the rms residuals change by less than this fractional threshold in a single iteration. For example, assuming delta_rms_thresh=0.1 and a residual RMS of 100 in iteration 1, the iteration will stop if the RMS residual in iteration 2 is greater than 90. Default 0.0, i.e., ignore this and only stop at maxiter.

dispersion_axisint, optional

The index to select the along-dispersion axis. Used to compute the RMS residual, so must be set if rms_thresh > 0. Default None.

Methods Summary

__call__(sci, bkg, var[, mask])

Call function for the class.

err_weighted_mean(sci, bkg, var)

Remove any var=0 values, which can happen for real data.

Methods Documentation

__call__(sci, bkg, var, mask=None)[source]

Call function for the class.

Parameters:
scindarray

The science data.

bkgndarray

The reference background model.

varndarray

Total variance (error squared) of the science data.

maskndarray[bool], optional

Initial mask to be applied to the data, True where bad. Typically, this would mask out the real sources in the data.

Returns:
float

Scaling factor that minimizes sci - factor*bkg, taking into account residuals and outliers.

ndarray[bool]

Outlier mask generated by the iterative clipping procedure.

err_weighted_mean(sci, bkg, var)[source]

Remove any var=0 values, which can happen for real data.

Parameters:
scindarray

The science data.

bkgndarray

The reference background model.

varndarray

Total variance (error squared) of the science data.

Returns:
ndarray

New array with the weighted sum of array elements