earthkit.data.readers.xarray.flavour¶
Classes¶
A dictionary that allows access to its keys as attributes. |
|
Class to guess the type of coordinates in a dataset. |
|
Default implementation of CoordinateGuesser. |
|
Implementation of CoordinateGuesser that uses a flavour for guessing. |
Module Contents¶
- class earthkit.data.readers.xarray.flavour.CoordinateAttributes(*args, **kwargs)¶
Bases:
earthkit.data.utils.dotdict.DotDictA dictionary that allows access to its keys as attributes.
>>> d = DotDict({"a": 1, "b": {"c": 2}}) >>> d.a 1 >>> d.b.c 2 >>> d.b = 3 >>> d.b 3
The class is recursive, so nested dictionaries are also DotDicts.
The DotDict class has the same constructor as the dict class.
>>> d = DotDict(a=1, b=2)
- classmethod from_file(path)¶
Create a DotDict from a file.
- Parameters:
path (
str) – The path to the file.- Returns:
The created DotDict.
- Return type:
DotDict
- classmethod from_json_file(path)¶
Create a DotDict from a JSON file.
- Parameters:
path (
str) – The path to the JSON file.- Returns:
The created DotDict.
- Return type:
DotDict
- classmethod from_toml_file(path)¶
Create a DotDict from a TOML file.
- Parameters:
path (
str) – The path to the TOML file.- Returns:
The created DotDict.
- Return type:
DotDict
- classmethod from_yaml_file(path)¶
Create a DotDict from a YAML file.
- Parameters:
path (
str) – The path to the YAML file.- Returns:
The created DotDict.
- Return type:
DotDict
- class earthkit.data.readers.xarray.flavour.CoordinateGuesser(ds)¶
Bases:
abc.ABCClass to guess the type of coordinates in a dataset.
- ds¶
- classmethod from_flavour(ds, flavour)¶
Creates a CoordinateGuesser from a flavour.
- Parameters:
ds (
xr.Dataset) – The dataset to guess coordinates from.flavour (
Optional[Dict[str,Any]]) – The flavour to use for guessing.
- Returns:
The created CoordinateGuesser.
- Return type:
- grid(coordinates, variable)¶
Determines the grid type for the given coordinates and variable.
- Parameters:
coordinates (
Any) – The coordinates to determine the grid from.variable (
Any) – The variable to determine the grid from.
- Returns:
The determined grid type.
- Return type:
Any
- guess(c, coord)¶
Guesses the type of a coordinate.
- Parameters:
c (
xr.DataArray) – The coordinate to guess.coord (
Hashable) – The name of the coordinate.
- Returns:
The guessed coordinate type.
- Return type:
Coordinate
- class earthkit.data.readers.xarray.flavour.DefaultCoordinateGuesser(ds)¶
Bases:
CoordinateGuesserDefault implementation of CoordinateGuesser.
- ds¶
- classmethod from_flavour(ds, flavour)¶
Creates a CoordinateGuesser from a flavour.
- Parameters:
ds (
xr.Dataset) – The dataset to guess coordinates from.flavour (
Optional[Dict[str,Any]]) – The flavour to use for guessing.
- Returns:
The created CoordinateGuesser.
- Return type:
- grid(coordinates, variable)¶
Determines the grid type for the given coordinates and variable.
- Parameters:
coordinates (
Any) – The coordinates to determine the grid from.variable (
Any) – The variable to determine the grid from.
- Returns:
The determined grid type.
- Return type:
Any
- guess(c, coord)¶
Guesses the type of a coordinate.
- Parameters:
c (
xr.DataArray) – The coordinate to guess.coord (
Hashable) – The name of the coordinate.
- Returns:
The guessed coordinate type.
- Return type:
Coordinate
- class earthkit.data.readers.xarray.flavour.FlavourCoordinateGuesser(ds, flavour)¶
Bases:
CoordinateGuesserImplementation of CoordinateGuesser that uses a flavour for guessing.
- ds¶
- flavour¶
- classmethod from_flavour(ds, flavour)¶
Creates a CoordinateGuesser from a flavour.
- Parameters:
ds (
xr.Dataset) – The dataset to guess coordinates from.flavour (
Optional[Dict[str,Any]]) – The flavour to use for guessing.
- Returns:
The created CoordinateGuesser.
- Return type:
- grid(coordinates, variable)¶
Determines the grid type for the given coordinates and variable.
- Parameters:
coordinates (
Any) – The coordinates to determine the grid from.variable (
Any) – The variable to determine the grid from.
- Returns:
The determined grid type.
- Return type:
Any
- guess(c, coord)¶
Guesses the type of a coordinate.
- Parameters:
c (
xr.DataArray) – The coordinate to guess.coord (
Hashable) – The name of the coordinate.
- Returns:
The guessed coordinate type.
- Return type:
Coordinate