emsarray.formats.grid#

Datasets following the CF conventions with gridded datasets. Both 1D coordinates and 2D coordinates are supported.

class emsarray.formats.grid.CFGrid(dataset, *, latitude=None, longitude=None, topology=None)#

A base class for CF grid datasets. There are two concrete subclasses: CFGrid1D and CFGrid2D.

__init__(dataset, *, latitude=None, longitude=None, topology=None)#

Construct a new CFGrid instance.

Parameters
  • dataset (xarray.Dataset) – A Dataset that follows the CF conventions. The grid coordinates must be one-dimensional.

  • latitude (str, optional) – The name of the latitude coordinate variable on this dataset. Optional. By default the coordinate variables are found by introspecting the dataset. You can use this parameter to override this behaviour.

  • longitude (str, optional) – The name of the longitude coordinate variable on this dataset. Optional. By default the coordinate variables are found by introspecting the dataset. You can use this parameter to override this behaviour.

  • topology (CFGridTopology, optional) – Optional, allows you to override the default topology helper.

property topology#

A CFGridTopology helper.

class emsarray.formats.grid.CFGrid1D(dataset, *, latitude=None, longitude=None, topology=None)#

A Format subclass representing datasets on an axis-aligned grid that follows the CF metadata conventions and has one dimensional coordinates.

class emsarray.formats.grid.CFGrid2D(dataset, *, latitude=None, longitude=None, topology=None)#

A Format subclass representing datasets on a curvilinear grid that follows the CF metadata conventions and has two dimensional coordinates.

Indexing#

CF grid datasets have one grid: face. CFGridKind represents this. Each face is indexed by two integers x and y. The format native index type is CFGridIndex.

class emsarray.formats.grid.CFGridKind(value)#
face = 'face'#
emsarray.formats.grid.CFGridIndex#

A two-tuple of (y, x).

alias of Tuple[int, int]

Topology#

class emsarray.formats.grid.CFGridTopology(dataset, longitude=None, latitude=None)#

A topology helper that keeps track of the latitude and longitude coordinates in a CF grid dataset.

property latitude_name#

The name of the latitude coordinate variable. Found by looking for a variable with either a standard_name = "latitude" or units = "degree_north" attribute.

property longitude_name#

The name of the longitude coordinate variable. Found by looking for a variable with either a standard_name = "longitude" or units = "degree_east" attribute.

property latitude#

The latitude coordinate variable

property longitude#

The longitude coordinate variable

abstract property y_dimension#

The name of the ‘y’ dimension. For 1D coordinates, this is the the latitude dimension. For 2D coordinates, this is the first dimension of the coordinate variables.

abstract property x_dimension#

The name of the ‘x’ dimension. For 1D coordinates, this is the the longitude dimension. For 2D coordinates, this is the second dimension of the coordinate variables.

property shape#

The shape of this grid, as a tuple of (y, x).

property size#

The scalar size of this grid.

Equal to np.prod(topology.shape), i.e., the product of the grid dimensions.

class emsarray.formats.grid.CFGrid1DTopology(dataset, longitude=None, latitude=None)#

Collects information about the topology of a gridded dataset so that you don’t have to.

This grid has one-dimensional coordinates, such as lat(lat) or longitude(x).

class emsarray.formats.grid.CFGrid2DTopology(dataset, longitude=None, latitude=None)#

Collects information about the topology of a gridded dataset so that you don’t have to.

This grid has two-dimensional coordinates, such as lat(y, x) and lon(y, x)