pycontrails.models.pcc¶
Probability of persistent contrail coverage (PCC).
Classes
|
Potential Contrail Coverage Algorithm. |
|
PCC Model Parameters. |
- class pycontrails.models.pcc.PCC(met, surface, params=None, **params_kwargs)¶
Bases:
Model
Potential Contrail Coverage Algorithm.
Determines the potential of ambient atmosphere to allow contrail formation at grid points.
- Parameters:
met (
MetDataset
) – Dataset containingmet_variables
variables.surface (
MetDataset
) – Surface level dataset containing “air_pressure”.params (
dict[str
,Any]
, optional) – Override PCC model parameters with dictionary. SeePCCParams
for model parameters.**params_kwargs – Override PCC model parameters with keyword arguments. See
PCCParams
for model parameters.
Notes
Based on Ponater et al. (2002)
- Slingo1980(T, p, iwc, q, rh_crit_old, rh_crit_new)¶
Apply Slingo scheme described in Wood and Field, 1999.
Relationships between Total Water, Condensed Water, and Cloud Fraction in Stratiform Clouds Examined Using Aircraft Data
- Parameters:
T (
xarray:DataArray
) – Air Temperature, [\(K\)]p (
xarray:DataArray
) – Air Pressure, [\(Pa\)]iwc (
xarray:DataArray
) – Cloud ice water content, [\(kg \ kg^{-1}\)]q (
xarray:DataArray
) – Specific humidityrh_crit_old (
xarray:DataArray
) – Critical relative humidity, [\([0 - 1]\)]rh_crit_new (
xarray:DataArray
) – Critical relative humidity, [\([0 - 1]\)]
- Returns:
xarray:DataArray
– Probability of cirrus formation, [\([0 - 1]\)]
- Smith1990(T, p, iwc, q, rh_crit_old, rh_crit_new)¶
Apply Smith Scheme described in Rap et al. (2009).
Parameterization of contrails in the UK Met OfficeClimate Model;
- Parameters:
T (
xarray:DataArray
) – Air Temperature, [\(K\)]p (
xarray:DataArray
) – Air Pressure, [\(Pa\)]iwc (
xarray:DataArray
) – Cloud ice water content, [\(kg \ kg^{-1}\)]q (
xarray:DataArray
) – Specific humidityrh_crit_old (
xarray:DataArray
) – Critical relative humidity, [\([0 - 1]\)]rh_crit_new (
xarray:DataArray
) – Critical relative humidity, [\([0 - 1]\)]
- Returns:
xarray:DataArray
– Probability of cirrus formation, [\([0 - 1]\)]
- Sundqvist1989(T, p, iwc, q, rh_crit_old, rh_crit_new)¶
Apply Sundqvist scheme described in Ponater et al. (2002).
Contrails in a comprehensive global climate model: Parameterization and radiative forcing results
- Parameters:
T (
xarray:DataArray
) – Air Temperature, [\(K\)]p (
xarray:DataArray
) – Air Pressure, [\(Pa\)]iwc (
xarray:DataArray
) – Cloud ice water content, [\(kg \ kg^{-1}\)]q (
xarray:DataArray
) – Specific humidityrh_crit_old (
xarray:DataArray
) – Critical relative humidity, [\([0 - 1]\)]rh_crit_new (
xarray:DataArray
) – Critical relative humidity, [\([0 - 1]\)]
- Returns:
xarray:DataArray
– Probability of cirrus formation, [\([0 - 1]\)]
- b_contr()¶
Calculate critical relative humidity threshold of contrail formation.
- Returns:
xarray.DataArray
– Critical relative humidity of contrail formation, [\([0 - 1]\)]
Notes
Instead of using a prescribed threshold relative humidity for
rh_crit_old
the threshold relative humidity now change with pressure.This equation is described in Roeckner et al. 1996, Eq.57 THE ATMOSPHERIC GENERAL CIRCULATION MODEL ECHAM-4: MODEL DESCRIPTION AND SIMULATION OF PRESENT-DAY CLIMATE
- 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 PCC model.
Currently only implemented to work on the
met
data input.- Parameters:
source (
MetDataset | None
, optional) –- Input MetDataset.
If None, evaluates at the
met
grid points.
**params (
Any
) – Overwrite model parameters before eval
- Returns:
MetDataArray
– PCC model output
- 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 = 'Potential contrail coverage'¶
- 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='ciwc', standard_name='specific_cloud_ice_water_content', long_name='Specific cloud ice water content', level_type='isobaricInhPa', ecmwf_id=247, grib1_id=None, grib2_id=(0, 1, 84), units='kg kg**-1', amip=None, description="This parameter is the mass of cloud ice particles per kilogram of the total mass of moist air. The 'total mass of moist air' is the sum of the dry air, water vapour, cloud liquid, cloud ice, rain and falling snow. This parameter represents the average value for a grid box."))¶
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 = 'pcc'¶
- 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 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
- surface¶
- class pycontrails.models.pcc.PCCParams(copy_source=True, interpolation_method='linear', interpolation_bounds_error=False, interpolation_fill_value=nan, interpolation_localize=False, interpolation_use_indices=False, interpolation_q_method=None, verify_met=True, downselect_met=True, met_longitude_buffer=(0.0, 0.0), met_latitude_buffer=(0.0, 0.0), met_level_buffer=(0.0, 0.0), met_time_buffer=(np.timedelta64(0, 'h'), np.timedelta64(0, 'h')), cloud_model='Smith1990', rh_crit_factor=0.7, fuel=<factory>, engine_efficiency=0.35, humidity_scaling=None)¶
Bases:
ModelParams
PCC Model Parameters.
- as_dict()¶
Convert object to dictionary.
We use this method instead of dataclasses.asdict to use a shallow/unrecursive copy. This will return values as Any instead of dict.
- Returns:
dict[str
,Any]
– Dictionary version of self.
- cloud_model = 'Smith1990'¶
Cloud model Options include “Smith1990”, “Sundqvist1989”, “Slingo1980”
- copy_source = True¶
Copy input
source
data on eval
- downselect_met = True¶
Downselect input
MetDataset`
to region aroundsource
.
- engine_efficiency = 0.35¶
Engine efficiency
- fuel¶
Fuel type
- humidity_scaling = None¶
Humidity scaling
- interpolation_bounds_error = False¶
If True, points lying outside interpolation will raise an error
- interpolation_fill_value = nan¶
Used for outside interpolation value if
interpolation_bounds_error
is False
- interpolation_localize = False¶
Experimental. See
pycontrails.core.interpolation
.
- interpolation_method = 'linear'¶
Interpolation method. Supported methods include “linear”, “nearest”, “slinear”, “cubic”, and “quintic”. See
scipy.interpolate.RegularGridInterpolator
for the description of each method. Not all methods are supported by all met grids. For example, the “cubic” method requires at least 4 points per dimension.
- interpolation_q_method = None¶
Experimental. Alternative interpolation method to account for specific humidity lapse rate bias. Must be one of
None
,"cubic-spline"
, or"log-q-log-p"
. IfNone
, no special interpolation is used for specific humidity. The"cubic-spline"
method applies a custom stretching of the met interpolation table to account for the specific humidity lapse rate bias. The"log-q-log-p"
method interpolates in the log of specific humidity and pressure, then converts back to specific humidity. Only used by models calling tointerpolate_met()
.
- interpolation_use_indices = False¶
Experimental. See
pycontrails.core.interpolation
.
- met_latitude_buffer = (0.0, 0.0)¶
Met latitude buffer for input to
Flight.downselect_met()
, in WGS84 coordinates. Only applies whendownselect_met
is True.
- met_level_buffer = (0.0, 0.0)¶
Met level buffer for input to
Flight.downselect_met()
, in [\(hPa\)]. Only applies whendownselect_met
is True.
- met_longitude_buffer = (0.0, 0.0)¶
Met longitude buffer for input to
Flight.downselect_met()
, in WGS84 coordinates. Only applies whendownselect_met
is True.
- met_time_buffer = (np.timedelta64(0,'h'), np.timedelta64(0,'h'))¶
Met time buffer for input to
Flight.downselect_met()
Only applies whendownselect_met
is True.
- rh_crit_factor = 0.7¶
Critical RH Factor for the model to cirrus clouds
- verify_met = True¶
Call
_verify_met()
on model instantiation.