fix_jumps¶
- sofia_redux.scan.custom.hawc_plus.integration.hawc_integration_numba_functions.fix_jumps(frame_valid, frame_data, frame_weights, modeling_frames, frame_parms, sample_flags, exclude_sample_flag, channel_indices, channel_parms, min_jump_level_frames, jump_flag, fix_each, fix_subarray, has_jumps, subarray, jump_counter, start_frame=None, end_frame=None, flag_before=0, flag_after=0)[source]¶
Detect and fix jumps in the frame data for each channel.
If a given channel has jumps and settings imply that jumps may be fixed, the average frame data level between the jump is subtracted (frame and channel dependents are also updated). A change in the jump level occurs when the
jump_counter
value for a given channel changes to a new value. a block is defined as all frames having the same jump value before a jump change.If the number of frames in a block is less than
min_jump_level_frames
, those frames will be flagged with thejump_flag
sample flag. Otherwise, the frame data will be levelled as described above.- Parameters:
- 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. Will be updated in-place if levelling occurs.
- sample_flagsnumpy.ndarray (int)
The frame data sample flags. Typically non-zero samples will be excluded from processing. However, those samples not flagged with only
exclude_sample_flag
will be included.- exclude_sample_flagint
The sample flag to explicitly exclude from processing.
- channel_indicesnumpy.ndarray (int)
The channel indices of shape (n_channels,) indicating which channels to process and mapping n_channels onto all_channels.
- channel_parmsnumpy.ndarray (float)
The channel dependents of shape (all_channels,). Will be updated in-place when levelling occurs.
- min_jump_level_framesint
The minimum number of frames in a jump block required for levelling. If this value is not reached, all samples in the block are flagged with
jump_flag
instead.- jump_flagint
The integer flag identifier with which to flag samples if the jump block length to which they belong is less than
min_jump_level_frames
and cannot be levelled.- fix_eachbool
If
False
, do not fix any channel with jumps.- fix_subarraynumpy.ndarray (bool)
An array of shape (n_subarrays,) where
True
indicates that any channel belonging to that subarray should have jumps corrected. Ignored if fix_each is False.- has_jumpsnumpy.ndarray (bool)
A boolean mask of shape (n_channels,) where
True
indicates that a channel has jumps that may be corrected.- subarraynumpy.ndarray (int)
An array of shape (n_channels,) containing the subarray number for each channel.
- jump_counternumpy.ndarray (int)
The channel jumps of shape (n_frames, n_channels).
- start_frameint, optional
The start frame from which to begin correction. The default is the first frame (0).
- end_frameint, optional
The last frame at which to conclude correction (non-inclusive). The default is the total number of frames (n_frames).
- flag_beforeint, optional
The number of frames to flag in the sample flags prior to a jump detection with
jump_flag
.- flag_afterint, optional
The number of frames to flag in the sample flags following a jump detection with
jump_flag
.
- Returns:
- no_jumpsnumpy.ndarray (bool)
A boolean mask of shape (n_channels,) where
True
indicates that a channel has no jumps.