earthkit.data.field.component.parameter

Classes

ChemicalOpticalParameter

Parameter component representing a chemical-optical parameter.

ChemicalParameter

Parameter component representing a chemical parameter.

EmptyParameter

Empty parameter component, representing the absence of parameter information.

OpticalParameter

Parameter component representing an optical parameter.

Parameter

Parameter component representing a regular parameter.

ParameterBase

Base class for the parameter component of a field.

WaveSpectraParameter

Parameter component representing a wave spectra parameter.

Functions

create_parameter(d)

Create a ParameterBase object from a dictionary.

Module Contents

class earthkit.data.field.component.parameter.ChemicalOpticalParameter(variable=None, standard_name=None, long_name=None, units=None, chem=None, chem_long_name=None, wavelength=None, wavelength_bounds=None, wavelength_units=None)

Bases: ChemicalParameter, OpticalParameter

Parameter component representing a chemical-optical parameter.

A chemical-optical parameter includes both a chemical constituent or aerosol type and an optical wavelength. It inherits chemical properties from ChemicalParameter and optical properties from OpticalParameter.

Parameters:
  • variable (str, optional) – The parameter variable, by default None.

  • standard_name (str, optional) – The standard name of the parameter variable, by default None.

  • long_name (str, optional) – The long name of the parameter variable, by default None.

  • units (str or Units, optional) – The parameter units, by default None. Can be provided as a string or a Units object.

  • chem (str, optional) – The parameter chemical constituent or aerosol type, by default None.

  • chem_long_name (str, optional) – The long name of the parameter chemical constituent or aerosol type, by default None.

  • wavelength (int, optional) – The optical parameter wavelength in native units (see wavelength_units), by default None.

  • wavelength_bounds (2-tuple of ints, optional) – The optical parameter wavelength bounds in native units, by default None.

  • wavelength_units (str or Units, optional) – The wavelength units, by default None. Can be provided as a string or a Units object.

aliases()

Return the aliases in the component.

chem()

Return the parameter chemical constituent or aerosol type.

chem_long_name()

Return the long name of the parameter chemical constituent or aerosol type.

classmethod from_dict(d)

Create a parameter object from a dictionary.

The appropriate subclass is determined automatically based on the dictionary contents.

Parameters:

d (dict) –

Dictionary containing parameter data.

The dictionary can contain the following keys:

  • ”variable”: The parameter variable.

  • ”standard_name”: The standard name of the parameter variable.

  • ”long_name”: The long name of the parameter variable.

  • ”units”: The parameter units, as a string or a Units object.

  • ”chem”: The chemical constituent or aerosol type of the parameter.

  • ”chem_long_name”: The long name of the chemical constituent or aerosol type of the parameter.

  • ”wavelength”: The optical parameter wavelength, as an int or a float.

  • ”wavelength_bounds”: The optical parameter wavelength bounds, as a 2-tuple of ints or floats.

  • ”wavelength_units”: The wavelength units, as a string or a Units object.

  • ”wave_direction”: The wave direction of the 2D spectra parameter, as a float.

  • ”wave_direction_index”: The 0-based index of the wave direction bin.

  • ”wave_direction_bounds”: The wave direction bounds, as a 2-tuple of floats.

  • ”wave_direction_units”: The wave direction units, as a string or a Units object.

  • ”wave_frequency”: The wave frequency of the 2D spectra parameter, as a float.

  • ”wave_frequency_index”: The 0-based index of the wave frequency bin.

  • ”wave_frequency_bounds”: The wave frequency bounds, as a 2-tuple of floats.

  • ”wave_frequency_units”: The wave frequency units, as a string or a Units object.

Returns:

The created parameter instance. The actual type depends on the dictionary contents: ChemicalOpticalParameter, ChemicalParameter, OpticalParameter, WaveSpectraParameter, or Parameter.

Return type:

ParameterBase

get(key, default=None, *, astype=None, raise_on_missing=False)

Return the value for the specified key.

Parameters:
  • key (str) – The key to retrieve.

  • default (Any, optional) – The default value to return if the key is not found. Default is None.

  • astype (type, optional) – The type to which the value should be cast. Default is None.

  • raise_on_missing (bool, optional) – If True, raise a KeyError if the key is not found. Default is False.

Returns:

The value for the specified key.

Return type:

Any

Raises:

KeyError – If raise_on_missing is True and the key is not found.

keys()

Return the available keys in the component.

long_name()

Return the long name of the parameter variable.

The long name is a string representing the long name of the parameter variable

param()
set(*args, **kwargs)

Create a new instance with updated data.

The returned instance type is determined by the resulting dictionary contents, which may differ from the current instance type.

Parameters:
  • args (tuple) – Positional arguments containing parameter data. Only dictionaries are allowed.

  • kwargs (dict) – Keyword arguments containing parameter data.

  • information (The following keys can be provided to update the parameter) –

    • “variable”: The parameter variable.

    • ”units”: The parameter units, as a string or a Units object.

    • ”standard_name”: The standard name of the parameter variable.

    • ”long_name”: The long name of the parameter variable.

    • ”chem”: The chemical constituent or aerosol type of the parameter.

    • ”chem_long_name”: The long name of the chemical constituent or aerosol type of the parameter.

    • ”wavelength”: The optical parameter wavelength.

    • ”wavelength_bounds”: The optical parameter wavelength bounds, as a 2-tuple.

    • ”wavelength_units”: The wavelength units, as a string or a Units object.

    • ”wave_direction”: The wave direction of the 2D spectra parameter.

    • ”wave_direction_index”: The 0-based index of the wave direction bin.

    • ”wave_direction_bounds”: The wave direction bounds, as a 2-tuple of floats.

    • ”wave_direction_units”: The wave direction units, as a string or a Units object.

    • ”wave_frequency”: The wave frequency of the 2D spectra parameter.

    • ”wave_frequency_index”: The 0-based index of the wave frequency bin.

    • ”wave_frequency_bounds”: The wave frequency bounds, as a 2-tuple of floats.

    • ”wave_frequency_units”: The wave frequency units, as a string or a Units object.

standard_name()

Return the standard name of the parameter variable.

The standard name is a string representing the standard name of the parameter variable. It is based on the CF standard name.

