pycontrails.models.ps_model.PSGrid¶
- class pycontrails.models.ps_model.PSGrid(met=None, params=None, **params_kwargs)¶
Bases:
AircraftPerformanceGrid
Compute nominal Poll-Schumann aircraft performance over a grid.
For a given aircraft type, altitude, aircraft mass, air temperature, and mach number, the PS model computes a theoretical engine efficiency and fuel flow rate for an aircraft under cruise conditions. Letting the aircraft mass vary and fixing the other parameters, the engine efficiency curve attains a single maximum at a particular aircraft mass. By solving this implicit equation, the PS model can be used to compute the aircraft mass that maximizes engine efficiency for a given set of parameters. This is the “nominal” aircraft mass computed by this model.
This nominal aircraft mass is not always realizable. For example, the maximum engine efficiency may be attained at an aircraft mass that is less than the operating empty mass of the aircraft. This model determines the minimum and maximum possible aircraft mass for a given set of parameters using a simple heuristic. The nominal aircraft mass is then clipped to this range.
- __init__(met=None, params=None, **params_kwargs)¶
Methods
__init__
([met, params])eval
([source])Evaluate the PS model over a
MetDataset
orGeoVectorDataset
.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
PSGridParams
- 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 the PS model over a
MetDataset
orGeoVectorDataset
.- Parameters:
source (
GeoVectorDataset | MetDataset | None
, optional) – The source data to use for the evaluation. If None, the source is taken from themet
attribute of thePSGrid
instance. The aircraft type is taken fromsource.attrs["aircraft_type"]
. If this field is not present,params["aircraft_type"]
is used instead. See the static CSV fileps-aircraft-params-20240524.csv
for a list of supported aircraft types.**params (
Any
) – Override the default parameters of thePSGrid
instance.
- Returns:
GeoVectorDataset | MetDataset
–The source data with the following variables added:
aircraft_mass
fuel_flow
engine_efficiency
- Raises:
NotImplementedError – If “true_airspeed” or “aircraft_mass” fields are included in
source
.
See also
- 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 = 'Poll-Schumann Aircraft Performance evaluated at arbitrary points'¶
- 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.'),)¶
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 = 'PSGrid'¶
- 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