spectrochempy.CoordSet

class CoordSet(**kwargs)[source]

A collection of Coord objects for a NDArray object with validation.

This object is an iterable containing a collection of Coord objects.

Parameters
  • *coords (|NDarray| , |NDArray| subclass or |CoordSet| sequence of objects.) – If an instance of CoordSet is found, instead of an array, this means that all coordinates in this coords describe the same axis. It is assumed that the coordinates are passed in the order of the dimensions of a nD numpy array ( row-major order), i.e., for a 3d object : ‘z’, ‘y’, ‘x’.

  • **kwargs – Additional keyword parameters (see Other Parameters).

Other Parameters
  • x (|NDarray| , |NDArray| subclass or |CoordSet|) – A single coordinate associated to the ‘x’-dimension. If a coord was already passed in the argument, this will overwrite the previous. It is thus not recommended to simultaneously use both way to initialize the coordinates to avoid such conflicts.

  • y, z, u, … (|NDarray| , |NDArray| subclass or |CoordSet|) – Same as x for the others dimensions.

  • dims (list of string, optional) – Names of the dims to use corresponding to the coordinates. If not given, standard names are used: x, y, …

  • copy (bool, optional) – Perform a copy of the passed object. Default is True.

See also

Coord

Explicit coordinates object.

LinearCoord

Implicit coordinates object.

NDDataset

The main object of SpectroChempy which makes use of CoordSet.

Examples

>>> from spectrochempy import Coord, CoordSet

Define 4 coordinates, with two for the same dimension

>>> coord0 = Coord.linspace(10., 100., 5, units='m', title='distance')
>>> coord1 = Coord.linspace(20., 25., 4, units='K', title='temperature')
>>> coord1b = Coord.linspace(1., 10., 4, units='millitesla', title='magnetic field')
>>> coord2 = Coord.linspace(0., 1000., 6, units='hour', title='elapsed time')

Now create a coordset

>>> cs = CoordSet(t=coord0, u=coord2, v=[coord1, coord1b])

Display some coordinates

>>> cs.u
Coord: [float64] hr (size: 6)
>>> cs.v
CoordSet: [_1:temperature, _2:magnetic field]
>>> cs.v_1
Coord: [float64] K (size: 4)

Methods

CoordSet.copy([keepname])

Make a disconnected copy of the current coords.

CoordSet.keys()

Alias for names.

CoordSet.select(val)

Select the default coord index.

CoordSet.set(*args, **kwargs)

Set one or more coordinates in the current CoordSet.

CoordSet.set_titles(*args, **kwargs)

Set one or more coord title at once.

CoordSet.set_units(*args, **kwargs)

Set one or more coord units at once.

CoordSet.to_dict()

Return a dict of the coordinates from the coordset.

CoordSet.update(**kwargs)

Update a specific coordinates in the CoordSet.

Attributes

CoordSet.available_names

Chars that can be used for dimension name (list).

CoordSet.coords

Coordinates in the coordset (list).

CoordSet.default

Default coordinates (Coord).

CoordSet.has_defined_name

True if the name has been defined (bool).

CoordSet.id

Object identifier (Readonly property).

CoordSet.is_empty

True if there is no coords defined (bool).

CoordSet.is_labeled

returns True if one of the coords is labeled.

CoordSet.is_same_dim

True if the coords define a single dimension (bool).

CoordSet.labels

Labels of the coordinates in the current coordset (list).

CoordSet.names

Names of the coords in the current coords (list - read only property).

CoordSet.size

Sizes of the coord object for each dimension (int or tuple of int).

CoordSet.sizes

Sizes of the coord object for each dimension (int or tuple of int).

CoordSet.titles

Titles of the coords in the current coords (list).

CoordSet.units

Units of the coords in the current coords (list).

available_names

Chars that can be used for dimension name (list).

It returns DEFAULT_DIM_NAMES less those already in use.

coords

Coordinates in the coordset (list).

default

Default coordinates (Coord).

has_defined_name

True if the name has been defined (bool).

id

Object identifier (Readonly property).

is_empty

True if there is no coords defined (bool).

is_labeled

returns True if one of the coords is labeled.

is_same_dim

True if the coords define a single dimension (bool).

labels

Labels of the coordinates in the current coordset (list).

names

Names of the coords in the current coords (list - read only property).

size

Sizes of the coord object for each dimension (int or tuple of int).

(readonly property). If the set is for a single dimension return a single size as all coordinates must have the same.

sizes

Sizes of the coord object for each dimension (int or tuple of int).

(readonly property). If the set is for a single dimension return a single size as all coordinates must have the same.

titles

Titles of the coords in the current coords (list).

units

Units of the coords in the current coords (list).

Examples using spectrochempy.CoordSet

2D-IRIS analysis example

2D-IRIS analysis example

NDDataset coordinates example

NDDataset coordinates example