to_dict()

Return a dictionary representation of the chemical-optical parameter.

units()

Return the parameter units.

The parameter units are Units objects. The units are based on Pint (when possible) and are normalised to a standard form. They can be used for unit conversions and comparisons.

variable()

Return the parameter variable.

The parameter variable is a string representing the parameter variable. At the moment it not normalised, but takes the value as it is in the source data. For example, for GRIB data, it will be the value of the “shortName” key in the GRIB message.

wave_direction(units=None)

Return the wave direction of the 2D spectra parameter.

A regular Parameter does not have wave spectra information, and this method returns None.

wave_direction_bounds(units=None)

Return the wave direction bounds of the 2D spectra parameter.

A regular Parameter does not have wave spectra information, and this method returns None.

wave_direction_index()

Return the 0-based index of the wave direction bin.

A regular Parameter does not have wave spectra information, and this method returns None.

wave_direction_units()

Return the units of the wave direction.

A regular Parameter does not have wave spectra information, and this method returns None.

wave_frequency(units=None)

Return the wave frequency of the 2D spectra parameter.

A regular Parameter does not have wave spectra information, and this method returns None.

wave_frequency_bounds(units=None)

Return the wave frequency bounds of the 2D spectra parameter.

A regular Parameter does not have wave spectra information, and this method returns None.

wave_frequency_index()

Return the 0-based index of the wave frequency bin.

A regular Parameter does not have wave spectra information, and this method returns None.

wave_frequency_units()

Return the units of the wave frequency.

A regular Parameter does not have wave spectra information, and this method returns None.

wavelength(units=None)

Return the optical parameter wavelength.

A regular Parameter does not have optical information, and this method returns None.

wavelength_bounds(units=None)

Return the optical parameter wavelength bounds.

A regular Parameter does not have optical information, and this method returns None.

wavelength_units()

Return the units of the optical parameter wavelength.

A regular Parameter does not have optical information, and this method returns None.

class earthkit.data.field.component.parameter.ChemicalParameter(variable=None, standard_name=None, long_name=None, units=None, chem=None, chem_long_name=None)

Bases: Parameter

Parameter component representing a chemical parameter.

A chemical parameter includes a chemical constituent or aerosol type identifier. For parameters that also have optical wavelength information, use ChemicalOpticalParameter.

Parameters:
  • variable (str, optional) – The parameter variable, by default None.

  • standard_name (str, optional) – The standard name of the parameter variable, by default None.

  • long_name (str, optional) – The long name of the parameter variable, by default None.

  • units (str or Units, optional) – The parameter units, by default None. Can be provided as a string or a Units object.

  • chem (str, optional) – The parameter chemical constituent or aerosol type, by default None.

  • chem_long_name (str, optional) – The long name of the parameter chemical constituent or aerosol type, by default None.

aliases()

Return the aliases in the component.

chem()

Return the parameter chemical constituent or aerosol type.

chem_long_name()

Return the long name of the parameter chemical constituent or aerosol type.

classmethod from_dict(d)

Create a parameter object from a dictionary.

The appropriate subclass is determined automatically based on the dictionary contents.

Parameters:

d (dict) –

Dictionary containing parameter data.

The dictionary can contain the following keys:

  • ”variable”: The parameter variable.

  • ”standard_name”: The standard name of the parameter variable.

  • ”long_name”: The long name of the parameter variable.

  • ”units”: The parameter units, as a string or a Units object.

  • ”chem”: The chemical constituent or aerosol type of the parameter.

  • ”chem_long_name”: The long name of the chemical constituent or aerosol type of the parameter.

  • ”wavelength”: The optical parameter wavelength, as an int or a float.

  • ”wavelength_bounds”: The optical parameter wavelength bounds, as a 2-tuple of ints or floats.

  • ”wavelength_units”: The wavelength units, as a string or a Units object.

  • ”wave_direction”: The wave direction of the 2D spectra parameter, as a float.

  • ”wave_direction_index”: The 0-based index of the wave direction bin.

  • ”wave_direction_bounds”: The wave direction bounds, as a 2-tuple of floats.

  • ”wave_direction_units”: The wave direction units, as a string or a Units object.

  • ”wave_frequency”: The wave frequency of the 2D spectra parameter, as a float.

  • ”wave_frequency_index”: The 0-based index of the wave frequency bin.

  • ”wave_frequency_bounds”: The wave frequency bounds, as a 2-tuple of floats.

  • ”wave_frequency_units”: The wave frequency units, as a string or a Units object.

Returns:

The created parameter instance. The actual type depends on the dictionary contents: ChemicalOpticalParameter, ChemicalParameter, OpticalParameter, WaveSpectraParameter, or Parameter.

Return type:

ParameterBase

get(key, default=None, *, astype=None, raise_on_missing=False)

Return the value for the specified key.

Parameters:
  • key (str) – The key to retrieve.

  • default (Any, optional) – The default value to return if the key is not found. Default is None.

  • astype (type, optional) – The type to which the value should be cast. Default is None.

  • raise_on_missing (bool, optional) – If True, raise a KeyError if the key is not found. Default is False.

Returns:

The value for the specified key.

Return type:

Any

Raises:

KeyError – If raise_on_missing is True and the key is not found.

keys()

Return the available keys in the component.

long_name()

Return the long name of the parameter variable.

The long name is a string representing the long name of the parameter variable

param()
set(*args, **kwargs)

Create a new instance with updated data.

The returned instance type is determined by the resulting dictionary contents, which may differ from the current instance type.

