utilities.xarray

Extra functionality for xarray

Coordinates.__add__


def __add__(
    other
):

Adding two Coordinates objects combines their coordinates.

Define the + operator for Coordinates to combine the coordinates:

coords = Coordinates({'foo': [1, 2]}) + Coordinates({'bar': [1, 2, 3]})
coords
Coordinates:
  * foo      (foo) int64 16B 1 2
  * bar      (bar) int64 24B 1 2 3

Coordinates.complement


def complement(
    other:Coordinates
):

Return coordinates not in other coordinates.

coords.complement(Coordinates({'bar': [1, 2, 3]}))
Coordinates:
  * foo      (foo) int64 16B 1 2

Coordinates.shape


def shape(
    
):

Return tuple of sizes of the coordinates.

coords.shape
(2, 3)

Coordinates.size


def size(
    
):

Return product of coordinate lengths.

coords.size
6

Coordinates.intersection


def intersection(
    other:Coordinates
):

Return coordinates in self and other.

coords.intersection(Coordinates({'foo': [1, 2]}))
Coordinates:
  * foo      (foo) int64 16B 1 2

Coordinates.contain


def contain(
    other:Coordinates
):

Return true if all coordinates in other are in self, otherwise false.

coords.contain(Coordinates({'foo': [1, 2]}))
True
coords.contain(Coordinates({'foo': [1, 2], 'baz': [4, 5]}))
False