emsarray.conventions.grid#

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

class 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 (Hashable, 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 (Hashable, 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 CFGrid1D(dataset, *, latitude=None, longitude=None, topology=None)#

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

class CFGrid2D(dataset, *, latitude=None, longitude=None, topology=None)#

A Convention 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 convention native index type is CFGridIndex.

class CFGridKind(value)#
face = 'face'#
CFGridIndex#

A two-tuple of (y, x).

alias of Tuple[int, int]

Topology#

class 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.

See also

https

//cfconventions.org/Data/cf-conventions/cf-conventions-1.10/cf-conventions.html#latitude-coordinate

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.

See also

https

//cfconventions.org/Data/cf-conventions/cf-conventions-1.10/cf-conventions.html#longitude-coordinate

property latitude#

The latitude coordinate variable

property longitude#

The longitude coordinate variable

abstract property latitude_bounds#

Bounds for the latitude coordinate variable. If there are no bounds defined on the dataset, bounds will be generated.

abstract property longitude_bounds#

Bounds for the longitude coordinate variable. If there are no bounds defined on the dataset, bounds will be generated.

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 numpy.prod(topology.shape), i.e., the product of the grid dimensions.

class 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 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)