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” variablessurface (
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])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.
Ensure that
met
is a MetDataset.require_source_type
(type_)Ensure that
source
istype_
.set_source
([source])Attach original or copy of input
source
tosource
.set_source_met
([optional, variable])Ensure or interpolate each required
met_variables
onsource
.transfer_met_source_attrs
([source])Transfer met source metadata from
met
tosource
.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
met
input.Optional meteorology variables
- default_params¶
alias of
ACCFParams
- downselect_met()¶
Downselect
met
domain to the max/min bounds ofsource
.Override this method if special handling is needed in met down-selection.
source
must be defined before callingdownselect_met()
.This method copies and re-assigns
met
usingmet.copy()
to avoid side-effects.
- Raises:
ValueError – Raised if
source
is not defined. Raised ifsource
is not aGeoVectorDataset
.
- 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 themet
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:
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]
.- 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
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 atuple[MetVariable]
. If element is atuple[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 tomet
. This is helpful for type narrowingmet
when meteorology is required.- Raises:
ValueError – Raises when
met
is None.
- require_source_type(type_)¶
Ensure that
source
istype_
.- Returns:
_Source
– Returns reference tosource
. This is helpful for type narrowingsource
to specific type(s).- Raises:
ValueError – Raises when
source
is not_type_
.
- set_source(source=None)¶
Attach original or copy of input
source
tosource
.- Parameters:
source (
MetDataset | GeoVectorDataset | Flight | Iterable[Flight] | None
) – Parametersource
passed ineval()
. If None, an empty MetDataset with coordinates likemet
is set tosource
.
See also
-
meth:eval
- set_source_met(optional=False, variable=None)¶
Ensure or interpolate each required
met_variables
onsource
.For each variable in
met_variables
, checksource
for data variable with the same name.For
GeoVectorDataset
sources, try to interpolatemet
if variable does not exist.For
MetDataset
sources, try to get data frommet
if variable does not exist.- Parameters:
optional (
bool
, optional) – Includeoptional_met_variables
variable (
MetVariable | Sequence[MetVariable] | None
, optional) – MetVariable to set, frommet_variables
. If None, set all variables inmet_variables
andoptional_met_variables
ifoptional
is True.
- Raises:
ValueError – Variable does not exist and
source
is a MetDataset.
- 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'))¶