FlaggedDataGroup

class sofia_redux.scan.flags.flagged_data_group.FlaggedDataGroup(data, indices=None, name=None)[source]

Bases: FlaggedData

Create a subgroup of flagged data.

The FlaggedDataGroup object is a wrapper around the FlaggedData class, accessing only certain indices and may be used to access or modify those elements of the original 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:
dataFlaggedData

The data to reference.

indicesnumpy.ndarray (int), optional

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

namestr, optional

The name of the group.

Attributes Summary

fields

Return the available parent data fields.

fixed_indices

Return the fixed indices of parent class (copied to self).

flagspace

Return the flag space for the underlying FlaggedData object.

indices

Returns the parent reference indices.

protected_attributes

Protected attributes belong to the group, not the parent.

size

Return the size of the data group.

Methods Summary

apply_data(data)

Set the parent flagged data for the data group.

copy([full])

Return a copy of the ChannelGroup.

create_data_group([indices, name, ...])

Creates and returns a data group.

delete_indices(indices_or_mask)

Remove channels from the DataGroup.

discard_flag(flag[, criterion])

Given a flag, remove indices from the group data.

new_indices_in_old()

If reindexing occurs, returns the new indices on the old array.

reindex()

Validate channel indices with parent indices.

set_flags(flag[, indices])

Flag data with the supplied flag.

unflag([flag, indices])

Remove data flags.

Attributes Documentation

fields

Return the available parent data fields.

Returns:
set (str)
fixed_indices

Return the fixed indices of parent class (copied to self).

Returns:
numpy.ndarray (int)
flagspace

Return the flag space for the underlying FlaggedData object.

Returns:
Flags
indices

Returns the parent reference indices.

Returns:
numpy.ndarray (int)
protected_attributes

Protected attributes belong to the group, not the parent.

These are used to distinguish between internal and referenced attributes.

Returns:
set (str)
size

Return the size of the data group.

Returns:
sizeint

The number of referenced indices of the parent data.

Methods Documentation

apply_data(data)[source]

Set the parent flagged data for the data group.

Parameters:
dataFlaggedData or FlaggedDataGroup or object

If an object is supplied, it should have a ‘data’ attribute that is either FlaggedData or FlaggedDataGroup type.

Returns:
None
copy(full=False)[source]

Return a copy of the ChannelGroup.

Parameters:
fullbool, optional

If True, reference a hard copy of the channel data rather than a reference to allow for local rather than global alteration.

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

Creates and returns a data group.

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

Parameters:
indicesnumpy.ndarray (int), optional

The indices to reference. If not supplied, defaults to all indices in the parent FlaggedData object.

namestr, optional

The name of the group. If not supplied, defaults to the name of this FlaggedDataGroup.

discard_flagint or str or FlagTypes, optional

Flags to discard_flag from the new group.

keep_flagint or str or FlagTypes, optional

Keep data with these matching flags.

match_flagint or str or FlagTypes, optional

Keep only data with a flag exactly matching this flag.

Returns:
FlaggedDataGroup

A newly created data group.

delete_indices(indices_or_mask)[source]

Remove channels from the DataGroup.

Actual indices should be passed in. To delete based on fixed index values, please convert first using find_fixed_indices.

Note that since this a FlaggedDataGroup which is a reference to the FlaggedData, only the reference indices are removed, not the data in the parent.

Parameters:
indices_or_masknumpy.ndarray of (bool or int)

The indices to delete, or a boolean mask where True marks an element for deletion.

Returns:
None
discard_flag(flag, criterion=None)[source]

Given a flag, remove indices from the group data.

Since this is a FlaggedDataGroup object, only the reference indices are removed, not data in the parent FlaggedData object.

Parameters:
flagint or str or FlagTypes

The flag to discard_flag.

criterionstr, optional

One of {‘DISCARD_ANY’, ‘DISCARD_ALL’, ‘DISCARD_MATCH’, ‘KEEP_ANY’, ‘KEEP_ALL’, ‘KEEP_MATCH’}. *_ANY refers to any flag that is not zero (unflagged). *_ALL refers to any flag that contains flag, and *_MATCH refers to any flag that exactly matches flag. The default (None), uses DISCARD_ANY if flag is None, and DISCARD_ALL otherwise.

Returns:
None
new_indices_in_old()[source]

If reindexing occurs, returns the new indices on the old array.

Returns:
new_indicesnumpy.ndarray (int)
reindex()[source]

Validate channel indices with parent indices.

set_flags(flag, indices=None)[source]

Flag data with the supplied flag.

Modified to access parent flags.

Parameters:
flagint or str or Flags.flags

The flag to set.

indicesnumpy.ndarray (int), optional

The indices to flag. If not supplied, all data are flagged.

Returns:
None
unflag(flag=None, indices=None)[source]

Remove data flags.

Modified to access parent flags.

Parameters:
flagint or str or Flags.flags

The flag to remove. If not supplied, all data are unflagged.

indicesnumpy.ndarray (int), optional

The indices to flag. If not supplied, all data are flagged.

Returns:
None