CorrelatedMode

class sofia_redux.scan.channels.mode.correlated_mode.CorrelatedMode(channel_group=None, gain_provider=None, name=None)[source]

Bases: Mode

Create a correlated mode operating on a given channel group.

A mode is an object that is applied to a given channel group, defining what constitutes its “gain” and how to operate thereon. This is also dependent on a gain provider.

The correlated mode normalizes gains by the typical gain magnitude. It also provides methods to update signals in an integration.

Parameters:
channel_groupChannelGroup, optional

The channel group owned by the mode.

gain_providerstr or GainProvider, optional

If a string is provided a FieldGainProvider will be set to operate on the given field of the channel group.

namestr, optional

The name of the mode. If not provided, will be determined from the channel group name (if available).

Methods Summary

get_gains([validate])

Return the normalized gain values of the correlated mode.

get_valid_channels()

Return a channel group containing channels not flagged by skip_flags.

normalize_gains([gain])

Normalizes the supplied (or contained) gains and returns the average.

set_channel_group(channel_group)

Apply a channel group to the correlated mode.

set_gains(gain[, flag_normalized])

Set the gain values of the mode.

update_signals(integration[, robust])

Update signals in an integration.

Methods Documentation

get_gains(validate=True)[source]

Return the normalized gain values of the correlated mode.

If no gains are available and no gain provider is available, will return an array of ones. The gains returned will always be normalized with respect to the typical gain values of the gain flagged channels.

Parameters:
validatebool, optional

If True (default), will cause the gain provider to “validate” the mode itself. This could mean anything and is dependent on the gain provider.

Returns:
gainsnumpy.ndarray (float)

The gain values.

get_valid_channels()[source]

Return a channel group containing channels not flagged by skip_flags.

Returns:
ChannelGroup
normalize_gains(gain=None)[source]

Normalizes the supplied (or contained) gains and returns the average.

If no gains are supplied, they are retrieved from the gain provider and normalized by the typical gain magnitude of the gain flagged channels. Note that if this is the case, the gain provider will store the normalized values. The average (normalization factor) is returned to the caller.

Note that unlike the parent Mode class, average gain values are those derived from channels only flagged by the gain type flag, not those that include the gain flag. However, no flagging of gain values will occur.

Parameters:
gainnumpy.ndarray (float), optional

The gain values to normalize.

Returns:
average_gainfloat

The average gain prior to normalization.

set_channel_group(channel_group)[source]

Apply a channel group to the correlated mode.

All channel flags except for the zero flag will be marked as flags to ignore by the correlated mode.

Parameters:
channel_groupChannelGroup
Returns:
None
set_gains(gain, flag_normalized=True)[source]

Set the gain values of the mode.

If a gain provider is available, it will be used to update the gain values, which could also update values in the channel group. Gains may be flagged depending on whether a gain range has been set (in the gain_range attribute). Note that any flagging will back propagate to the channel group and therefore, the channels themselves.

Correlated mode

Parameters:
gainnumpy.ndarray (float)

The new gain values to apply.

flag_normalizedbool, optional

If True, will flag gain values outside the gain range after normalizing to the average gain value of those previously flagged.

Returns:
flaggingbool

If gain flagging was performed. This does not necessarily mean any channels were flagged, just that it was attempted.

update_signals(integration, robust=False)[source]

Update signals in an integration.

If the integration does not contain the required signal, it will be added to the integration.

Parameters:
integrationIntegration
robustbool, optional

If True, update the signals using the “robust” (median) method. Otherwise, use a weighted mean.

Returns:
None