pycontrails.models.pcr¶
Persistent contrail regions (PCR = SAC & ISSR).
Equivalent to (SAC & ISSR)
Functions
| 
 | Calculate regions of persistent contrail formation. | 
Classes
| 
 | Determine points with likely persistent contrails (PCR). | 
| 
 | Persistent Contrail Regions (PCR) parameters. | 
- class pycontrails.models.pcr.PCR(met=None, params=None, **params_kwargs)¶
- Bases: - Model- Determine points with likely persistent contrails (PCR). - Intersection of Ice Super Saturated Regions (ISSR) with regions in which the Schmidt-Appleman Criteria (SAC) is satisfied. - Parameters:
- met ( - MetDataset) – Dataset containing “air_temperature”, “specific_humidity” variables
- params ( - dict[str,- Any], optional) – Override PCR model parameters with dictionary. See- PCRGridParamsfor model parameters.
- **params_kwargs – Override PCR model parameters with keyword arguments. See - PCRGridParamsfor model parameters.
 
 - downselect_met()¶
- Downselect - metdomain to the max/min bounds of- source.- Override this method if special handling is needed in met down-selection. - sourcemust be defined before calling- downselect_met().
- This method copies and re-assigns - metusing- met.copy()to avoid side-effects.
 - Raises:
- ValueError – Raised if - sourceis not defined. Raised if- sourceis not a- GeoVectorDataset.
 
 
 - 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)¶
- Evaluate potential contrails regions of the - metgrid.- Parameters:
- source ( - GeoVectorDataset | Flight | MetDataset | None, optional) – Input GeoVectorDataset or Flight. If None, evaluates at the- metgrid points.
- **params ( - Any) – Overwrite model parameters.
 
- Returns:
- GeoVectorDataset | Flight | MetDataset– Returns 1 in potential contrail regions, 0 everywhere else. Returns- np.nanif interpolating outside meteorology grid.
 
 - 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]. Returns- np.ndarray | xr.DataArray.
- other.attrs[key]
- params[key]
- default
 - In case 3., the value of - params[key]is attached to- other.attrs[key]unless- set_attris set to False.- Parameters:
- Returns:
- Any– Value(s) found for key in- otherdata,- 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]. Returns- np.ndarray | xr.DataArray.
- source.attrs[key]
- params[key]
- default
 - In case 3., the value of - params[key]is attached to- source.attrs[key]unless- set_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 = 'Persistent contrail regions'¶
 - 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.'))¶
- Required meteorology pressure level variables. Each element in the list is a - MetVariableor a- tuple[MetVariable]. If element is a- tuple[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 = 'pcr'¶
 - 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 to- met. This is helpful for type narrowing- metwhen meteorology is required.
- Raises:
- ValueError – Raises when - metis None.
 
 - require_source_type(type_)¶
- Ensure that - sourceis- type_.- Returns:
- _Source– Returns reference to- source. This is helpful for type narrowing- sourceto specific type(s).
- Raises:
- ValueError – Raises when - sourceis not- _type_.
 
 - set_source(source=None)¶
- Attach original or copy of input - sourceto- source.- Parameters:
- source ( - MetDataset | GeoVectorDataset | Flight | Iterable[Flight] | None) – Parameter- sourcepassed in- eval(). If None, an empty MetDataset with coordinates like- metis set to- source.
 - See also 
 - set_source_met(optional=False, variable=None)¶
- Ensure or interpolate each required - met_variableson- source.- For each variable in - met_variables, check- sourcefor data variable with the same name.- For - GeoVectorDatasetsources, try to interpolate- metif variable does not exist.- For - MetDatasetsources, try to get data from- metif variable does not exist.- Parameters:
- optional ( - bool, optional) – Include- optional_met_variables
- variable ( - MetVariable | Sequence[MetVariable] | None, optional) – MetVariable to set, from- met_variables. If None, set all variables in- met_variablesand- optional_met_variablesif- optionalis True.
 
- Raises:
- ValueError – Variable does not exist and - sourceis a MetDataset.
 
 
 - source¶
- Data evaluated in model 
 
- class pycontrails.models.pcr.PCRParams(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')), rhi_threshold=1.0, humidity_scaling=None, engine_efficiency=0.3, fuel=<factory>)¶
- Bases: - SACParams,- ISSRParams- Persistent Contrail Regions (PCR) 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.
 
 - copy_source = True¶
- Copy input - sourcedata on eval
 - downselect_met = True¶
- Downselect input - MetDataset`to region around- source.
 - engine_efficiency = 0.3¶
- Jet engine efficiency, [\(0 - 1\)] 
 - fuel¶
- Fuel type. Overridden by Fuel provided on input - sourceattributes
 - 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_erroris 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.RegularGridInterpolatorfor 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". If- None, 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 to- interpolate_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 when- downselect_metis True.
 - met_level_buffer = (0.0, 0.0)¶
- Met level buffer for input to - Flight.downselect_met(), in [\(hPa\)]. Only applies when- downselect_metis True.
 - met_longitude_buffer = (0.0, 0.0)¶
- Met longitude buffer for input to - Flight.downselect_met(), in WGS84 coordinates. Only applies when- downselect_metis True.
 - met_time_buffer = (np.timedelta64(0,'h'), np.timedelta64(0,'h'))¶
- Met time buffer for input to - Flight.downselect_met()Only applies when- downselect_metis True.
 - rhi_threshold = 1.0¶
- RHI Threshold 
 - verify_met = True¶
- Call - _verify_met()on model instantiation.
 
- pycontrails.models.pcr.pcr(air_temperature, specific_humidity, air_pressure, engine_efficiency, ei_h2o, q_fuel)¶
- Calculate regions of persistent contrail formation. - Ice Super Saturated Regions (ISSR) where the Schmidt-Appleman Criteria (SAC) is satisfied. - Parameters of type - ArrayLikemust have compatible shapes.- Parameters:
- air_temperature ( - ArrayLike) – A sequence or array of temperature values, [\(K\)]
- specific_humidity ( - ArrayLike) – A sequence or array of specific humidity values, [\(kg_{H_{2}O} \ kg_{air}^{-1}\)]
- air_pressure ( - ArrayLike) – A sequence or array of atmospheric pressure values, [\(Pa\)].
- engine_efficiency ( - float | ArrayLike) – Engine efficiency, [\(0 - 1\)]
- ei_h2o ( - float) – Emission index of water vapor, [\(kg \ kg^{-1}\)]
- q_fuel ( - float) – Specific combustion heat of fuel combustion, [\(J \ kg^{-1} \ K^{-1}\)]
 
- Returns: