get_ml_correlated

sofia_redux.scan.signal.signal_numba_functions.get_ml_correlated(frame_data, frame_weights, frame_valid, channel_indices, channel_wg, channel_wg2, sample_flags, resolution)[source]

Derive the maximum-likelihood gain increments and weights.

The gain increments and associated weights are determined by performing an analysis of the parameters in blocks, the length of which are determined by resolution. While a resolution (r) of 1 is standard practice, higher values result in a downsampled set of increments. The increments for a single block (i) are calculated using the values between frames (f1 and f2) where:

f1 = i * r f2 = (i + 1) * r

The increment weight is given by:

increment_weight = sum_{ch}(sum_{f1}^{f2}(fw * cw * g^2))

where fw is the frame weight, cw is the channel weight, g is the channel gain and sum_{ch} is the sum over all channels. The gain increment is given by:

increment = sum_{ch}(sum_{f1}^{f2}(fw * cw * g * d) / increment_weight)

where d is the frame_data. Any invalid results are returned as zero values increments and increment weights.

Parameters:
frame_datanumpy.ndarray (float)

The frame data of shape (n_frames, all_channels).

frame_weightsnumpy.ndarray (float)

The array of frame relative weights of shape (n_frames,).

frame_validnumpy.ndarray (bool)

A boolean mask of shape (n_frames,) where False excludes a frame from any calculations or updates. Should include both invalid frames and modeling flags.

channel_indicesnumpy.ndarray (int)

An array of shape (n_channels,) mapping n_channels to all_channels.

channel_wgnumpy.ndarray (float)

An array of shape (n_channels,) containing the channel gains multiplied by the channel weights.

channel_wg2numpy.ndarray (float)

An array of shape (n_channels,) containing the channel gains^2 multiplied by the channel weights.

sample_flagsnumpy.ndarray (int)

An array of sample flags of shape (n_frames, all_channels) where any non-zero value excludes a data sample from being included in calculations.

resolutionint

The signal resolution (number of frames).

Returns:
gain_increments, gain_increment_weightsnumpy.ndarray, numpy.ndarray

The gain increments and weights, both float arrays of shape (n_frames // resolution,) that should be applied to the signal.