flap.coordinate¶
Created on Wed Jan 23 09:44:50 2019
This is the coordinate description and related methods for FLAP
@author: Sandor Zoletnik (zoletnik.sandor@ek-cer.hu) Centre for Energy Research
- class flap.coordinate.Coordinate(name=None, unit=None, mode=<flap.coordinate.CoordinateMode object>, shape=[], start=None, step=None, c_range=None, values=None, value_index=None, value_ranges=None, dimension_list=[])¶
Bases:
objectClass for the description of a mapping of coordinate values from an n-dimensional coordinate sample space to coordinates of an m-dimensional data matrix.
The coordinate sample space is a rectangular equidistant point matrix, with equal steps in each dimension. For dimension
i, the sample index spans0 ... n-1ifshape[i] == n.The sample space in this coordinate description does not necessarily match the shape of any sub-matrix of the data object. If the shape is different then interpolation is done assuming the coordinate of the first(last) point of the coordinate matrix is the coordinate of the first(last) data point.
A coordinate can be anything described by name and unit. Standard coordinates: ‘Time’, ‘Channel’, ‘Channel number’, ‘Device_x’, ‘Device_y’, ‘Device_z’, ‘Device_R’, ‘Device_Z’, ‘Device_phi’, ‘Flux_r’, ‘Flux_theta’, ‘Flux_phi’, ‘Frequency’, ‘Time lag’.
The ranges and start-step pair of parameters are alternatives.
- Parameters:
- namestr, optional, default=None
Name of the quantity measured in the coordinate. (E.g. ‘Time’.)
- unitstr, optional, default=None
Name of the unit used along the coordinate. (E.g. ‘Second’.)
- modeflap.CoordinateMode, optional, default=``CoordinateMode()``
Coordinate mode to use.
- shapearray_like, optional, default=``[]``
The shape of the sample space matrix in this coordinate description. If
len(shape) == 0, then the coordinate is the same for all samples and it is described by values and value_ranges. The parameter shape should not have a1element. In the equidistant case only the dimension of shape is used.- startfloat, optional, default=None
Start of the coordinate mapping. Only valid if the coordinate mode is equidistant.
- steplist of float, optional, default=None
Steps of the coordinate mapping. One-dimensional list with the same number of elements as dimension_list. Only valid if the coordinate mode is equidistant.
- c_rangearray_like, optional, default=None
Used for specifying a range when reading data.
- values, value_indexarray_like, optional, default=None
Only valid if the coordinate mode is non-equidistant. The values describe the coordinate values at value_index. Sample values are a 2D array of size
(len(shape), N_sample)containing indices to the coordinate matrix described by shape. That is,values_index[:,i]gives the coordinates ofvalues[i]in the coordinate sample space.- value_rangesfloat | array_like | dict, optional, default=None
Specifies the range around the coordinate values.
If the coordinate mode has symmetric ranges, it is symmetric around the values:
[values-value_ranges, value+value_ranges]. If not symmetric, it is[values-value_ranges_low, value+value_ranges_high].For equidistant coordinates:
if the range is not symmetric, value_ranges should be a 2 element array;
if the range is symmetric, value_ranges should be a scalar.
For non-equidistant coordinates:
if the range is not symmetric, value_ranges should be a dictionary with keys ‘low’, ‘high’, with each value having the same dimensions as values;
if the range is symmetric, value_ranges should have the same shape as values.
- dimension_listlist, optional, default=[]
List of data dimensions with which this coordinate is associated (0…). Length of dimension_list should be equal to length of shape.
- change_dimensions()¶
Return the list of dimensions of the data array along which this coordinate changes.
- Returns:
- list
- data(data_shape=None, index=None, options=None)¶
Return the coordinates, low and high limits for a sub-array of the data array in a DataObject.
- Parameters:
- data_shapearray_like, optional, default=None
The shape of the data array (without slicing) for which coordinates are requested.
- indexlist | tuple of int, optional, default=None
Describes the elements in DataObject.data for which the coordinates are required. The length of the array should be identical to the number of dimensions of the data array. Elements can be a mixture of numbers, slice objects, lists, numpy arrays, integer iterators and ellipses.
Examples for 3D array:
(...,0,0): coordinates of the elements in the first row of the data array(slice(2,5),2,...)
- optionsdict, optional, default=None
Dictionary with options for processing:
‘Interpolation’ (default=’Linear’):
‘Linear’: For non-equidistant axis, when values shape is different from data shape)
‘Change only’ (default=False):
True (return only the data for those dimensions where this coordinate changes. E.g. if it changes only along one dimension the output array will have 1 element in all other dimensions.)
- Returns:
- values, value_range_low, value range_higharray_like
Values and the respective low and high range values. The low and high values are the absolute values not, the difference from values.
- data_range(data_shape=None)¶
Return the data range and the data range with errors for the coordinate.
- Parameters:
- data_shapearray_like, optional, default=None
Data shape.
- Returns:
- value_range, value_range_errorlist
- property dimension_list¶
List of data dimensions with which this coordinate is associated with.
- Returns:
- list of int
- dtype()¶
Return the data type of the coordinate.
Return standard Python types: str, int, float, complex, boolean or object.
- Returns:
- type
- isnumeric()¶
Return whether the data type is numeric.
- Returns:
- bool
- nochange_dimensions(data_shape)¶
Return the list of dimensions of the data array along which this coordinate does not change.
- Parameters:
- data_shapearray_like
The data shape to use.
- Returns:
- list
- non_interpol(data_shape)¶
Return True if the shape of the coordinate description is the same as the sub-data-array for which it applies and self.value_index is None. In this case there is no need for interpolation, coordinate values are copied. Valid only for non-equidistant coordinate mode.
- Parameters:
- data_shapearray_like
The shape of the sub-data-array.
- Returns:
- bool
- property shape¶
The shape of the sample space matrix in this coordinate description.
- Returns:
- list
- property start¶
Start of the coordinate mapping. Only valid if the coordinate mode is equidistant.
- Returns:
- float or None
- property step¶
Steps of the coordinate mapping. Only valid if the coordinate mode is equidistant.
- Returns:
- list or None
- string_subtype()¶
Return the type of the values if the coordinate type is str. Otherwise returns None.
- Returns:
- type or None
- class flap.coordinate.CoordinateMode(equidistant=True, range_symmetric=True)¶
Bases:
objectClass for storing mode flags of the coordinate description.
- Parameters:
- equidistantbool, optional, default=True
Whether the coordinate values are equidistant.
- range_symmetricbool, optional, default=True
Whether the ranges corresponding to the coordinates are symmetric.
- class flap.coordinate.Intervals(start, stop, step=None, number=None)¶
Bases:
objectClass to describe a series of intervals.
Different types of intervals exist:
Regular intervals are identical length ones repeating with a fixed step.
Irregulars are just a list of start-stop values.
For integer type values both the start and stop value is included.
The optional number gives the number of ranges for the regular intervals.
- Parameters:
- start, stopint | float | ndarray
For regular intervals: start and stop value of first interval. For irregular intervals: start and stop value of all intervals. (Identical-length numpy arrays.)
- stepint | float, optional, default=None
If not given, the intervals are assumed to be irregular, otherwise regular.
- numberint, optional, default=None
The number of intervals in regular case. If not set, the intervals continue indefinitely.
- interval_limits(limits=None, partial_intervals=False)¶
Return the range lower and upper limits as two numpy arrays. Limit the ranges within argument limits.
- Parameters:
- limitsarray_like, optional, default=None
Two-element list with lower and upper limit, in this order.
- partial_intervalsbool, optional, default=False
Return also partial ranges which extend over limits. Their size will be truncated.
- Returns:
- range_starts, range_stopsndarray
The range lower and upper limits.
- interval_number(limits=None, partial_intervals=False)¶
Return the number of intervals and the index of the start interval. Limit the ranges within argument limits.
- Parameters:
- limitsarray_like, optional, default=None
2 elements list with lower and upper limit.
- partial_intervalsbool, optional, default=False
Take into account also partial ranges which extend over limits.
- Returns:
- int
The number of intervals.
- int
The index of the start interval.
- regular()¶
Return True if the interval is regular, otherwise returns False.
- Returns:
- bool
- class flap.coordinate.Unit(name='', unit='')¶
Bases:
objectClass representing the unit of a quantity.
- Parameters:
- namestr, optional, default=’’
Name of the quantity. (E.g. ‘Time’.)
- unitstr, optional, default=’’
Name of the unit. (E.g. ‘Second’.)
- title(language='EN', complex_txt=None, new_unit=None)¶
Return a title string to be used in plotting.
- Parameters:
- language{‘EN’, ‘HU’}, optional, default=’EN’
Language to be used for creating the title string.
- complex_txt{[0, 0], [0, 1], [1, 0], [1, 1]}, optional, default=None
List of 2 numbers representing which component of a complex variable is used:
[0,0]: Amplitude[0,1]: Phase[1,0]: Real[1,1]: Imaginary
- new_unitstr, optional, default=None
Unit string override to be used instead of self.unit.
- Returns:
- str
The title string.