utilities.xarray

Extra functionality for xarray
%%capture

source

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

source

Coordinates.complement

def complement(
    other:xarray.core.coordinates.Coordinates
):

Return coordinates not in other coordinates.

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

source

Coordinates.shape

def shape():

Return tuple of sizes of the coordinates.

coords.shape
(2, 3)

source

Coordinates.size

def size():

Return product of coordinate lengths.

coords.size
np.int64(6)

source

Coordinates.intersection

def intersection(
    other:xarray.core.coordinates.Coordinates
):

Return coordinates in self and other.

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

source

Coordinates.contain

def contain(
    other:xarray.core.coordinates.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