domains

Attributes

NO_BBOX

NO_TRANSFORM_FIRST

Classes

Domain

Class for storing domain information.

PresetDomain

Class for storing domain information.

Functions

force_0_to_360(x)

Force an array of longitudes to be in the range 0 to 360.

force_minus_180_to_180(x)

Force an array of longitudes to be in the range -180 to 180.

format_name(domain_name)

Format a domain name to match the lookup keys in the domain lookup.

is_latlon(data)

Determine whether a dataset' coordinates are in latitude and longitude.

roll_from_0_360_to_minus_180_180(x)

Find the index at which an array of longitudes crosses the 180° meridian.

roll_from_minus_180_180_to_0_360(x)

Find the index at which an array of longitudes crosses the 0° meridian.

union(domains[, name])

Combine multiple domains into a single domain.

Module Contents

class domains.Domain(bbox, crs=DEFAULT_CRS, name=None)

Class for storing domain information.

Parameters:
  • bbox (list of float) – The bounding box of the domain in the form [west, east, south, north].

  • crs (cartopy.crs.CRS, optional) – The coordinate reference system of the domain.

  • name (str, optional) – The name of the domain.

bbox
property can_bbox

Whether the domain can be used to slice data.

property crs

The coordinate reference system of the domain.

extract(x, y, values=None, extra_values=None, source_crs=ccrs.PlateCarree())

Slice data to fit the domain. Works for both gridded and unstructured data.

Parameters:
  • x (array-like) – The x-coordinates of the data.

  • y (array-like) – The y-coordinates of the data.

  • values (array-like, optional) – The values of the data.

  • extra_values (list of array-like, optional) – Additional values to be sliced.

  • source_crs (cartopy.crs.CRS, optional) – The coordinate reference system of the input data.

classmethod from_bbox(*args, name=None, **kwargs)

Create a domain from a bounding box.

Parameters:
  • *args (list of float) – The bounding box of the domain in the form [west, east, south, north].

  • name (str, optional) – The name of the domain.

  • **kwargs – Additional keyword arguments to be passed to the BoundingBox constructor.

classmethod from_data(data)

Create a domain from a dataset.

The domain will be created based on the bounding box and CRS of the dataset.

Parameters:

data (xarray.Dataset or earthkit.data.core.Base) – The dataset from which to create the domain.

classmethod from_string(string, crs=None)

Create a domain from a string.

The name of the domain can be a country, region, or a custom domain as defined in the domain lookup associated with your schema.

Parameters:
  • string (str) – The name of the domain.

  • crs (cartopy.crs.CRS, optional) – The coordinate reference system to be used.

property is_complete

Whether the domain is fully defined.

property name

The name of the domain.

property title

The title of the domain.

domains.NO_BBOX
domains.NO_TRANSFORM_FIRST
class domains.PresetDomain(bbox=None, crs=None, name=None)

Bases: Domain

Class for storing domain information.

Parameters:
  • bbox (list of float) – The bounding box of the domain in the form [west, east, south, north].

  • crs (cartopy.crs.CRS, optional) – The coordinate reference system of the domain.

  • name (str, optional) – The name of the domain.

BBOX
CRS
NAME = 'Custom Domain'
bbox
property can_bbox

Whether the domain can be used to slice data.

property crs

The coordinate reference system of the domain.

extract(x, y, values=None, extra_values=None, source_crs=ccrs.PlateCarree())

Slice data to fit the domain. Works for both gridded and unstructured data.

Parameters:
  • x (array-like) – The x-coordinates of the data.

  • y (array-like) – The y-coordinates of the data.

  • values (array-like, optional) – The values of the data.

  • extra_values (list of array-like, optional) – Additional values to be sliced.

  • source_crs (cartopy.crs.CRS, optional) – The coordinate reference system of the input data.

classmethod from_bbox(*args, name=None, **kwargs)

Create a domain from a bounding box.

Parameters:
  • *args (list of float) – The bounding box of the domain in the form [west, east, south, north].

  • name (str, optional) – The name of the domain.

  • **kwargs – Additional keyword arguments to be passed to the BoundingBox constructor.

classmethod from_data(data)

Create a domain from a dataset.

The domain will be created based on the bounding box and CRS of the dataset.

Parameters:

data (xarray.Dataset or earthkit.data.core.Base) – The dataset from which to create the domain.

classmethod from_string(string, crs=None)

Create a domain from a string.

The name of the domain can be a country, region, or a custom domain as defined in the domain lookup associated with your schema.

Parameters:
  • string (str) – The name of the domain.

  • crs (cartopy.crs.CRS, optional) – The coordinate reference system to be used.

property is_complete

Whether the domain is fully defined.

property name

The name of the domain.

property title

The title of the domain.

domains.force_0_to_360(x)

Force an array of longitudes to be in the range 0 to 360.

Parameters:

x (array-like) – The longitudes to be forced into the range 0 to 360.

domains.force_minus_180_to_180(x)

Force an array of longitudes to be in the range -180 to 180.

Parameters:

x (array-like) – The longitudes to be forced into the range -180 to 180.

domains.format_name(domain_name)

Format a domain name to match the lookup keys in the domain lookup.

Parameters:

domain_name (str) – The domain name to be formatted.

domains.is_latlon(data)

Determine whether a dataset’ coordinates are in latitude and longitude.

Parameters:

data (xarray.Dataset or earthkit.data.core.Base) – The dataset to be checked.

domains.roll_from_0_360_to_minus_180_180(x)

Find the index at which an array of longitudes crosses the 180° meridian.

Parameters:

x (array-like (1D or 2D)) – The longitudes to be checked.

Returns:

The index at which the array crosses 180°.

Return type:

int

domains.roll_from_minus_180_180_to_0_360(x)

Find the index at which an array of longitudes crosses the 0° meridian.

Parameters:

x (array-like) – The longitudes to be checked.

domains.union(domains, name=None)

Combine multiple domains into a single domain.

Parameters:
  • domains (list of Domain or str) – The domains to be combined.

  • name (str, optional) – The name of the new domain.

Example

>>> union(["Norway", "Sweden", "Finland"], name="Fennoscandia")