ChannelData¶
- class sofia_redux.scan.channels.channel_data.channel_data.ChannelData(channels=None)[source]¶
Bases:
FlaggedData
Initialize channel data.
The channel data is a
FlaggedData
collection containing parameters relating to each individual channel (pixel or detector) of a given instrument.- Parameters:
- channelssofia_redux.scan.channels.channels.Channels
Attributes Summary
Return the configuration for the channel data.
Return the default values for the channel attributes.
Return the instrument information object.
Return attributes that should be referenced rather than copied.
Methods Summary
add_dependents
(dependents)Add dependents to channel data.
apply_info
(info)Apply scan/instrument information to the channels.
calculate_overlap_values
(overlap_distances, ...)Calculates the overlap values based on overlap distances.
calculate_overlaps
(point_size[, maximum_radius])Calculates the overlaps between channels.
Remove all overlap values.
flag_channel_list
(channel_list)Flag channels as DEAD from a list of channel ranges/fixed indices.
flag_field
(field, specs)Given a data field name and list of specifications, flag as DEAD.
flag_fields
(fields)Flags elements in various data fields as dead based on data values.
Flattens weight according to gain^2.
get_filtering
(integration)Return the filtering for a given integration.
get_mapping_pixels
([indices, name, ...])Creates and returns mapping pixels.
get_overlap_distances
(overlap_indices)Calculates the overlap distances.
get_overlap_indices
(radius)Return a cross-array indicating overlapping indices.
Return the number of pixels in the arrangement.
Return the pixels in the arrangement.
get_rcp_string
([indices])Return a string representation for the RCP of ALL channels.
get_typical_gain_magnitude
(gains[, ...])Return the mean gain value of data.
Returns a ChannelData instance for a given instrument.
kill_channels
([flag])Given a flag, sets all matching elements to DEAD only flag status.
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.
read_wiring_data
(filename)remove_dependents
(dependents)Remove dependents from channel data.
set_blind_channels
(fixed_indices)Set BLIND flag for elements based on fixed indices.
set_channel_data
(index, channel_info)Set the channel info for a selected index.
Sets data values based on currently set flags.
set_hardware_gain
(info)Set the hardware gain attribute from the supplied info object.
set_parent
(channels)Set the parent channels of the channel data.
set_uniform_gains
([field])Sets the gain and coupling to 1.0 for all channels.
to_string
([indices, frame])Return a string representation of channels.
Validates data read from the pixel data file.
Validates weight data.
Attributes Documentation
- configuration¶
Return the configuration for the channel data.
- Returns:
- Configuration
- default_field_types¶
Return the default values for the channel attributes.
These are used during the initial creation of the data arrays to populate each of the attribute arrays with a default value. The field types are returned as a dictionary {attribute (str): value}. If a simple initialized value is supplied, that attribute of the data will default to a numpy array filled with that value. Other options are:
- (value, shape): will create arrays of shape (n, shape,) filled with value. - type or class: will create empty arrays of the given type
Special handling are provided for
units.Quantity
,units.Unit
and thesofia_redux.scan.coordinate_systems.coordinate.Coordinate
classes. For the coordinate type classes, a field value also may be provided as (class, value, shape) to create filled coordinates of shape (n, shape,) with the value. Here, n is the size of the data.- Returns:
- defaultsdict
A dictionary of the form {name (str): value}.
- info¶
Return the instrument information object.
- Returns:
- Info
- referenced_attributes¶
Return attributes that should be referenced rather than copied.
- Returns:
- set (str)
Methods Documentation
- add_dependents(dependents)[source]¶
Add dependents to channel data.
- Parameters:
- dependentsnumpy.ndarray (float)
- Returns:
- None
- apply_info(info)[source]¶
Apply scan/instrument information to the channels.
- Parameters:
- infoInfo
- Returns:
- None
- calculate_overlap_values(overlap_distances, point_size)[source]¶
Calculates the overlap values based on overlap distances.
The overlap values are stored in the
overlaps
attribute values. This should be a csr_sparse matrix of shape (n_channels, n_channels) where overlaps[i, j] gives the overlap value between channels i and j.- Parameters:
- overlap_distancesscipy.sparse.csr.csr_matrix (float)
A Compressed Sparse Row (CSR) matrix of shape (channels, channels) where distances[i, j] gives the distance between channels i and j. These float values should be converted to units of
point_size
.- point_sizeastropy.units.Quantity
The point size for calculating the overlaps. Typically, the beam FWHM.
- Returns:
- None
- calculate_overlaps(point_size, maximum_radius=2.0)[source]¶
Calculates the overlaps between channels.
The overlap array (in the
overlaps
attribute) is a csr_sparse array of shape (n_channels, n_channels) where overlaps[i, j] givens the overlap value of channel j from the channel i.- Parameters:
- point_sizeastropy.units.Quantity
The point size for calculating the overlaps. Typically, the beam FWHM.
- maximum_radiusfloat, optional
The maximum radius in units of
point_size
to search for channel overlaps.
- Returns:
- None
- flag_channel_list(channel_list)[source]¶
Flag channels as DEAD from a list of channel ranges/fixed indices.
- Parameters:
- channel_listlist or str
If provided as a string, elements should be comma delimited. Each element can be an int or string specifying fixed indices to flag. Note that ranges can be specified via ‘min:max’ or ‘min-max’.
- Returns:
- None
- flag_field(field, specs)[source]¶
Given a data field name and list of specifications, flag as DEAD.
The specifications may define a single value or range of values. Any data value within that range or equal to a specified value will be flagged as dead.
- Parameters:
- fieldstr
The data field name.
- specslist of str
Each element may contain a single value or range of values (marked by lower-upper or lower:upper) that should be flagged as dead.
- Returns:
- None
- flag_fields(fields)[source]¶
Flags elements in various data fields as dead based on data values.
- Parameters:
- fieldsdict
A dictionary where keys should define a data field name, and values are lists of str where each element defines a value or range of values (min:max, or min-max) that should be flagged as dead for the given field.
- Returns:
- None
- flatten_weights()[source]¶
Flattens weight according to gain^2.
Does not include hardware gains.
- Returns:
- None
- get_filtering(integration)[source]¶
Return the filtering for a given integration.
- Parameters:
- integrationIntegration
- Returns:
- filteringnumpy.ndarray (float)
- abstract get_mapping_pixels(indices=None, name=None, keep_flag=None, discard_flag=None, match_flag=None)[source]¶
Creates and returns mapping pixels.
- 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:
- Group
A newly created channel group.
- abstract get_overlap_distances(overlap_indices)[source]¶
Calculates the overlap distances.
The overlap distances are stored in the
overlaps
attribute values. This should be a csr_sparse matrix of shape (n_channels, n_channels) where overlaps[i, j] gives the distance between channel i and channel j.- Parameters:
- overlap_indicesscipy.sparse.csr.csr_matrix (bool)
A Compressed Sparse Row (CSR) matrix of shape (channels, channels) where a
True
value for overlap_indices[i, j] signals that channeli
overlaps with the channelj
.
- Returns:
- distances, unitscipy.sparse.csr.csr_matrix, astropy.units.Unit
distances
is a Compressed Sparse Row (CSR) matrix of shape (channels, channels) and of float type where distances[i, j] gives the distance between channels i and j.unit
gives the distance unit.
- abstract get_overlap_indices(radius)[source]¶
Return a cross-array indicating overlapping indices.
- Parameters:
- radiusastropy.units.Quantity
The maximum radius about which to include overlaps.
- pixel_xy_sizeastropy.units.Quantity (numpy.ndarray)
The pixel (x, y) size.
- Returns:
- overlap_indicesscipy.sparse.csr.csr_matrix (bool)
A Compressed Sparse Row (CSR) matrix of shape (channels, channels) where a
True
value for overlap_indices[i, j] signals that channeli
overlaps with the channelj
.
- abstract get_pixel_count()[source]¶
Return the number of pixels in the arrangement.
- Returns:
- pixelsint
- get_rcp_string(indices=None)[source]¶
Return a string representation for the RCP of ALL channels.
- Parameters:
- indicesnumpy.ndarray or slice, optional
The channel indices (not fixed) to return. The default is all channels.
- Returns:
- str
- get_typical_gain_magnitude(gains, keep_flag=None, discard_flag=None, match_flag=None)[source]¶
Return the mean gain value of data.
The mean value may be calculated given a number of flag criteria. The outer 10% of log(1 + |gain|) are excluded from the mean calculation.
- Parameters:
- gainsnumpy.ndarray (float)
- keep_flagint or ChannelFlagTypes, optional
Flag values to keep in the calculation.
- discard_flagint or ChannelFlagTypes, optional
Flag values to discard_flag from the calculation.
- match_flagint or ChannelFlagTypes, optional
Only matching flag values will be used in the calculation.
- Returns:
- meanfloat
The mean gain value.
- classmethod instance_from_instrument_name(name)[source]¶
Returns a ChannelData instance for a given instrument.
- Parameters:
- namestr
The name of the instrument.
- Returns:
- ChannelData
- kill_channels(flag=None)[source]¶
Given a flag, sets all matching elements to DEAD only flag status.
- Parameters:
- flagint or ChannelFlagTypes
- Returns:
- None
- abstract read_channel_data_file(filename)[source]¶
Read a channel data file and return the information within.
- 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(dependents)[source]¶
Remove dependents from channel data.
- Parameters:
- dependentsnumpy.ndarray (float)
- Returns:
- None
- set_blind_channels(fixed_indices)[source]¶
Set BLIND flag for elements based on fixed indices.
Will kill (set flag to only DEAD) any previously defined BLIND channels. All new blinded channels will only have the BLIND flag.
- Parameters:
- fixed_indicesnumpy.ndarray of int
- 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_hardware_gain(info)[source]¶
Set the hardware gain attribute from the supplied info object.
- Parameters:
- infoInfo
- Returns:
- None
- set_parent(channels)[source]¶
Set the parent channels of the channel data.
- Parameters:
- channelsChannels
- Returns:
- None
- set_uniform_gains(field=None)[source]¶
Sets the gain and coupling to 1.0 for all channels.
- Parameters:
- fieldstr, optional
If supplied, sets all values of the requested field to unity.
- Returns:
- None
- to_string(indices=None, frame=False)[source]¶
Return a string representation of channels.
- Parameters:
- indicesnumpy.ndarray or slice, optional
The channel indices (not fixed) to return. The default is all channels.
- framebool, optional
If
True
, returns apd.DataFrame
instead of a string representation.
- Returns:
- str or pd.DataFrame