spectrochempy.LinearCoord¶
- class LinearCoord(**kwargs)[source]¶
Linear coordinates.
Such coordinates correspond to a ascending or descending linear sequence of values, fully determined by two parameters, i.e., an offset (off) and an increment (inc) :
\[\mathrm{data} = i*\mathrm{inc} + \mathrm{off}.\]- Parameters
data (a 1D array-like object, optional) – WWen provided, the
size
parameters is adjusted to the size of the array, and a linearization of the array is performed (only if it is possible: regular spacing in the 1.e5 relative accuracy).offset (float, optional) – If omitted a value of 0.0 is taken for the coordinate offset.
increment (float, optional) – If omitted a value of 1.0 is taken for the coordinate increment.
**kwargs – Optional keywords parameters. See other parameters.
- Other Parameters
dtype (str or dtype, optional, default=np.float64) – If specified, the data will be casted to this dtype, else the type of the data will be used
dims (list of chars, optional.) – if specified the list must have a length equal to the number od data dimensions (ndim) and the chars must be taken among x,y,z,u,v,w or t. If not specified, the dimension names are automatically attributed in this order.
name (str, optional) – A user-friendly name for this object. If not given, the automatic
id
given at the object creation will be used as a name.labels (array of objects, optional) – Labels for the
data
. labels can be used only for 1D-datasets. The labels array may have an additional dimension, meaning several series of labels for the same data. The given array can be a list, a tuple, andarray
, a ndarray-like, aNDArray
or any subclass ofNDArray
.units (|Unit| instance or str, optional) – Units of the data. If data is a
Quantity
thenunits
is set to the unit of thedata
; if a unit is also explicitly provided an error is raised. Handling of units use the pint package.title (str, optional) – The title of the dimension. It will later be used for instance for labelling plots of the data. It is optional but recommended to give a title to each ndarray.
dlabel (str, optional.) – Alias of
title
.meta (dict-like object, optional.) – Additional metadata for this object. Must be dict-like but no further restriction is placed on meta.
copy (bool, optional) – Perform a copy of the passed object. Default is False.
fill_missing (bool) – Create a linear coordinate array where missing data are masked.
See also
NDDataset
Main SpectroChemPy object: an array with masks, units and
coordinates.
Coord
Explicit coordinates.
Examples
>>> from spectrochempy import LinearCoord, Coord
To create a linear coordinate, we need to specify an offset, an increment and the size of the data
>>> c1 = LinearCoord(offset=2.0, increment=2.0, size=10)
Alternatively, linear coordinates can be created using the
linear
keyword>>> c2 = Coord(linear=True, offset=2.0, increment=2.0, size=10)
Methods
LinearCoord.amax
(dataset[, dim, keepdims])Return the maximum of the dataset or maxima along given dimensions.
LinearCoord.amin
(dataset[, dim, keepdims])Return the maximum of the dataset or maxima along given dimensions.
LinearCoord.arange
([start, stop, step, dtype])Return evenly spaced values within a given interval.
LinearCoord.around
(dataset[, decimals])Evenly round to the given number of decimals.
LinearCoord.astype
([dtype])Cast the data to a specified type.
LinearCoord.copy
([deep, keepname])Make a disconnected copy of the current object.
LinearCoord.fromfunction
(cls, function[, ...])Construct a nddataset by executing a function over each coordinate.
LinearCoord.fromiter
(iterable[, dtype, count])Create a new 1-dimensional array from an iterable object.
LinearCoord.geomspace
(start, stop[, num, ...])Return numbers spaced evenly on a log scale (a geometric progression).
LinearCoord.get_labels
([level])Get the labels at a given level.
Check the compatibility of units with another object.
LinearCoord.ito
(other[, force])Inplace scaling to different units.
Inplace rescaling to base units.
Quantity scaled in place to reduced units, inplace.
LinearCoord.linspace
(cls, start, stop[, ...])Return evenly spaced numbers over a specified interval.
Return the index corresponding to a given location.
LinearCoord.logspace
(cls, start, stop[, ...])Return numbers spaced evenly on a log scale.
LinearCoord.max
(dataset[, dim, keepdims])Return the maximum of the dataset or maxima along given dimensions.
LinearCoord.min
(dataset[, dim, keepdims])Return the maximum of the dataset or maxima along given dimensions.
LinearCoord.ptp
(dataset[, dim, keepdims])Range of values (maximum - minimum) along a dimension.
LinearCoord.round
(dataset[, decimals])Evenly round to the given number of decimals.
LinearCoord.round_
(dataset[, decimals])Evenly round to the given number of decimals.
LinearCoord.to
(other[, inplace, force])Return the object with data rescaled to different units.
LinearCoord.to_base_units
([inplace])Return an array rescaled to base units.
LinearCoord.to_reduced_units
([inplace])Return an array scaled in place to reduced units.
Attributes
True if the
data
array is dimensionless - Readonly property (bool).Data type (np.dtype).
Current filename for this dataset (
Pathlib
object).True if the
data
array is not empty and size > 0.True is the name has been defined (bool).
True if the
data
array have units - Readonly property (bool).Object identifier - Readonly property (str).
True if the
data
array is empty or size=0, and if no label are present - Readonly property (bool).True if the
data
are real values - Readonly property (bool).True if the
data
are integer values - Readonly property (bool).True if the
data
array have labels - Readonly property (bool).Laser frequency if needed (Quantity).
Range of the data (list).
Additional metadata (
Meta
).A user-friendly name (str).
Starting value for linear array
bool - Whether the axis is reversed (readonly property).
Region of interest (ROI) limits (list).
True if axis must discard values and show only datapoints.
Size of the underlying
data
array - Readonly property (int).Return coordinates spacing.
An user friendly title (str).
The actual array with mask and unit (
Quantity
).bool
- True if thedata
does not haveunits
(Readonly property).Unit
- The units of the data.Alias of
values
.Quantity
- The actual values (data, units) contained in this object (Readonly property).- data¶
-
If there is no data but labels, then the labels are returned instead of data.
- dtype¶
Data type (np.dtype).
- filename¶
Current filename for this dataset (
Pathlib
object).
- has_defined_name¶
True is the name has been defined (bool).
- has_units¶
True if the
data
array have units - Readonly property (bool).See also
unitless
True if the data has no unit.
dimensionless
True if the data have dimensionless units.
- id¶
Object identifier - Readonly property (str).
- is_empty¶
True if the
data
array is empty or size=0, and if no label are present - Readonly property (bool).
- labels¶
An array of labels for
data
(ndarray
of str).An array of objects of any type (but most generally string), with the last dimension size equal to that of the dimension of data. Note that’s labelling is possible only for 1D data. One classical application is the labelling of coordinates to display informative strings instead of numerical values.
- laser_frequency¶
Laser frequency if needed (Quantity).
- limits¶
Range of the data (list).
- m¶
-
If there is no data but labels, then the labels are returned instead of data.
- magnitude¶
-
If there is no data but labels, then the labels are returned instead of data.
- meta¶
Additional metadata (
Meta
).
- name¶
A user-friendly name (str).
When no name is provided, the
id
of the object is returned instead.
- offset¶
Starting value for linear array
- reversed¶
bool - Whether the axis is reversed (readonly property).
- roi¶
Region of interest (ROI) limits (list).
- show_datapoints¶
True if axis must discard values and show only datapoints.
- Type
Bool
- spacing¶
Return coordinates spacing.
It will be a scalar if the coordinates are uniformly spaced, else an array of the different spacings
- title¶
An user friendly title (str).
When the title is provided, it can be used for labeling the object, e.g., axe title in a matplotlib plot.
- umasked_data¶
The actual array with mask and unit (
Quantity
).(Readonly property).
- units¶
Unit
- The units of the data.
- values¶
Quantity
- The actual values (data, units) contained in this object (Readonly property).