Parameters:
  • args (tuple) – Positional arguments containing parameter data. Only dictionaries are allowed.

  • kwargs (dict) – Keyword arguments containing parameter data.

  • information (The following keys can be provided to update the parameter) –

    • “variable”: The parameter variable.

    • ”units”: The parameter units, as a string or a Units object.

    • ”standard_name”: The standard name of the parameter variable.

    • ”long_name”: The long name of the parameter variable.

    • ”chem”: The chemical constituent or aerosol type of the parameter.

    • ”chem_long_name”: The long name of the chemical constituent or aerosol type of the parameter.

    • ”wavelength”: The optical parameter wavelength.

    • ”wavelength_bounds”: The optical parameter wavelength bounds, as a 2-tuple.

    • ”wavelength_units”: The wavelength units, as a string or a Units object.

    • ”wave_direction”: The wave direction of the 2D spectra parameter.

    • ”wave_direction_index”: The 0-based index of the wave direction bin.

    • ”wave_direction_bounds”: The wave direction bounds, as a 2-tuple of floats.

    • ”wave_direction_units”: The wave direction units, as a string or a Units object.

    • ”wave_frequency”: The wave frequency of the 2D spectra parameter.

    • ”wave_frequency_index”: The 0-based index of the wave frequency bin.

    • ”wave_frequency_bounds”: The wave frequency bounds, as a 2-tuple of floats.

    • ”wave_frequency_units”: The wave frequency units, as a string or a Units object.

standard_name()

Return the standard name of the parameter variable.

The standard name is a string representing the standard name of the parameter variable. It is based on the CF standard name.

to_dict()

Return a dictionary representation of the chemical parameter.

units()

Return the parameter units.

The parameter units are Units objects. The units are based on Pint (when possible) and are normalised to a standard form. They can be used for unit conversions and comparisons.

variable()

Return the parameter variable.

The parameter variable is a string representing the parameter variable. At the moment it not normalised, but takes the value as it is in the source data. For example, for GRIB data, it will be the value of the “shortName” key in the GRIB message.

wave_direction(units=None)

Return the wave direction of the 2D spectra parameter.

A regular Parameter does not have wave spectra information, and this method returns None.

wave_direction_bounds(units=None)

Return the wave direction bounds of the 2D spectra parameter.

A regular Parameter does not have wave spectra information, and this method returns None.

wave_direction_index()

Return the 0-based index of the wave direction bin.

A regular Parameter does not have wave spectra information, and this method returns None.

wave_direction_units()

Return the units of the wave direction.

A regular Parameter does not have wave spectra information, and this method returns None.

wave_frequency(units=None)

Return the wave frequency of the 2D spectra parameter.

A regular Parameter does not have wave spectra information, and this method returns None.

wave_frequency_bounds(units=None)

Return the wave frequency bounds of the 2D spectra parameter.

A regular Parameter does not have wave spectra information, and this method returns None.

wave_frequency_index()

Return the 0-based index of the wave frequency bin.

A regular Parameter does not have wave spectra information, and this method returns None.

wave_frequency_units()

Return the units of the wave frequency.

A regular Parameter does not have wave spectra information, and this method returns None.

wavelength(units=None)

Return the optical parameter wavelength.

A regular Parameter does not have optical information, and this method returns None.

wavelength_bounds(units=None)

Return the optical parameter wavelength bounds.

A regular Parameter does not have optical information, and this method returns None.

wavelength_units()

Return the units of the optical parameter wavelength.

A regular Parameter does not have optical information, and this method returns None.

class earthkit.data.field.component.parameter.EmptyParameter

Bases: ParameterBase

Empty parameter component, representing the absence of parameter information.

aliases()

Return the aliases in the component.

chem()

Return the parameter chemical constituent or aerosol type.

An EmptyParameter does not contain any parameter information, and this method returns None.

chem_long_name()

Return the long name of the parameter chemical constituent or aerosol type.

An EmptyParameter does not contain any parameter information, and this method returns None.

classmethod from_dict(d)

Create an EmptyParameter object from a dictionary.

get(key, default=None, *, astype=None, raise_on_missing=False)

Return the value for the specified key.

Parameters:
  • key (str) – The key to retrieve.

  • default (Any, optional) – The default value to return if the key is not found. Default is None.

  • astype (type, optional) – The type to which the value should be cast. Default is None.

  • raise_on_missing (bool, optional) – If True, raise a KeyError if the key is not found. Default is False.

Returns:

The value for the specified key.

Return type:

Any

Raises:

KeyError – If raise_on_missing is True and the key is not found.

keys()

Return the available keys in the component.

long_name()

Return the long name of the parameter variable.

An EmptyParameter does not contain any parameter information, and this method returns None.

param()
set(*args, **kwargs)

Create a new instance with updated data.

An EmptyParameter object cannot be updated, and this method raises a ValueError.

standard_name()

Return the standard name of the parameter variable.

An EmptyParameter does not contain any parameter information, and this method returns None.

to_dict()

Return a dictionary representation of the EmptyParameter.

units()

Return the parameter units.

An EmptyParameter does not contain any parameter information, and this method returns None.

variable()

Return the parameter variable.

An EmptyParameter does not contain any parameter information, and this method returns None.

wave_direction(units=None)

Return the wave direction of the 2D spectra parameter.

An EmptyParameter does not contain any parameter information, and this method returns None.

wave_direction_bounds(units=None)

Return the wave direction bounds of the 2D spectra parameter.

An EmptyParameter does not contain any parameter information, and this method returns None.

wave_direction_index()

Return the 0-based index of the wave direction bin.

An EmptyParameter does not contain any parameter information, and this method returns None.

wave_direction_units()

Return the units of the wave direction.

An EmptyParameter does not contain any parameter information, and this method returns None.

wave_frequency(units=None)

Return the wave frequency of the 2D spectra parameter.

An EmptyParameter does not contain any parameter information, and this method returns None.

wave_frequency_bounds(units=None)

Return the wave frequency bounds of the 2D spectra parameter.

An EmptyParameter does not contain any parameter information, and this method returns None.

wave_frequency_index()

Return the 0-based index of the wave frequency bin.

An EmptyParameter does not contain any parameter information, and this method returns None.

wave_frequency_units()

Return the units of the wave frequency.

An EmptyParameter does not contain any parameter information, and this method returns None.

wavelength(units=None)

Return the optical parameter wavelength.

An EmptyParameter does not contain any parameter information, and this method returns None.

wavelength_bounds(units=None)

Return the optical parameter wavelength bounds.

An EmptyParameter does not contain any parameter information, and this method returns None.

wavelength_units()

Return the units of the optical parameter wavelength.

An EmptyParameter does not contain any parameter information, and this method returns None.

class earthkit.data.field.component.parameter.OpticalParameter(variable=None, standard_name=None, long_name=None, units=None, wavelength=None, wavelength_bounds=None, wavelength_units=None)

Bases: Parameter

