pycontrails.models.accf.ACCF

class pycontrails.models.accf.ACCF(met, surface=None, params=None, **params_kwargs)

Bases: Model

Compute Algorithmic Climate Change Functions (ACCF).

This class is a wrapper over the DLR / UMadrid library climaccf, DOI: 10.5281/zenodo.6977272

Parameters:
  • met (MetDataset) – Dataset containing “air_temperature” and “specific_humidity” variables

  • surface (MetDataset, optional) – Dataset containing “surface_solar_downward_radiation” and “top_net_thermal_radiation” variables

References

__init__(met, surface=None, params=None, **params_kwargs)

Methods

__init__(met[, surface, params])

downselect_met()

Downselect met domain to the max/min bounds of source.

eval([source])

Evaluate accfs along flight trajectory or on meteorology grid.

get_source_param(key[, default, set_attr])

Get source data with default set by parameter key.

require_met()

Ensure that met is a MetDataset.

require_source_type(type_)

Ensure that source is type_.

set_source([source])

Attach original or copy of input source to source.

set_source_met([optional, variable])

Ensure or interpolate each required met_variables on source .

transfer_met_source_attrs([source])

Transfer met source metadata from met to source.

update_params([params])

Update model parameters on params.

Attributes

met

Meteorology data

params

Instantiated model parameters, in dictionary form

source

Data evaluated in model

hash

Generate a unique hash for model instance.

interp_kwargs

Shortcut to create interpolation arguments from params.

long_name

met_required

Require meteorology is not None on __init__()

met_variables

Required meteorology pressure level variables.

name

path_lib

sur_variables

processed_met_variables

Set of required parameters if processing already complete on met input.

optional_met_variables

Optional meteorology variables

default_params

alias of ACCFParams

downselect_met()

Downselect met domain to the max/min bounds of source.

Override this method if special handling is needed in met down-selection.

  • source must be defined before calling downselect_met().

  • This method copies and re-assigns met using met.copy() to avoid side-effects.

Raises:
eval(source=None, **params)

Evaluate accfs along flight trajectory or on meteorology grid.

Parameters:
  • source (GeoVectorDataset | Flight | MetDataset | None, optional) – Input GeoVectorDataset or Flight. If None, evaluates at the met grid points.

  • **params (Any) – Overwrite model parameters before eval

Returns:

GeoVectorDataset | Flight | MetDataArray – Returns np.nan if interpolating outside meteorology grid.

Raises:

NotImplementedError – Raises if input source is not supported.

get_source_param(key, default=<object object>, *, set_attr=True)

Get source data with default set by parameter key.

Retrieves data with the following hierarchy:

  1. source.data[key]. Returns np.ndarray | xr.DataArray.

  2. source.attrs[key]

  3. params[key]

  4. default

In case 3., the value of params[key] is attached to source.attrs[key].

Parameters:
  • key (str) – Key to retrieve

  • default (Any, optional) – Default value if key is not found.

  • set_attr (bool, optional) – If True (default), set source.attrs[key] to params[key] if found. This allows for better post model evaluation tracking.

Returns:

Any – Value(s) found for key in source data, source attrs, or model params

Raises:

KeyError – Raises KeyError if key is not found in any location and default is not provided.

See also

-

property hash

Generate a unique hash for model instance.

Returns:

str – Unique hash for model instance (sha1)

property interp_kwargs

Shortcut to create interpolation arguments from params.

The output of this is useful for passing to interpolate_met().

Returns:

dict[str, Any] – Dictionary with keys

  • ”method”

  • ”bounds_error”

  • ”fill_value”

  • ”localize”

  • ”use_indices”

  • ”q_method”

as determined by params.

long_name = 'algorithmic climate change functions'
met

Meteorology data

met_required = False

Require meteorology is not None on __init__()

