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, a ndarray , a ndarray-like, a NDArray or any subclass of NDArray .

  • units (|Unit| instance or str, optional) – Units of the data. If data is a Quantity then units is set to the unit of the data; 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.

LinearCoord.is_units_compatible(other)

Check the compatibility of units with another object.

LinearCoord.ito(other[, force])

Inplace scaling to different units.

LinearCoord.ito_base_units()

Inplace rescaling to base units.

LinearCoord.ito_reduced_units()

Quantity scaled in place to reduced units, inplace.

LinearCoord.linspace(cls, start, stop[, ...])

Return evenly spaced numbers over a specified interval.

LinearCoord.loc2index(loc)

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

LinearCoord.data

The data array (ndarray).

LinearCoord.dimensionless

True if the data array is dimensionless - Readonly property (bool).

LinearCoord.dtype

Data type (np.dtype).

LinearCoord.filename

Current filename for this dataset (Pathlib object).

LinearCoord.has_data

True if the data array is not empty and size > 0.

LinearCoord.has_defined_name

True is the name has been defined (bool).

LinearCoord.has_units

True if the data array have units - Readonly property (bool).

LinearCoord.id

Object identifier - Readonly property (str).

LinearCoord.is_empty

True if the data array is empty or size=0, and if no label are present - Readonly property (bool).

LinearCoord.is_float

True if the data are real values - Readonly property (bool).

LinearCoord.is_integer

True if the data are integer values - Readonly property (bool).

LinearCoord.is_labeled

True if the data array have labels - Readonly property (bool).

LinearCoord.labels

An array of labels for data (ndarray of str).

LinearCoord.laser_frequency

Laser frequency if needed (Quantity).

LinearCoord.limits

Range of the data (list).

LinearCoord.m

The data array (ndarray).

LinearCoord.magnitude

The data array (ndarray).

LinearCoord.meta

Additional metadata (Meta).

LinearCoord.name

A user-friendly name (str).

LinearCoord.offset

Starting value for linear array

LinearCoord.reversed

bool - Whether the axis is reversed (readonly property).

LinearCoord.roi

Region of interest (ROI) limits (list).

LinearCoord.show_datapoints

True if axis must discard values and show only datapoints.

LinearCoord.size

Size of the underlying data array - Readonly property (int).

LinearCoord.spacing

Return coordinates spacing.

LinearCoord.title

An user friendly title (str).

LinearCoord.umasked_data

The actual array with mask and unit (Quantity).

LinearCoord.unitless

bool - True if the data does not have units (Readonly property).

LinearCoord.units

Unit - The units of the data.

LinearCoord.value

Alias of values.

LinearCoord.values

Quantity - The actual values (data, units) contained in this object (Readonly property).

data

The data array (ndarray).

If there is no data but labels, then the labels are returned instead of data.

dimensionless

True if the data array is dimensionless - Readonly property (bool).

See also

unitless

True if data has no units.

has_units

True if data has units. Notes

-----, None

dtype

Data type (np.dtype).

filename

Current filename for this dataset (Pathlib object).

has_data

True if the data array is not empty and size > 0.

(Readonly property).

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).

is_float

True if the data are real values - Readonly property (bool).

is_integer

True if the data are integer values - Readonly property (bool).

is_labeled

True if the data array have labels - 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

The data array (ndarray).

If there is no data but labels, then the labels are returned instead of data.

magnitude

The data array (ndarray).

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

size

Size of the underlying data array - Readonly property (int).

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).

unitless

bool - True if the data does not have units (Readonly property).

units

Unit - The units of the data.

value

Alias of values.

values

Quantity - The actual values (data, units) contained in this object (Readonly property).

Examples using spectrochempy.LinearCoord

Units manipulation examples

Units manipulation examples

NDDataset coordinates example

NDDataset coordinates example