Parameter component representing an optical parameter.

An optical parameter includes a wavelength but no chemical constituent. For parameters that have both chemical and optical properties, use ChemicalOpticalParameter.

Parameters:
  • variable (str, optional) – The parameter variable, by default None.

  • standard_name (str, optional) – The standard name of the parameter variable, by default None.

  • long_name (str, optional) – The long name of the parameter variable, by default None.

  • units (str or Units, optional) – The parameter units, by default None. Can be provided as a string or a Units object.

  • wavelength (int, optional) – The optical parameter wavelength in native units (see wavelength_units), by default None.

  • wavelength_bounds (2-tuple of ints, optional) – The optical parameter wavelength bounds in native units, by default None.

  • wavelength_units (str or Units, optional) – The wavelength units, by default None. Can be provided as a string or a Units object.

aliases()

Return the aliases in the component.

chem()

Return the parameter chemical constituent or aerosol type.

A regular Parameter does not have chemical information, and this method returns None.

chem_long_name()

Return the long name of the parameter chemical constituent or aerosol type.

A regular Parameter does not have chemical information, and this method returns None.

classmethod from_dict(d)

Create a parameter object from a dictionary.

The appropriate subclass is determined automatically based on the dictionary contents.

Parameters:

d (dict) –

Dictionary containing parameter data.

The dictionary can contain the following keys:

  • ”variable”: The parameter variable.

  • ”standard_name”: The standard name of the parameter variable.

  • ”long_name”: The long name of the parameter variable.

  • ”units”: The parameter units, as a string or a Units object.

  • ”chem”: The chemical constituent or aerosol type of the parameter.

  • ”chem_long_name”: The long name of the chemical constituent or aerosol type of the parameter.

  • ”wavelength”: The optical parameter wavelength, as an int or a float.

  • ”wavelength_bounds”: The optical parameter wavelength bounds, as a 2-tuple of ints or floats.

  • ”wavelength_units”: The wavelength units, as a string or a Units object.

  • ”wave_direction”: The wave direction of the 2D spectra parameter, as a float.

  • ”wave_direction_index”: The 0-based index of the wave direction bin.

  • ”wave_direction_bounds”: The wave direction bounds, as a 2-tuple of floats.

  • ”wave_direction_units”: The wave direction units, as a string or a Units object.

  • ”wave_frequency”: The wave frequency of the 2D spectra parameter, as a float.

  • ”wave_frequency_index”: The 0-based index of the wave frequency bin.

  • ”wave_frequency_bounds”: The wave frequency bounds, as a 2-tuple of floats.

  • ”wave_frequency_units”: The wave frequency units, as a string or a Units object.

Returns:

The created parameter instance. The actual type depends on the dictionary contents: ChemicalOpticalParameter, ChemicalParameter, OpticalParameter, WaveSpectraParameter, or Parameter.

Return type:

ParameterBase

get(key, default=None, *, astype=None, raise_on_missing=False)

Return the value for the specified key.

Parameters:
  • key (str) – The key to retrieve.

  • default (Any, optional) – The default value to return if the key is not found. Default is None.

  • astype (type, optional) – The type to which the value should be cast. Default is None.

  • raise_on_missing (bool, optional) – If True, raise a KeyError if the key is not found. Default is False.

Returns:

The value for the specified key.

Return type:

Any

Raises:

KeyError – If raise_on_missing is True and the key is not found.

keys()

Return the available keys in the component.

long_name()

Return the long name of the parameter variable.

The long name is a string representing the long name of the parameter variable

param()
set(*args, **kwargs)

Create a new instance with updated data.

The returned instance type is determined by the resulting dictionary contents, which may differ from the current instance type.

Parameters:
  • args (tuple) – Positional arguments containing parameter data. Only dictionaries are allowed.

  • kwargs (dict) – Keyword arguments containing parameter data.

  • information (The following keys can be provided to update the parameter) –

    • “variable”: The parameter variable.

    • ”units”: The parameter units, as a string or a Units object.

    • ”standard_name”: The standard name of the parameter variable.

    • ”long_name”: The long name of the parameter variable.

    • ”chem”: The chemical constituent or aerosol type of the parameter.

    • ”chem_long_name”: The long name of the chemical constituent or aerosol type of the parameter.

    • ”wavelength”: The optical parameter wavelength.

    • ”wavelength_bounds”: The optical parameter wavelength bounds, as a 2-tuple.

    • ”wavelength_units”: The wavelength units, as a string or a Units object.

    • ”wave_direction”: The wave direction of the 2D spectra parameter.

    • ”wave_direction_index”: The 0-based index of the wave direction bin.

    • ”wave_direction_bounds”: The wave direction bounds, as a 2-tuple of floats.

    • ”wave_direction_units”: The wave direction units, as a string or a Units object.

    • ”wave_frequency”: The wave frequency of the 2D spectra parameter.

    • ”wave_frequency_index”: The 0-based index of the wave frequency bin.

    • ”wave_frequency_bounds”: The wave frequency bounds, as a 2-tuple of floats.

    • ”wave_frequency_units”: The wave frequency units, as a string or a Units object.

standard_name()

Return the standard name of the parameter variable.

The standard name is a string representing the standard name of the parameter variable. It is based on the CF standard name.

to_dict()

Return a dictionary representation of the optical parameter.

units()

Return the parameter units.

The parameter units are Units objects. The units are based on Pint (when possible) and are normalised to a standard form. They can be used for unit conversions and comparisons.

variable()

Return the parameter variable.

The parameter variable is a string representing the parameter variable. At the moment it not normalised, but takes the value as it is in the source data. For example, for GRIB data, it will be the value of the “shortName” key in the GRIB message.

wave_direction(units=None)

Return the wave direction of the 2D spectra parameter.

A regular Parameter does not have wave spectra information, and this method returns None.

wave_direction_bounds(units=None)

Return the wave direction bounds of the 2D spectra parameter.

A regular Parameter does not have wave spectra information, and this method returns None.

wave_direction_index()

Return the 0-based index of the wave direction bin.

A regular Parameter does not have wave spectra information, and this method returns None.

wave_direction_units()

Return the units of the wave direction.

A regular Parameter does not have wave spectra information, and this method returns None.

