flag_weights

sofia_redux.scan.channels.channel_numba_functions.flag_weights(channel_gain, channel_weight, channel_dof, channel_flags, min_weight, max_weight, exclude_flag, dof_flag, sensitivity_flag, default_weight)[source]

Flag channels according to degrees-of-freedom and weight.

Channels will be flagged with the DOF (degrees-of-freedom) flag if its degrees-of-freedom is <= 0, or unflagged otherwise. Channels will also be flagged for sensitivity if:

wg2 < m * min_weight
wg2 > m * max_weight

where wg2 = channel_weight * channel_gain^2, and:

m = exp(inner_80_percent_mean(ln(1 + wg2))) - 1

Channels that fall within the above range are likewise unflagged for sensitivity. Any channels that are fully or partially marked with the exclude flag will not be included in the mean calculation, but may have flags set. The sum of wg2 for all zero flagged channels will be returned.

Parameters:
channel_gainnumpy.ndarray (float)

The gains for each channel of shape (n_channels,).

channel_weightnumpy.ndarray (float)

The weights for each channel of shape (n_channels,). Weights are equivalent to 1/variance.

channel_dofnumpy.ndarray (float)

The degrees-of-freedom for each channel of shape (n_channels,).

channel_flagsnumpy.ndarray (int)

The flags for each channel of shape (n_channels,). Flags will be updated in place.

min_weightfloat

The minimum acceptable (1/variance) weight value.

max_weightfloat

The maximum acceptable (1/variance) weight value.

exclude_flagint

An integer flag marking channel flag types that should be excluded from the flagging, or overall weight/gain calculation.

dof_flagint

The integer marking channels flagged as having insufficient degrees-of- freedom.

sensitivity_flagint

The integer marking channels flagged as having unacceptable weight (variance) values based on whether it falls outside the min_weight to max_weight range.

default_weightfloat

The default weight value for channels. Any channel with a weight value equivalent to the default value will not be flagged or included in any calculations, as channels with this weight value will not have been processed due to other factors.

Returns:
n_points, weight_sum, channel_flagsint, float, numpy.ndarray (int)

n_points are the number of channels that have valid dof values, are not excluded by exclude_flag, and have positive non-default weight values. weight_sum is sum(weight * gain^2) for all zero-flagged channels (following unflagging), and channel_flags are the updated channel flags.