met_variables = (MetVariable(short_name='t', standard_name='air_temperature', long_name='Air Temperature', level_type='isobaricInhPa', ecmwf_id=130, grib1_id=11, grib2_id=(0, 0, 0), units='K', amip='ta', description='Air temperature is the bulk temperature of the air, not the surface (skin) temperature.'), MetVariable(short_name='q', standard_name='specific_humidity', long_name='Specific Humidity', level_type='isobaricInhPa', ecmwf_id=133, grib1_id=51, grib2_id=(0, 1, 0), units='kg kg**-1', amip='hus', description='Specific means per unit mass. Specific humidity is the mass fraction of water vapor in (moist) air.'), MetVariable(short_name='pv', standard_name='potential_vorticity', long_name='Potential vorticity (K m^2 / kg s)', level_type='isobaricInhPa', ecmwf_id=60, grib1_id=128, grib2_id=(0, 2, 14), units='K m**2 kg**-1 s**-1', amip='pvu', description='Potential vorticity is a measure of the capacity for air to rotate in the atmosphere.If we ignore the effects of heating and friction, potential vorticity is conserved following an air parcel.It is used to look for places where large wind storms are likely to originate and develop.Potential vorticity increases strongly above the tropopause and therefore, it can also be used in studiesrelated to the stratosphere and stratosphere-troposphere exchanges. Large wind storms develop when a columnof air in the atmosphere starts to rotate. Potential vorticity is calculated from the wind, temperature andpressure across a column of air in the atmosphere.'), MetVariable(short_name='z', standard_name='geopotential', long_name='Geopotential', level_type='isobaricInhPa', ecmwf_id=129, grib1_id=6, grib2_id=(0, 3, 4), units='m**2 s**-2', amip=None, description='Geopotential is the sum of the specific gravitational potential energy relative to the geoid and the specific centripetal potential energy.'), (MetVariable(short_name='r', standard_name='relative_humidity', long_name='Relative Humidity', level_type='isobaricInhPa', ecmwf_id=157, grib1_id=52, grib2_id=(0, 1, 1), units='1', amip='hur', description='This parameter is the water vapour pressure as a percentage of the value at which the air becomes saturated liquid.'), MetVariable(short_name='r', standard_name='relative_humidity', long_name='Relative Humidity', level_type='isobaricInhPa', ecmwf_id=157, grib1_id=52, grib2_id=(0, 1, 1), units='%', amip=None, description='This parameter is the water vapour pressure as a percentage of the value at which the air becomes saturated (the point at which water vapour begins to condense into liquid water or deposition into ice).For temperatures over 0°C (273.15 K) it is calculated for saturation over water. At temperatures below -23°C it is calculated for saturation over ice. Between -23°C and 0°C this parameter is calculated by interpolating between the ice and water values using a quadratic function.See https://www.ecmwf.int/sites/default/files/elibrary/2016/17117-part-iv-physical-processes.pdf#subsection.7.4.2')), MetVariable(short_name='v', standard_name='northward_wind', long_name='Northward Wind', level_type='isobaricInhPa', ecmwf_id=132, grib1_id=34, grib2_id=(0, 2, 3), units='m s**-1', amip='va', description='"Northward" indicates a vector component which is positive when directed northward (negative southward). Wind is defined as a two-dimensional (horizontal) air velocity vector, with no vertical component.'), MetVariable(short_name='u', standard_name='eastward_wind', long_name='Eastward Wind', level_type='isobaricInhPa', ecmwf_id=131, grib1_id=33, grib2_id=(0, 2, 2), units='m s**-1', amip='ua', description='"Eastward" indicates a vector component which is positive when directed eastward (negative westward). Wind is defined as a two-dimensional (horizontal) air velocity vector, with no vertical component.'))

Required meteorology pressure level variables. Each element in the list is a MetVariable or a tuple[MetVariable]. If element is a tuple[MetVariable], the variable depends on the data source. Only one variable in the tuple is required.

name = 'accr'
optional_met_variables

Optional meteorology variables

params

Instantiated model parameters, in dictionary form

path_lib = './'
processed_met_variables

Set of required parameters if processing already complete on met input.

require_met()

Ensure that met is a MetDataset.

Returns:

MetDataset – Returns reference to met. This is helpful for type narrowing met when meteorology is required.

Raises:

ValueError – Raises when met is None.

require_source_type(type_)

Ensure that source is type_.

Returns:

_Source – Returns reference to source. This is helpful for type narrowing source to specific type(s).

Raises:

ValueError – Raises when source is not _type_.

set_source(source=None)

Attach original or copy of input source to source.

Parameters:

source (MetDataset | GeoVectorDataset | Flight | Iterable[Flight] | None) – Parameter source passed in eval(). If None, an empty MetDataset with coordinates like met is set to source.

See also

-

meth:eval

set_source_met(optional=False, variable=None)

Ensure or interpolate each required met_variables on source .

For each variable in met_variables, check source for data variable with the same name.

For GeoVectorDataset sources, try to interpolate met if variable does not exist.

For MetDataset sources, try to get data from met if variable does not exist.

Parameters:
Raises:
source

Data evaluated in model

sur_variables = (MetVariable(short_name='ssrd', standard_name='surface_solar_downward_radiation', long_name='Surface Solar Downward Radiation', level_type='surface', ecmwf_id=169, grib1_id=None, grib2_id=(0, 4, 7), units='J m**-2', amip=None, description='This parameter is the amount of solar radiation (also known as shortwave radiation) that reaches a horizontal plane at the surface of the Earth. This parameter comprises both direct and diffuse solar radiation.'), MetVariable(short_name='ttr', standard_name='top_net_thermal_radiation', long_name='Top of atmosphere net thermal (longwave) radiation', level_type='nominalTop', ecmwf_id=179, grib1_id=None, grib2_id=(0, 5, 5), units='J m**-2', amip=None, description='The thermal (also known as terrestrial or longwave) radiation emitted to space at the top of the atmosphere is commonly known as the Outgoing Longwave Radiation (OLR). The top net thermal radiation (this parameter) is equal to the negative of OLR.See https://www.ecmwf.int/sites/default/files/elibrary/2015/18490-radiation-quantities-ecmwf-model-and-mars.pdf'))
transfer_met_source_attrs(source=None)

Transfer met source metadata from met to source.

update_params(params=None, **params_kwargs)

Update model parameters on params.

Parameters:
  • params (dict[str, Any], optional) – Model parameters to update, as dictionary. Defaults to {}

  • **params_kwargs (Any) – Override keys in params with keyword arguments.