wave_frequency(units=None)

Return the wave frequency of the 2D spectra parameter.

A regular Parameter does not have wave spectra information, and this method returns None.

wave_frequency_bounds(units=None)

Return the wave frequency bounds of the 2D spectra parameter.

A regular Parameter does not have wave spectra information, and this method returns None.

wave_frequency_index()

Return the 0-based index of the wave frequency bin.

A regular Parameter does not have wave spectra information, and this method returns None.

wave_frequency_units()

Return the units of the wave frequency.

A regular Parameter does not have wave spectra information, and this method returns None.

wavelength(units=None)

Return the optical parameter wavelength.

Parameters:

units (str or Units, optional) – If provided, convert the wavelength to the specified units and return as float. If None, return the value in native units.

wavelength_bounds(units=None)

Return the optical parameter wavelength bounds.

Parameters:

units (str or Units, optional) – If provided, convert the bounds to the specified units and return as tuple of floats. If None, return the value in native units.

wavelength_units()

Return the units of the optical parameter wavelength.

class earthkit.data.field.component.parameter.Parameter(variable=None, standard_name=None, long_name=None, units=None)

Bases: ParameterBase

Parameter component representing a regular parameter.

A regular parameter is one that does not have any chemical, optical, or wave spectra properties. For parameters with chemical constituents, use ChemicalParameter. For parameters with optical wavelength information, use OpticalParameter. For parameters with both chemical and optical properties, use ChemicalOpticalParameter. For parameters with wave spectra properties, use WaveSpectraParameter.

Parameters:
  • variable (str, optional) – The parameter variable, by default None.

  • standard_name (str, optional) – The standard name of the parameter variable, by default None.

  • long_name (str, optional) – The long name of the parameter variable, by default None.

  • units (str or Units, optional) – The parameter units, by default None. Can be provided as a string or a Units object.

aliases()

Return the aliases in the component.

chem()

Return the parameter chemical constituent or aerosol type.

A regular Parameter does not have chemical information, and this method returns None.

chem_long_name()

Return the long name of the parameter chemical constituent or aerosol type.

A regular Parameter does not have chemical information, and this method returns None.

classmethod from_dict(d)

Create a parameter object from a dictionary.

The appropriate subclass is determined automatically based on the dictionary contents.

Parameters:

d (dict) –

Dictionary containing parameter data.

The dictionary can contain the following keys:

  • ”variable”: The parameter variable.

  • ”standard_name”: The standard name of the parameter variable.

  • ”long_name”: The long name of the parameter variable.

  • ”units”: The parameter units, as a string or a Units object.

  • ”chem”: The chemical constituent or aerosol type of the parameter.

  • ”chem_long_name”: The long name of the chemical constituent or aerosol type of the parameter.

  • ”wavelength”: The optical parameter wavelength, as an int or a float.

  • ”wavelength_bounds”: The optical parameter wavelength bounds, as a 2-tuple of ints or floats.

  • ”wavelength_units”: The wavelength units, as a string or a Units object.

  • ”wave_direction”: The wave direction of the 2D spectra parameter, as a float.

  • ”wave_direction_index”: The 0-based index of the wave direction bin.

  • ”wave_direction_bounds”: The wave direction bounds, as a 2-tuple of floats.

  • ”wave_direction_units”: The wave direction units, as a string or a Units object.

  • ”wave_frequency”: The wave frequency of the 2D spectra parameter, as a float.

  • ”wave_frequency_index”: The 0-based index of the wave frequency bin.

  • ”wave_frequency_bounds”: The wave frequency bounds, as a 2-tuple of floats.

  • ”wave_frequency_units”: The wave frequency units, as a string or a Units object.

Returns:

The created parameter instance. The actual type depends on the dictionary contents: ChemicalOpticalParameter, ChemicalParameter, OpticalParameter, WaveSpectraParameter, or Parameter.

Return type:

ParameterBase

get(key, default=None, *, astype=None, raise_on_missing=False)

Return the value for the specified key.

Parameters:
  • key (str) – The key to retrieve.

  • default (Any, optional) – The default value to return if the key is not found. Default is None.

  • astype (type, optional) – The type to which the value should be cast. Default is None.

  • raise_on_missing (bool, optional) – If True, raise a KeyError if the key is not found. Default is False.

Returns:

The value for the specified key.

Return type:

Any

Raises:

KeyError – If raise_on_missing is True and the key is not found.

keys()

Return the available keys in the component.

long_name()

Return the long name of the parameter variable.

The long name is a string representing the long name of the parameter variable

param()
set(*args, **kwargs)

Create a new instance with updated data.

The returned instance type is determined by the resulting dictionary contents, which may differ from the current instance type.

Parameters:
  • args (tuple) – Positional arguments containing parameter data. Only dictionaries are allowed.

  • kwargs (dict) – Keyword arguments containing parameter data.

  • information (The following keys can be provided to update the parameter) –

    • “variable”: The parameter variable.

    • ”units”: The parameter units, as a string or a Units object.

    • ”standard_name”: The standard name of the parameter variable.

    • ”long_name”: The long name of the parameter variable.

    • ”chem”: The chemical constituent or aerosol type of the parameter.

    • ”chem_long_name”: The long name of the chemical constituent or aerosol type of the parameter.

    • ”wavelength”: The optical parameter wavelength.

    • ”wavelength_bounds”: The optical parameter wavelength bounds, as a 2-tuple.

    • ”wavelength_units”: The wavelength units, as a string or a Units object.

    • ”wave_direction”: The wave direction of the 2D spectra parameter.

    • ”wave_direction_index”: The 0-based index of the wave direction bin.

    • ”wave_direction_bounds”: The wave direction bounds, as a 2-tuple of floats.

    • ”wave_direction_units”: The wave direction units, as a string or a Units object.

    • ”wave_frequency”: The wave frequency of the 2D spectra parameter.

    • ”wave_frequency_index”: The 0-based index of the wave frequency bin.

    • ”wave_frequency_bounds”: The wave frequency bounds, as a 2-tuple of floats.

    • ”wave_frequency_units”: The wave frequency units, as a string or a Units object.

standard_name()

Return the standard name of the parameter variable.

The standard name is a string representing the standard name of the parameter variable. It is based on the CF standard name.

