xdas.coordinates.Coordinates#

class xdas.coordinates.Coordinates(coords=None, dims=None)[source]#

Dictionary like container for coordinates.

Parameters:
  • coords (dict-like, optional) –

    Mapping from coordinate names to any of the followings:

    • Coordinate objects

    • tuples (dim, coordinate-like) which can be either dimensional (dim == name) or non-dimensional (dim != name or dim == None).

    • coordinate-like objects (that are passed to the Coordinate constructor) which are assumed to be a dimensional coordinate with dim set to the related name.

  • dims (squence of str, optional) – An ordered sequence of dimensions. It is meant to match the dimensionality of its associated data. If provided, it must at least include all dimensions found in coords (extras dimensions will be considered as empty coordinates). Otherwise, dimensions will be guessed from coords.

Examples

>>> import xdas as xd
>>> coords = {
...     "time": {"tie_indices": [0, 999], "tie_values": [0.0, 10.0]},
...     "distance": [0, 1, 2],
...     "channel": ("distance", ["DAS01", "DAS02", "DAS03"]),
...     "interrogator": (None, "SRN"),
... }
>>> xd.Coordinates(coords)
Coordinates:
  * time (time): 0.000 to 10.000
  * distance (distance): [0 ... 2]
    channel (distance): ['DAS01' ... 'DAS03']
    interrogator: 'SRN'
__init__(coords=None, dims=None)[source]#

Methods

__init__([coords, dims])

clear()

Remove all items from the dict.

copy([deep])

Return a copy of this Coordinates container.

drop_coords(*names)

Return a new Coordinates with the named coordinates removed.

drop_dims(*dims)

Return a new Coordinates with dims and their associated coordinates removed.

equals(other)

Return True if other is a Coordinates with identical coordinate values.

from_dataset(dataset, name)

Build a Coordinates by delegating to each registered coordinate subclass.

from_dict(dct)

Reconstruct a Coordinates from the dict returned by to_dict().

fromkeys(iterable[, value])

Create a new dictionary with keys from iterable and values set to value.

get(key[, default])

Return the value for key if key is in the dictionary, else default.

get_query(item)

Format a query from one or multiple indexer.

isdim(name)

Return True if name is a dimensional coordinate (i.e. its dim equals its name).

items()

Return a set-like object providing a view on the dict's items.

keys()

Return a set-like object providing a view on the dict's keys.

pop(k[,d])

If the key is not found, return the default if given; otherwise, raise a KeyError.

popitem()

Remove and return a (key, value) pair as a 2-tuple.

setdefault(key[, default])

Insert key with a value of default if key is not in the dictionary.

to_dict()

Convert this Coordinates object into a pure python dictionnary.

to_index(item[, method, endpoint])

Convert an item selector to a dict of per-dimension integer indices.

update([E, ]**F)

If E is present and has a .keys() method, then does: for k in E.keys(): D[k] = E[k] If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k]

values()

Return an object providing a view on the dict's values.

Attributes

dims

Ordered tuple of dimension names for this coordinates container.

parent

The parent object (usually a DataArray) this container is attached to.