pycontrails.ext.bada.BADAGrid¶
- class pycontrails.ext.bada.BADAGrid(met=None, params=None, **params_kwargs)¶
Bases:
AircraftPerformanceGridCompute nominal BADA values for a large grid of independent points.
This model automatically corrects engine efficiency values to ensure that they remain realistic by clipping to a nominal grid of BADA-derived values.
- Parameters:
met (
MetDataset | None, optional) – Dataset containing “air_temperature” variable. Only used if these variables are not already found on parametersourceineval(). By default None.params (
dict[str,Any], optional) – Override model parameters with dictionary. SeeBADAGridParamsfor model parameters.**params_kwargs – Override model parameters with keyword arguments. See
BADAFlightParamsfor model parameters.
See also
-meth:eval
-class:BADAGridParams
- __init__(met=None, params=None, **params_kwargs)¶
Methods
__init__([met, params])Return an ECMWF-specific list of required meteorology variables.
eval([source])Extract aircraft properties and calculate the fuel consumption.
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
Evaluated data source
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.
Optional meteorology variables
Set of required parameters if processing already complete on
metinput.- default_params¶
alias of
BADAGridParams
- 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)¶
Extract aircraft properties and calculate the fuel consumption.
- Parameters:
source (
GeoVectorDataset | None, optional) – Vector dataset defining coordinates to evaluate model. If None, the coordinates ofmetare used as evaluation points.**params (
Any) – Overwrite model parameters before eval
- Returns:
-
Data with variables:
”engine_efficiency”
”true_airspeed”
”fuel_flow”
”thrust”
”aircraft_mass”
and attributes:
”aircraft_type”
”bada_model”
”aircraft_type_bada”
”wingspan”
”max_mach”
”max_altitude”
”engine_name”
”n_engine”
- 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 = 'Base of aircraft data 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
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 = 'bada-points'¶
- optional_met_variables = (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.'))¶
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¶
Evaluated data source