Warning

You are reading the documentation related to the development version. Go here if you are looking for the documentation of the stable release.

spectrochempy.CoordSet

class CoordSet(*coords, **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.

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)

Attributes Summary

available_names

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

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

sizes

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

titles

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

units

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

Methods Summary

copy([keepname])

Make a disconnected copy of the current coords.

keys()

Alias for names.

select(val)

Select the default coord index.

set(*args, **kwargs)

Set one or more coordinates in the current CoordSet.

set_titles(*args, **kwargs)

Set one or more coord title at once.

set_units(*args, **kwargs)

Set one or more coord units at once.

to_dict()

Return a dict of the coordinates from the coordset.

update(**kwargs)

Update a specific coordinates in the CoordSet.

Attributes Documentation

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

Methods Documentation

copy(keepname=False)[source]

Make a disconnected copy of the current coords.

Returns

object – an exact copy of the current object

keys()[source]

Alias for names.

Returns

out (list) – list of all coordinates names (including reference to other coordinates).

select(val)[source]

Select the default coord index.

set(*args, **kwargs)[source]

Set one or more coordinates in the current CoordSet.

Parameters
  • *args

  • **kwargs

set_titles(*args, **kwargs)[source]

Set one or more coord title at once.

Parameters
  • args (str(s)) – The list of titles to apply to the set of coordinates (they must be given according to the coordinate’s name alphabetical order.

  • **kwargs – Keyword attribution of the titles. The keys must be valid names among the coordinate’s name list. This is the recommended way to set titles as this will be less prone to errors.

Notes

If the args are not named, then the attributions are made in coordinate’s name alphabetical order : e.g, the first title will be for the x coordinates, the second for the y , etc.

set_units(*args, **kwargs)[source]

Set one or more coord units at once.

Parameters
  • *args (str(s)) – The list of units to apply to the set of coordinates (they must be given according to the coordinate’s name alphabetical order.

  • **kwargs – Keyword attribution of the units. The keys must be valid names among the coordinate’s name list. This is the recommended way to set units as this will be less prone to errors.

  • force (bool, optional, default=False) – Whether or not the new units must be compatible with the current units. See the Coord .`to` method.

Notes

If the args are not named, then the attributions are made in coordinate’s name alphabetical order : e.g, the first units will be for the x coordinates, the second for the y , etc.

to_dict()[source]

Return a dict of the coordinates from the coordset.

Returns

out (dict) – A dictionary where keys are the names of the coordinates, and the values the coordinates themselves.

update(**kwargs)[source]

Update a specific coordinates in the CoordSet.

Parameters

k**warg – Only keywords among the CoordSet.names are allowed - they denotes the name of a dimension.

Examples using spectrochempy.CoordSet

NDDataset coordinates example

NDDataset coordinates example

Analysis CP NMR spectra

Analysis CP NMR spectra

2D-IRIS analysis example

2D-IRIS analysis example