ChannelGroup

class sofia_redux.scan.channels.channel_group.channel_group.ChannelGroup(channel_data, indices=None, name=None)[source]

Bases: FlaggedDataGroup, ChannelData

Create a channel group from channel data.

A channel group is a subset of channels from the original channel data. The ChannelGroup object is a wrapper around the ChannelData class, accessing only certain channel indices and may be used to access or modify those elements of the original channel data. However, due to the nature of indexing in numpy arrays, for value writing operations, the entire field must be modified at one. For example self.gain[0]=1.234 will not result in any values being set. To modify values, use self.gain=<new_array> or self.gain = <value> where <value> can be broadcast to the parent array.

Parameters:
channel_dataChannelData or ChannelGroup or object

The channel data to reference. If an object is supplied, it’s ‘data’ attribute must contain ChannelData or ChannelGroup.

indicesnumpy.ndarray (int), optional

The indices of ChannelData that will belong to the ChannelGroup. If no indices are supplied, the entire ChannelData will be referenced.

namestr, optional

The name of the ChannelGroup.

Methods Summary

add_dependents(values)

Add dependent values for given indices.

copy()

Return a copy of the channel group.

create_group([indices, name, keep_flag, ...])

Creates and returns a channel group.

read_channel_data_file(filename)

Read a channel data file and return the information within.

read_pixel_data(filename)

Read a pixel data file and apply the results.

remove_dependents(values)

Subtract dependent values for given indices.

set_channel_data(index, channel_info)

Set the channel info for a selected index.

set_flag_defaults()

Sets data values based on currently set flags.

validate_pixel_data()

Validates data read from the pixel data file.

validate_weights()

Validates weight data.

Methods Documentation

add_dependents(values)[source]

Add dependent values for given indices.

Parameters:
valuesnumpy.ndarray (float)
Returns:
None
copy()[source]

Return a copy of the channel group.

Returns:
ChannelGroup
create_group(indices=None, name=None, keep_flag=None, discard_flag=None, match_flag=None)[source]

Creates and returns a channel group.

A channel group is a referenced subset of the channel data. Operations performed on a channel group will be applied to the original channel data.

Parameters:
indicesnumpy.ndarray (int), optional

The indices to reference. If not supplied, defaults to all channels.

namestr, optional

The name of the channel group. If not supplied, defaults to the name of the channel data.

discard_flagint or str or ChannelFlagTypes, optional

Flags to discard_flag from the new group.

keep_flagint or str or ChannelFlagTypes, optional

Keep channels with these matching flags.

match_flagint or str or ChannelFlagTypes, optional

Keep only channels with a flag exactly matching this flag.

Returns:
ChannelGroup

A newly created channel group.

abstract read_channel_data_file(filename)[source]

Read a channel data file and return the information within.

Note that this should be defined in the parent ChannelData class, not in one of the ChannelGroup classes. Since the groups inherit from the data classes, this method is only here to avoid abstract method warnings.

Parameters:
filenamestr

The path to a channel data file.

Returns:
channel_infopandas.DataFrame
read_pixel_data(filename)[source]

Read a pixel data file and apply the results.

Parameters:
filenamestr

File path to the pixel data file.

Returns:
None
remove_dependents(values)[source]

Subtract dependent values for given indices.

Parameters:
valuesnumpy.ndarray (float)
Returns:
None
set_channel_data(index, channel_info)[source]

Set the channel info for a selected index.

Parameters:
indexint

The channel index for which to set new data.

channel_infodict

A dictionary of the form {field: value} where. The attribute field at ‘index’ will be set to value.

Returns:
None
set_flag_defaults()[source]

Sets data values based on currently set flags.

Returns:
None
validate_pixel_data()[source]

Validates data read from the pixel data file.

Returns:
None
validate_weights()[source]

Validates weight data.

Returns:
None