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.
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.
Return a dict of the coordinates from the coordset.
CoordSet.update
(**kwargs)Update a specific coordinates in the CoordSet.
Attributes
Chars that can be used for dimension name (list).
Coordinates in the coordset (list).
Default coordinates (Coord).
True if the name has been defined (bool).
Object identifier (Readonly property).
True if there is no coords defined (bool).
returns True if one of the coords is labeled.
True if the coords define a single dimension (bool).
Labels of the coordinates in the current coordset (list).
Names of the coords in the current coords (list - read only property).
Sizes of the coord object for each dimension (int or tuple of int).
Sizes of the coord object for each dimension (int or tuple of int).
Titles of the coords in the current coords (list).
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).