get_covariance

sofia_redux.scan.signal.signal_numba_functions.get_covariance(signal_values, frame_data, frame_valid, channel_indices, channel_weights, sample_flags)[source]

Return the signal covariance for samples in frames/channel.

The signal covariance is given as:

C = sum_{channels}(xs * xs) / sum_{channels}(ss * xx)

where xs = sum_{frames}(w * x * s), ss = sum_{frames}(w * s * s), and xx = sum_{frames}(w * x * x). Here w is the channel weight, s is the signal value for each frame, and x are the frame data values.

Parameters:
signal_valuesnumpy.ndarray (float)

The signal values of shape (n_frames,). Note that these values should be at the same resolution as frame_data.

frame_datanumpy.ndarray (float)

The frame data of shape (n_frames, all_channels).

frame_validnumpy.ndarray (bool)

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

channel_indicesnumpy.ndarray (int)

The channel indices to include in the covariance calculation of shape (n_channels,). Should map n_channels -> all_channels for frame and sample data.

channel_weightsnumpy.ndarray (float)

The channel weights of shape (n_channels,).

sample_flagsnumpy.ndarray (int)

The sample flags of shape (n_frames, n_channels). Any non-zero value will not be included in the covariance calculation.

Returns:
covariancefloat