to_dict()

Return a dictionary representation of the parameter.

units()

Return the parameter units.

The parameter units are Units objects. The units are based on Pint (when possible) and are normalised to a standard form. They can be used for unit conversions and comparisons.

variable()

Return the parameter variable.

The parameter variable is a string representing the parameter variable. At the moment it not normalised, but takes the value as it is in the source data. For example, for GRIB data, it will be the value of the “shortName” key in the GRIB message.

wave_direction(units=None)

Return the wave direction of the 2D spectra parameter.

A regular Parameter does not have wave spectra information, and this method returns None.

wave_direction_bounds(units=None)

Return the wave direction bounds of the 2D spectra parameter.

A regular Parameter does not have wave spectra information, and this method returns None.

wave_direction_index()

Return the 0-based index of the wave direction bin.

A regular Parameter does not have wave spectra information, and this method returns None.

wave_direction_units()

Return the units of the wave direction.

A regular Parameter does not have wave spectra information, and this method returns None.

wave_frequency(units=None)

Return the wave frequency of the 2D spectra parameter.

A regular Parameter does not have wave spectra information, and this method returns None.

wave_frequency_bounds(units=None)

Return the wave frequency bounds of the 2D spectra parameter.

A regular Parameter does not have wave spectra information, and this method returns None.

wave_frequency_index()

Return the 0-based index of the wave frequency bin.

A regular Parameter does not have wave spectra information, and this method returns None.

wave_frequency_units()

Return the units of the wave frequency.

A regular Parameter does not have wave spectra information, and this method returns None.

wavelength(units=None)

Return the optical parameter wavelength.

A regular Parameter does not have optical information, and this method returns None.

wavelength_bounds(units=None)

Return the optical parameter wavelength bounds.

A regular Parameter does not have optical information, and this method returns None.

wavelength_units()

Return the units of the optical parameter wavelength.

A regular Parameter does not have optical information, and this method returns None.

class earthkit.data.field.component.parameter.ParameterBase

Bases: earthkit.data.field.component.component.SimpleFieldComponent

Base class for the parameter component of a field.

This class defines the interface for parameter components, which can represent different types of parameter information. Some of the methods may not be applicable to all parameter types (e.g. chem()), and may return None.

The parameter information can be accessed by methods like variable(), units(), and chem(). Each of these methods has an associated key that can be used in the get() method to retrieve the corresponding information. The list of supported keys are as follows:

  • “variable”: string representing the parameter variable

  • “standard_name”: string representing the standard name of the parameter variable, based

    on the CF standard name

  • “long_name”: string representing the long name of the parameter variable

  • “units”: as a string or a Units object representing the parameter units

  • “chem”: string representing the parameter chemical constituent or aerosol type, or None

  • “chem_long_name”: string representing the long name of the parameter chemical constituent or aerosol type, or None

  • “wavelength”: int or float representing the optical parameter wavelength, or None

  • “wavelength_bounds”: 2-tuple of ints or floats representing the optical parameter wavelength bounds, or None

  • “wavelength_units”: Units object representing the wavelength units (e.g. nanometers), or None

  • “wave_direction”: float representing the wave direction of the 2D spectra parameter, or None

  • “wave_direction_index”: int representing the 0-based index of the wave direction bin, or None

  • “wave_direction_bounds”: 2-tuple of floats representing the wave direction bounds, or None

  • “wave_direction_units”: Units object representing the wave direction units (e.g. degrees), or None

  • “wave_frequency”: float representing the wave frequency of the 2D spectra parameter, or None

  • “wave_frequency_index”: int representing the 0-based index of the wave frequency bin, or None

  • “wave_frequency_bounds”: 2-tuple of floats representing the wave frequency bounds, or None

  • “wave_frequency_units”: Units object representing the wave frequency units (e.g. 1/s), or None

  • “param”: alias of “variable”

Depending on the type of parameter information available, some of these keys may not be supported and will return None in the subclasses. For example, the “chem” key is only supported for chemical parameters, and will return None for other parameter types.

Typically, this object is used as a component of a field, and can be accessed via the parameter attribute of a field. The keys above can also be accessed via the get() method of the field, using the “parameter.” prefix.

The following example demonstrates how to access the parameter information from a field using various methods and keys:

>>> import earthkit.data as ekd
>>> field = ekd.from_source("sample", "test.grib").to_fieldlist()[0]
>>> field.parameter.variable()
'2t'
>>> field.parameter.get("variable")
'2t'
>>> field.get("parameter.variable")
'2t'

The parameter component is immutable. The set() method to create a new instance with updated values. For example, the following code creates a new parameter component with an updated variable:

>>> new_parameter = field.parameter.set(variable="msl", units="Pa")
>>> new_parameter.variable()
'msl'

We can also call the Field’s set() method to create a new field with an updated parameter component:

>>> new_field = field.set({"parameter.variable": "msl", "parameter.units": "Pa"})
>>> new_field.parameter.variable()
'msl'
aliases()

Return the aliases in the component.

abstractmethod chem()

Return the parameter chemical constituent or aerosol type.

abstractmethod chem_long_name()

Return the long name of the parameter chemical constituent or aerosol type.

classmethod from_dict(d)

Create a parameter object from a dictionary.

The appropriate subclass is determined automatically based on the dictionary contents.

Parameters:

d (dict) –

Dictionary containing parameter data.

The dictionary can contain the following keys:

  • ”variable”: The parameter variable.

  • ”standard_name”: The standard name of the parameter variable.

  • ”long_name”: The long name of the parameter variable.

  • ”units”: The parameter units, as a string or a Units object.

  • ”chem”: The chemical constituent or aerosol type of the parameter.

  • ”chem_long_name”: The long name of the chemical constituent or aerosol type of the parameter.

  • ”wavelength”: The optical parameter wavelength, as an int or a float.

  • ”wavelength_bounds”: The optical parameter wavelength bounds, as a 2-tuple of ints or floats.

  • ”wavelength_units”: The wavelength units, as a string or a Units object.

  • ”wave_direction”: The wave direction of the 2D spectra parameter, as a float.

  • ”wave_direction_index”: The 0-based index of the wave direction bin.

  • ”wave_direction_bounds”: The wave direction bounds, as a 2-tuple of floats.

  • ”wave_direction_units”: The wave direction units, as a string or a Units object.

  • ”wave_frequency”: The wave frequency of the 2D spectra parameter, as a float.

  • ”wave_frequency_index”: The 0-based index of the wave frequency bin.

  • ”wave_frequency_bounds”: The wave frequency bounds, as a 2-tuple of floats.

  • ”wave_frequency_units”: The wave frequency units, as a string or a Units object.

