CorrelatedSignal¶
- class sofia_redux.scan.signal.correlated_signal.CorrelatedSignal(integration, mode)[source]¶
Bases:
Signal
Initialize a correlated signal.
The correlated signal is used to extract a signal from the integration defined by the supplied correlated mode. The mode defines a set of instrument channels, and how gain should be determined from them.
- Parameters:
- integrationsofia_redux.scan.integration.integration.Integration
The integration to which this signal belongs.
- modesofia_redux.scan.channels.mode.correlated_mode.CorrelatedMode
The correlated modality mode for this signal.
Methods Summary
Update the source filtering of the signal.
copy
()Return a copy of the signal.
Differentiate the signal values and weights in-place.
Return a differentiated copy of the signal.
Get the signal as it would appear translated to the frame data.
Return an integrated copy of the signal.
get_mean
()Return the mean signal value and weight.
Return the median signal value and weight.
get_ml_correlated
(channel_group[, ...])Get the maximum-likelihood correlated gain increment and weight.
Return the degrees of freedom for the signal.
get_robust_correlated
(channel_group[, ...])Get the median derived correlated gain increment and weight.
Return the signal variance.
Integrate the signal values and weights in-place.
level
([start_frame, end_frame, robust])Remove the mean value from the signal values.
update
([robust])Update the frame data by the signal.
weight_at
(frame)Return the weight at a given frame index.
Methods Documentation
- calc_filtering()[source]¶
Update the source filtering of the signal.
Where phi is the channel dependents, they are updated by:
phi = mean(phi + phi * channel_overlaps)
The signal source filtering is set to 1 - phi. The channel source filtering has the prior correction undone, and then updated as:
csf *= signal source filtering.
- Returns:
- None
- differentiate()[source]¶
Differentiate the signal values and weights in-place.
Note that the spacing between sample values is assumed to be in seconds when calculating the gradient.
- Returns:
- None
- get_frame_data_signal()[source]¶
Get the signal as it would appear translated to the frame data.
- Returns:
- frame_data_signalnumpy.ndarray (float)
The signal contribution to the frame data of shape (n_frames, n_channels).
- get_median()[source]¶
Return the median signal value and weight.
- Returns:
- median, median_weightfloat, float
- get_ml_correlated(channel_group, modeling_frames=None)[source]¶
Get the maximum-likelihood correlated gain increment and weight.
The gain increments are given as:
dC_s = sum_{f | s}{w_f * sum_{c} {w_c g_c d_{f,c}} / dW_s
where dW_s is the gain increment weight given by
dW_s = sum_{f | s}{w_f} sum_{c} {w_c g_c^2}
Here {f | s} indicate the frames in each signal block, w_f is the frame weight, w_c is the channel_weight, g_c is the channel gain, and d_{f, c} is the frame data value for frame f and channel c.
- Parameters:
- channel_groupChannelGroup
- modeling_framesnumpy.ndarray (bool), optional
A boolean mask where
True
indicates that a frame is used for modeling and should be excluded from the calculations.
- Returns:
- gain_increment, increment_weightnumpy.ndarray, numpy.ndarray
The gain increments and associated weights both of shape (n_signal,) or (n_frames // self.resolution).
- get_parms()[source]¶
Return the degrees of freedom for the signal.
The degrees of freedom are given as
DOF = number_of(weights > 0) * (1 - 1/drift_n)
- Returns:
- float
- get_robust_correlated(channel_group, modeling_frames=None, max_dependence=0.25)[source]¶
Get the median derived correlated gain increment and weight.
Derived in a very similar way to the
get_ml_correlated
method except replacing the mean operation with a median. Please seesnf.get_robust_correlated()
for further details.- Parameters:
- channel_groupChannelGroup
- modeling_framesnumpy.ndarray (bool), optional
A boolean mask where
True
indicates that a frame is used for modeling and should be excluded from the calculations.- max_dependencefloat, optional
- Returns:
- gain_increment, increment_weightnumpy.ndarray, numpy.ndarray
The gain increments and associated weights both of shape (n_signal,) or (n_frames // self.resolution).
- get_variance()[source]¶
Return the signal variance.
The signal variance is returned as:
v = sum(w * x^2) / sum(w)
where x are the signal values and w are the signal weights.
- Returns:
- variancefloat
- integrate()[source]¶
Integrate the signal values and weights in-place.
Note that the spacing between sample values is assumed to be in seconds. The
is_floating
attribute is set toTrue
following this operation indicating that the integrated signal has an arbitrary DC offset.- Returns:
- None
- level(start_frame=None, end_frame=None, robust=False)[source]¶
Remove the mean value from the signal values.
The mean signal between a given start and end frame is calculated and subtracted from the signal. This value is returned to the user.
- Parameters:
- start_frameint, optional
The starting frame from which to level. The default is the first frame (0).
- end_frameint, optional
The last frame from to level (non-inclusive). The default is the total number of frames.
- robustbool, optional
If
True
, subtract the median value rather than the mean.
- Returns:
- averagefloat
The average signal value that was removed.