level_block

sofia_redux.scan.custom.hawc_plus.integration.hawc_integration_numba_functions.level_block(from_frame, to_frame, frame_valid, frame_data, frame_weights, modeling_frames, frame_parms, sample_flags, exclude_sample_flag, channel, channel_parms, skip_start=0, skip_end=0)[source]

Level a frame block for a given channel.

For a given channel i, all frames that are valid (but may be modeling frames) will be corrected by:

d[f:t, i] -= sum_{f|nm}(w[f] * d[f]) / w_sum

w_sum = sum_{f|nm}(w[f])

Where f is the from_frame, t is the to_frame, d are the frame_data, w are the frame_weights, and f|nm are the set of frames in the range t:f that are valid and non-modeling frames.

If w_sum > 0 then the channel dependents are incremented by 1 and the frame dependents for frame j are updated by:

dp[j] += w[j] / w_sum

if j is valid, non-modeling and the associated sample flag is not excluded by exclude_sample_flag.

Parameters:
from_frameint

The starting frame from which to begin jump correction.

to_frameint

The end frame (non-inclusive) at which to conclude jump correction.

frame_validnumpy.ndarray (bool)

A boolean mask of shape (n_frames,) where False excludes a frame from any processing.

frame_datanumpy.ndarray (float)

The frame data values of shape (n_frames, all_channels).

frame_weightsnumpy.ndarray (float)

The relative frame weights of shape (n_frames,).

modeling_framesnumpy.ndarray (bool)

A boolean mask of shape (n_frames,) where True marks a frame as a modeling frame. Modeling frames will still be levelled, but will not be included when updating the frame or channel dependents.

frame_parmsnumpy.ndarray (float)

The frame dependents of shape (n_frames,). Will be updated in-place.

sample_flagsnumpy.ndarray (int)

The frame data sample flags. Any samples flagged with exclude_sample_flag will not be included in the mean value calculation or contribute to the frame dependents. However, the mean value will still be subtracted from them.

exclude_sample_flagint

The sample flag to explicitly exclude from processing.

channelint

The channel to process.

channel_parmsnumpy.ndarray (float)

The channel dependents of shape (all_channels,). Will be updated in-place.

skip_startint, optional

The number of frames to flag in the sample flags prior to a jump detection with jump_flag.

skip_endint, optional

The number of frames to flag in the sample flags following a jump detection with jump_flag.

Returns:
None