Returns:

The created parameter instance. The actual type depends on the dictionary contents: ChemicalOpticalParameter, ChemicalParameter, OpticalParameter, WaveSpectraParameter, or Parameter.

Return type:

ParameterBase

get(key, default=None, *, astype=None, raise_on_missing=False)

Return the value for the specified key.

Parameters:
  • key (str) – The key to retrieve.

  • default (Any, optional) – The default value to return if the key is not found. Default is None.

  • astype (type, optional) – The type to which the value should be cast. Default is None.

  • raise_on_missing (bool, optional) – If True, raise a KeyError if the key is not found. Default is False.

Returns:

The value for the specified key.

Return type:

Any

Raises:

KeyError – If raise_on_missing is True and the key is not found.

keys()

Return the available keys in the component.

abstractmethod long_name()

Return the long name of the parameter variable.

The long name is a string representing the long name of the parameter variable

param()
abstractmethod set(*args, **kwargs)

Create a new instance with updated data.

Parameters:
  • *args – Positional arguments.

  • **kwargs – Keyword arguments.

Returns:

The created FieldComponent instance.

Return type:

FieldComponent

Raises:

KeyError – If any of the keys to be set are not supported.

abstractmethod standard_name()

Return the standard name of the parameter variable.

The standard name is a string representing the standard name of the parameter variable. It is based on the CF standard name.

abstractmethod to_dict()

Convert the object to a dictionary.

Returns:

Dictionary representation of the object.

Return type:

dict

abstractmethod units()

Return the parameter units.

The parameter units are Units objects. The units are based on Pint (when possible) and are normalised to a standard form. They can be used for unit conversions and comparisons.

abstractmethod variable()

Return the parameter variable.

The parameter variable is a string representing the parameter variable. At the moment it not normalised, but takes the value as it is in the source data. For example, for GRIB data, it will be the value of the “shortName” key in the GRIB message.

abstractmethod wave_direction(units=None)

Return the wave direction of the 2D spectra parameter.

Parameters:

units (str or Units, optional) – If provided, convert the direction to the specified units and return as float. If None, return the value in native units.

abstractmethod wave_direction_bounds(units=None)

Return the wave direction bounds of the 2D spectra parameter.

Parameters:

units (str or Units, optional) – If provided, convert the bounds to the specified units and return as tuple of floats. If None, return the value in native units.

abstractmethod wave_direction_index()

Return the 0-based index of the wave direction bin.

abstractmethod wave_direction_units()

Return the units of the wave direction.

abstractmethod wave_frequency(units=None)

Return the wave frequency of the 2D spectra parameter.

Parameters:

units (str or Units, optional) – If provided, convert the frequency to the specified units and return as float. If None, return the value in native units.

abstractmethod wave_frequency_bounds(units=None)

Return the wave frequency bounds of the 2D spectra parameter.

Parameters:

units (str or Units, optional) – If provided, convert the bounds to the specified units and return as tuple of floats. If None, return the value in native units.

abstractmethod wave_frequency_index()

Return the 0-based index of the wave frequency bin.

abstractmethod wave_frequency_units()

Return the units of the wave frequency.

abstractmethod wavelength(units=None)

Return the optical parameter wavelength.

Parameters:

units (str or Units, optional) – If provided, convert the wavelength to the specified units and return as float. If None, return the value in native units.

abstractmethod wavelength_bounds(units=None)

Return the optical parameter wavelength bounds.

Parameters:

units (str or Units, optional) – If provided, convert the bounds to the specified units and return as tuple of floats. If None, return the value in native units.

abstractmethod wavelength_units()

Return the units of the optical parameter wavelength.

class earthkit.data.field.component.parameter.WaveSpectraParameter(variable=None, standard_name=None, long_name=None, units=None, wave_direction=None, wave_direction_index=None, wave_direction_bounds=None, wave_direction_units=None, wave_frequency=None, wave_frequency_index=None, wave_frequency_bounds=None, wave_frequency_units=None)

Bases: Parameter

Parameter component representing a wave spectra parameter.

A wave spectra parameter includes wave direction and/or wave frequency information from 2D wave spectra fields.

Parameters:
  • variable (str, optional) – The parameter variable, by default None.

  • standard_name (str, optional) – The standard name of the parameter variable, by default None.

  • long_name (str, optional) – The long name of the parameter variable, by default None.

  • units (str or Units, optional) – The parameter units, by default None. Can be provided as a string or a Units object.

  • wave_direction (float, optional) – The wave direction of the 2D spectra parameter in native units (see wave_direction_units), by default None.

  • wave_direction_index (int, optional) – The 0-based index of the wave direction bin, by default None.

  • wave_direction_bounds (2-tuple of floats, optional) – The wave direction bounds in native units, by default None.

  • wave_direction_units (str or Units, optional) – The wave direction units, by default None. Can be provided as a string or a Units object.

  • wave_frequency (float, optional) – The wave frequency of the 2D spectra parameter in native units (see wave_frequency_units), by default None.

  • wave_frequency_index (int, optional) – The 0-based index of the wave frequency bin, by default None.

  • wave_frequency_bounds (2-tuple of floats, optional) – The wave frequency bounds in native units, by default None.

  • wave_frequency_units (str or Units, optional) – The wave frequency units, by default None. Can be provided as a string or a Units object.

aliases()

Return the aliases in the component.

chem()

Return the parameter chemical constituent or aerosol type.

A regular Parameter does not have chemical information, and this method returns None.

chem_long_name()

Return the long name of the parameter chemical constituent or aerosol type.

A regular Parameter does not have chemical information, and this method returns None.

classmethod from_dict(d)

Create a parameter object from a dictionary.

The appropriate subclass is determined automatically based on the dictionary contents.

Parameters:

d (dict) –

