pycontrails.models.emissions.Emissions

class pycontrails.models.emissions.Emissions(met=None, params=None, **params_kwargs)

Bases: Model

Emissions handling using ICAO Emissions Databank (EDB) and black carbon correlations.

Parameters:
  • met (MetDataset | None, optional) – Met data, by default None.

  • params (dict[str, Any] | None, optional) – Model parameters, by default None.

  • params_kwargs (Any) – Model parameters passed as keyword arguments.

References

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

Methods

__init__([met, params])

downselect_met()

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

eval([source])

Calculate the emissions data for source.

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

processed_met_variables

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

optional_met_variables

Optional meteorology variables

default_params

alias of EmissionsParams

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)

Calculate the emissions data for source.

Parameter source must contain each of the variables:
  • air_temperature

  • specific_humidity

  • true_airspeed

  • fuel_flow

If ‘engine_uid’ is not provided in source.attrs or not available in the ICAO EDB, constant emission indices will be assumed for NOx, CO, HC, and nvPM mass and number.

The computed pollutants include carbon dioxide (CO2), nitrogen oxide (NOx), carbon monoxide (CO), hydrocarbons (HC), non-volatile particulate matter (nvPM) mass and number, sulphur oxides (SOx), sulphates (S) and organic carbon (OC).

Changed in version 0.47.0: Support GeoVectorDataset for the source parameter.

Parameters:
  • source (GeoVectorDataset) – Flight to evaluate

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

Returns:

GeoVectorDataset – Flight with attached emissions data

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 = 'ICAO Emissions Databank (EDB)'
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.'))

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 = 'emissions'
optional_met_variables

Optional meteorology variables

params

Instantiated model parameters, in dictionary form

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

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.