SingleColorChannelData¶
- class sofia_redux.scan.channels.channel_data.single_color_channel_data.SingleColorChannelData(channels=None)[source]¶
Bases:
ColorArrangementData
Initialize single color channel data.
The single color channel data defines each channel as a single color pixel on a camera detector arranged by row and column, with a focal plane position. Each pixel may defined as having no relation to other pixels on the same detector (independent=True), or that they do share some commonality (independent=False) such as overlapping sensitivities to the source response.
- Parameters:
- channels
Attributes Summary
Return the default values for the channel attributes.
Methods Summary
calculate_overlap_values
(overlap_distances, ...)Calculates the overlap values based on overlap distances.
find_row_col_overlap_indices
(radius, rows, cols)Find which pixels overlap with others within a given radius.
Return the number of geometric columns in the detector array.
Return the number of geometric rows in the detector array.
get_geometric_overlap_indices
(radius)Return a cross-array indicating overlapping indices from data.
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 channels.
Return the pixels in the arrangement.
get_positional_overlap_indices
(position, radius)Return a cross-array indicating overlapping indices from positions.
get_rcp_string
([indices])Return a string representation for the RCP of ALL channels.
Attributes Documentation
- 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}.
Methods Documentation
- 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. Although these are float values, they should be converted be in units of
point_size
.- point_sizeastropy.units.Quantity
The point size for calculating the overlaps. Typically, the beam FWHM.
- Returns:
- None
- find_row_col_overlap_indices(radius, rows, cols)[source]¶
Find which pixels overlap with others within a given radius.
- Parameters:
- radiusunits.Quantity
The radius defining the maximum overlapping radius. Should be provided in the same units as the SI pixel size of the parent channels.
- rowsnumpy.ndarray (int or float)
The row indices of the channels for which to determine overlaps.
- colsnumpy.ndarray (int or float)
The column indices of the channels for which to determine overlaps.
- Returns:
- overlapscsr_matrix
- abstract geometric_cols()[source]¶
Return the number of geometric columns in the detector array.
- Returns:
- colsint
- abstract geometric_rows()[source]¶
Return the number of geometric rows in the detector array.
- Returns:
- rowsint
- get_geometric_overlap_indices(radius)[source]¶
Return a cross-array indicating overlapping indices from data.
Overlaps are calculated based on the geometric properties of channels (rows and columns). A maximum radius must be supplied as well as the pixel size indicating the separation between pixels in the x and y directions.
- Parameters:
- radiusastropy.units.Quantity
The maximum radius about which to include overlaps.
- 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
.
- 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:
- ChannelGroup
A newly created channel group.
- 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.
- get_overlap_indices(radius)[source]¶
Return a cross-array indicating overlapping indices.
- Parameters:
- radiusastropy.units.Quantity
The maximum radius about which to include overlaps.
- 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
.
- static get_positional_overlap_indices(position, radius)[source]¶
Return a cross-array indicating overlapping indices from positions.
Given a search radius, find all overlapping positions.
- Parameters:
- positionnumpy.ndarray (float or int)
An array of orthogonal 2-dimensional coordinates of shape (n, 2). Note that all negative positions will not be included in the overlaps (this is a way of flagging default values).
- radiusfloat
The maximum radius about which to include overlaps.
- 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
.