Dictionary containing parameter data.

The dictionary can contain the following keys:

  • ”variable”: The parameter variable.

  • ”standard_name”: The standard name of the parameter variable.

  • ”long_name”: The long name of the parameter variable.

  • ”units”: The parameter units, as a string or a Units object.

  • ”chem”: The chemical constituent or aerosol type of the parameter.

  • ”chem_long_name”: The long name of the chemical constituent or aerosol type of the parameter.

  • ”wavelength”: The optical parameter wavelength, as an int or a float.

  • ”wavelength_bounds”: The optical parameter wavelength bounds, as a 2-tuple of ints or floats.

  • ”wavelength_units”: The wavelength units, as a string or a Units object.

  • ”wave_direction”: The wave direction of the 2D spectra parameter, as a float.

  • ”wave_direction_index”: The 0-based index of the wave direction bin.

  • ”wave_direction_bounds”: The wave direction bounds, as a 2-tuple of floats.

  • ”wave_direction_units”: The wave direction units, as a string or a Units object.

  • ”wave_frequency”: The wave frequency of the 2D spectra parameter, as a float.

  • ”wave_frequency_index”: The 0-based index of the wave frequency bin.

  • ”wave_frequency_bounds”: The wave frequency bounds, as a 2-tuple of floats.

  • ”wave_frequency_units”: The wave frequency units, as a string or a Units object.

Returns:

The created parameter instance. The actual type depends on the dictionary contents: ChemicalOpticalParameter, ChemicalParameter, OpticalParameter, WaveSpectraParameter, or Parameter.

Return type:

ParameterBase

get(key, default=None, *, astype=None, raise_on_missing=False)

Return the value for the specified key.

Parameters:
  • key (str) – The key to retrieve.

  • default (Any, optional) – The default value to return if the key is not found. Default is None.

  • astype (type, optional) – The type to which the value should be cast. Default is None.

  • raise_on_missing (bool, optional) – If True, raise a KeyError if the key is not found. Default is False.

Returns:

The value for the specified key.

Return type:

Any

Raises:

KeyError – If raise_on_missing is True and the key is not found.

keys()

Return the available keys in the component.

long_name()

Return the long name of the parameter variable.

The long name is a string representing the long name of the parameter variable

param()
set(*args, **kwargs)

Create a new instance with updated data.

The returned instance type is determined by the resulting dictionary contents, which may differ from the current instance type.

Parameters:
  • args (tuple) – Positional arguments containing parameter data. Only dictionaries are allowed.

  • kwargs (dict) – Keyword arguments containing parameter data.

  • information (The following keys can be provided to update the parameter) –

    • “variable”: The parameter variable.

    • ”units”: The parameter units, as a string or a Units object.

    • ”standard_name”: The standard name of the parameter variable.

    • ”long_name”: The long name of the parameter variable.

    • ”chem”: The chemical constituent or aerosol type of the parameter.

    • ”chem_long_name”: The long name of the chemical constituent or aerosol type of the parameter.

    • ”wavelength”: The optical parameter wavelength.

    • ”wavelength_bounds”: The optical parameter wavelength bounds, as a 2-tuple.

    • ”wavelength_units”: The wavelength units, as a string or a Units object.

    • ”wave_direction”: The wave direction of the 2D spectra parameter.

    • ”wave_direction_index”: The 0-based index of the wave direction bin.

    • ”wave_direction_bounds”: The wave direction bounds, as a 2-tuple of floats.

    • ”wave_direction_units”: The wave direction units, as a string or a Units object.

    • ”wave_frequency”: The wave frequency of the 2D spectra parameter.

    • ”wave_frequency_index”: The 0-based index of the wave frequency bin.

    • ”wave_frequency_bounds”: The wave frequency bounds, as a 2-tuple of floats.

    • ”wave_frequency_units”: The wave frequency units, as a string or a Units object.

standard_name()

Return the standard name of the parameter variable.

The standard name is a string representing the standard name of the parameter variable. It is based on the CF standard name.

to_dict()

Return a dictionary representation of the wave spectra parameter.

units()

Return the parameter units.

The parameter units are Units objects. The units are based on Pint (when possible) and are normalised to a standard form. They can be used for unit conversions and comparisons.

variable()

Return the parameter variable.

The parameter variable is a string representing the parameter variable. At the moment it not normalised, but takes the value as it is in the source data. For example, for GRIB data, it will be the value of the “shortName” key in the GRIB message.

wave_direction(units=None)

Return the wave direction of the 2D spectra parameter.

Parameters:

units (str or Units, optional) – If provided, convert the direction to the specified units and return as float. If None, return the value in native units.

wave_direction_bounds(units=None)

Return the wave direction bounds of the 2D spectra parameter.

Parameters:

units (str or Units, optional) – If provided, convert the bounds to the specified units and return as tuple of floats. If None, return the value in native units.

wave_direction_index()

Return the 0-based index of the wave direction bin.

wave_direction_units()

Return the units of the wave direction.

wave_frequency(units=None)

Return the wave frequency of the 2D spectra parameter.

Parameters:

units (str or Units, optional) – If provided, convert the frequency to the specified units and return as float. If None, return the value in native units.

wave_frequency_bounds(units=None)

Return the wave frequency bounds of the 2D spectra parameter.

Parameters:

units (str or Units, optional) – If provided, convert the bounds to the specified units and return as tuple of floats. If None, return the value in native units.

wave_frequency_index()

Return the 0-based index of the wave frequency bin.

wave_frequency_units()

Return the units of the wave frequency.

wavelength(units=None)

Return the optical parameter wavelength.

A regular Parameter does not have optical information, and this method returns None.

wavelength_bounds(units=None)

Return the optical parameter wavelength bounds.

A regular Parameter does not have optical information, and this method returns None.

wavelength_units()

Return the units of the optical parameter wavelength.

A regular Parameter does not have optical information, and this method returns None.

earthkit.data.field.component.parameter.create_parameter(d)

Create a ParameterBase object from a dictionary.

The appropriate subclass is determined automatically based on the dictionary contents:

Parameters:

d (dict) – Dictionary containing parameter data.

Returns:

The created parameter instance. The actual type depends on the dictionary contents.

Return type:

ParameterBase