pycontrails.models.dry_advection.DryAdvection¶
- class pycontrails.models.dry_advection.DryAdvection(met=None, params=None, **params_kwargs)¶
Bases:
ModelSimulate “dry advection” of an emissions plume with an elliptical cross section.
The model simulates both horizontal and vertical advection of a weightless plume without any sedimentation effects. Unlike
Cocip, humidity is not considered, and radiative forcing is not simulated. The model is therefore useful simulating plume advection and dispersion itself.Added in version 0.46.0.
This model has two distinct modes of operation:
- Pointwise only: If
azimuthis None, then the model will only advect points without any wind shear effects. This mode is useful for testing the advection algorithm itself, and for simulating the evolution of a single point.
- Pointwise only: If
- Wind shear effects: If
azimuthis not None, then the model will advect points with wind shear effects. At each time step, the model will evolve the plume geometry according to diffusion and wind shear effects. This mode is also used in
CocipGridandCocip.
- Wind shear effects: If
- Parameters:
met (
MetDataset) – Meteorological data.params (
dict[str,Any]) – Model parameters. SeeDryAdvectionParamsfor details.**kwargs (
Any) – Additional parameters passed as keyword arguments.
- __init__(met=None, params=None, **params_kwargs)¶
Methods
__init__([met, params])Return an ECMWF-specific list of required meteorology variables.
eval([source])Simulate dry advection (no sedimentation) of arbitrary points.
Return a model-agnostic list of required meteorology variables.
get_data_param(other, key[, default, set_attr])Get data from other source-compatible object with default set by model parameter key.
get_source_param(key[, default, set_attr])Get source data with default set by parameter key.
Return a GFS-specific list of required meteorology variables.
Ensure that
metis a MetDataset.require_source_type(type_)Ensure that
sourceistype_.set_source([source])Attach original or copy of input
sourcetosource.set_source_met([optional, variable])Ensure or interpolate each required
met_variablesonsource.transfer_met_source_attrs([source])Transfer met source metadata from
mettosource.update_params([params])Update model parameters on
params.Attributes
Meteorology data
Instantiated model parameters, in dictionary form
Data evaluated in model
Generate a unique hash for model instance.
Shortcut to create interpolation arguments from
params.Require meteorology is not None on __init__()
Required meteorology pressure level variables.
Set of required parameters if processing already complete on
metinput.Optional meteorology variables
- default_params¶
alias of
DryAdvectionParams
- downselect_met()¶
Downselect
metdomain to the max/min bounds ofsource.Override this method if special handling is needed in met down-selection.
sourcemust be defined before callingdownselect_met().This method copies and re-assigns
metusingmet.copy()to avoid side-effects.
- Raises:
ValueError – Raised if
sourceis not defined. Raised ifsourceis not aGeoVectorDataset.
- classmethod ecmwf_met_variables()¶
Return an ECMWF-specific list of required meteorology variables.
- Returns:
tuple[MetVariable]– List of ECMWF-specific variants of required variables
- eval(source=None, **params)¶
Simulate dry advection (no sedimentation) of arbitrary points.
Like
Cocip, this model adds a “waypoint” column to thesource.- Parameters:
source (
GeoVectorDataset | None) – Arbitrary points to advect. AFlightinstance is not treated any differently than aGeoVectorDataset. In particular, the user must explicitly setflight["azimuth"] = flight.segment_azimuth()if they want to use wind shear effects for a flight. In the current implementation, any existing meteorological variables in thesourceare ignored. Thesourcewill be interpolated against themetdataset.**params (
Any) – Overwrite model parameters defined in__init__.
- Returns:
GeoVectorDataset– Advected points.
- classmethod generic_met_variables()¶
Return a model-agnostic list of required meteorology variables.
- Returns:
tuple[MetVariable]– List of model-agnostic variants of required variables
- get_data_param(other, key, default=<object object>, *, set_attr=True)¶
Get data from other source-compatible object with default set by model parameter key.
Retrieves data with the following hierarchy:
other.data[key]. Returnsnp.ndarray | xr.DataArray.other.attrs[key]params[key]default
In case 3., the value of
params[key]is attached toother.attrs[key]unlessset_attris set to False.- Parameters:
- Returns:
Any– Value(s) found for key inotherdata,otherattrs, or model params- Raises:
KeyError – Raises KeyError if key is not found in any location and
defaultis not provided.
- 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:
source.data[key]. Returnsnp.ndarray | xr.DataArray.source.attrs[key]params[key]default
In case 3., the value of
params[key]is attached tosource.attrs[key]unlessset_attris set to False.- Parameters:
- 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
defaultis not provided.
- classmethod gfs_met_variables()¶
Return a GFS-specific list of required meteorology variables.
- Returns:
tuple[MetVariable]– List of GFS-specific variants of required variables
- 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 = 'Emission plume advection without sedimentation'¶
- met¶
Meteorology data
- met_required = True¶
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='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.'), 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='w', standard_name='lagrangian_tendency_of_air_pressure', long_name='Vertical Velocity (omega)', level_type='isobaricInhPa', ecmwf_id=135, grib1_id=39, grib2_id=(0, 2, 8), units='Pa s**-1', amip='wap', description='The Lagrangian tendency of air pressure, often called "omega", plays the role of the upward component of air velocity when air pressure is being used as the vertical coordinate. If the vertical air velocity is upwards, it is negative when expressed as a tendency of air pressure; downwards is positive. Air pressure is the force per unit area which would be exerted when the moving gas molecules of which the air is composed strike a theoretical surface of any orientation.'))¶
Required meteorology pressure level variables. Each element in the list is a
MetVariableor atuple[MetVariable]. If element is atuple[MetVariable], the variable depends on the data source and the tuple must include entries for a model-agnostic variable, an ECMWF-specific variable, and a GFS-specific variable. Only one of the three variable in the tuple is required for model evaluation.
- name = 'dry_advection'¶
- 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
metinput.
- require_met()¶
Ensure that
metis a MetDataset.- Returns:
MetDataset– Returns reference tomet. This is helpful for type narrowingmetwhen meteorology is required.- Raises:
ValueError – Raises when
metis None.
- require_source_type(type_)¶
Ensure that
sourceistype_.- Returns:
_Source– Returns reference tosource. This is helpful for type narrowingsourceto specific type(s).- Raises:
ValueError – Raises when
sourceis not_type_.
- set_source(source=None)¶
Attach original or copy of input
sourcetosource.- Parameters:
source (
MetDataset | GeoVectorDataset | Flight | Iterable[Flight] | None) – Parametersourcepassed ineval(). If None, an empty MetDataset with coordinates likemetis set tosource.
See also
- set_source_met(optional=False, variable=None)¶
Ensure or interpolate each required
met_variablesonsource.For each variable in
met_variables, checksourcefor data variable with the same name.For
GeoVectorDatasetsources, try to interpolatemetif variable does not exist.For
MetDatasetsources, try to get data frommetif variable does not exist.- Parameters:
optional (
bool, optional) – Includeoptional_met_variablesvariable (
MetVariable | Sequence[MetVariable] | None, optional) – MetVariable to set, frommet_variables. If None, set all variables inmet_variablesandoptional_met_variablesifoptionalis True.
- Raises:
ValueError – Variable does not exist and
sourceis a MetDataset.
- source¶
Data evaluated in model