openairclim.calc_cont

Calculates the contrail response.

openairclim.calc_cont.add_inv_to_base(inv_dict, base_inv_dict)[source]

Adds the inventory dictionary to the base inventory dictionary. Currently, the keys of the inventory dictionary must be a subset of the keys of the base inventory dictionary. In other words, the inventories must align to at least one year. This function is used when rel_to_base is TRUE.

Parameters:
  • inv_dict (dict) – Dictionary of emission inventory xarrays, keys are inventory years.

  • base_inv_dict (dict) – Dictionary of base emission inventory xarrays, keys are inventory years.

Returns:

Summed dictionary of input inventories

Return type:

dict

openairclim.calc_cont.calc_cccov(config: dict, cfdd_dict: dict, ds_cont: Dataset, cont_grid: tuple, ac: str) dict[source]

Calculate contrail cirrus coverage using the relationship developed for AirClim 2.1 (Dahlmann et al., 2016).

Parameters:
  • config (dict) – Configuration dictionary from config file.

  • cfdd_dict (dict) – Dictionary with CFDD values [km/km2], keys are inventory years.

  • ds_cont (xr.Dataset) – Dataset of precalculated contrail data.

  • cont_grid (tuple) – Precalculated contrail grid.

  • ac (str) – Aircraft identifier from config.

Returns:

Dictionary with cccov values, keys are inventory years

Return type:

dict

openairclim.calc_cont.calc_cccov_tot(config, cccov_dict, cont_grid, ac)[source]

Calculate total, area-weighted contrail cirrus coverage using the relationship developed for AirClim 2.1 (Dahlmann et al., 2016).

Parameters:
  • config (dict) – Configuration dictionary from config file.

  • cccov_dict (dict) – Dictionary with cccov values, keys are inventory years.

  • cont_grid (tuple) – Precalculated contrail grid.

  • ac (str) – Aircraft identifier from config.

Returns:

Dictionary with total, area-weighted contrail cirrus coverage,

keys are inventory years.

Return type:

dict

openairclim.calc_cont.calc_cfdd(config: dict, inv_dict: dict, ds_cont: Dataset, cont_grid: tuple, ac: str) dict[source]

Calculate the Contrail Flight Distance Density (CFDD) for each year in inv_dict. This function uses the p_pcf data calculated using ERA5 (Megill & Grewe, 2025) or replicates the legacy AirClim 2.1 using the p_sac data calculated for the AHEAD project (Dahlmann et al., 2016; Grewe et al., 2017).

Parameters:
  • config (dict) – Configuration dictionary from config file.

  • inv_dict (dict) – Dictionary of emission inventory xarrays, keys are inventory years.

  • ds_cont (xr.Dataset) – Dataset of precalculated contrail data.

  • cont_grid (tuple) – Precalculated contrail grid.

  • ac (str) – Aircraft identifier from config.

Returns:

Dictionary with CFDD values [km/km2], keys are inventory years

Return type:

dict

openairclim.calc_cont.calc_cont_grid_areas(lat: ndarray, lon: ndarray) ndarray[source]

Calculate the cell area of the contrail grid using a simplified method.

Parameters:
  • lat (np.ndarray) – Latitudes of the grid cells [deg].

  • lon (np.ndarray) – Longitudes of the grid cells [deg].

Returns:

Contrail grid cell areas as a function of latitude [km^2].

Return type:

np.ndarray

openairclim.calc_cont.calc_cont_rf(config, cccov_tot_dict, inv_dict, cont_grid, ac)[source]

Calculate contrail Radiative Forcing (RF) using the relationship developed for AirClim 2.1 (Dahlmann et al., 2016).

Parameters:
  • config (dict) – Configuration dictionary from config file.

  • cccov_tot_dict (dict) – Dictionary with total, area-weighted contrail cirrus coverage, keys are inventory years

  • inv_dict (dict) – Dictionary of emission inventory xarrays, keys are inventory years.

  • cont_grid (tuple) – Precalculated contrail grid.

  • ac (str) – Aircraft identifier from config.

Returns:

Dictionary with contrail RF values interpolated for all years

between the simulation start and end years.

Return type:

dict

openairclim.calc_cont.calc_cont_weighting(config: dict, val: str, cont_grid: tuple, ac: str) ndarray[source]

Calculate weighting functions for the contrail grid developed by Ludwig Hüttenhofer (Bachelorarbeit LMU, 2013). This assumes the contrail grid developed for AirClim 2.1 (Dahlmann et al., 2016).

Parameters:
  • config (dict) – Configuration dictionary from config file.

  • val (str) – Weighting value to calculate. Choice of “w1”, “w2” or “w3”

  • cont_grid (tuple) – Precalculated contrail grid.

  • ac (str) – Aircraft identifier from config

Raises:

ValueError – if invalid value is passed for “val”.

Returns:

Array of size (nlat) with weighting values for each

latitude value

Return type:

np.ndarray

openairclim.calc_cont.calc_ppcf(config: dict, ds_cont: Dataset, ac: str) DataArray[source]

Calculate Potential Persistent Contrail Formation (p_PCF) using the precalculated contrail data, either from the Limiting Factors study (Megill & Grewe, 2025; default) or using the legacy AirClim 2.1 method (Dahlmann et al., 2016). The terms p_SAC (AirClim) and p_PCF (OpenAirClim) are equivalent.

Parameters:
  • config (dict) – Configuration dictionary from config file.

  • ds_cont (xr.Dataset) – Dataset of precalculated contrail data.

  • ac (str) – Aircraft identifier from config.

Returns:

Interpolated p_PCF on precalculated contrail data grid

Return type:

xr.DataArray

openairclim.calc_cont.calc_ppcf_megill(config: dict, ds_cont: Dataset, ac: str) DataArray[source]

Calculate the Potential Persistent Contrail Formation (p_PCF) using the Megill & Grewe (2025) method and precalculated data from ERA5.

Parameters:
  • config (dict) – Configuration dictionary from config file.

  • ds_cont (xr.Dataset) – Dataset of precalculated contrail data.

  • ac (str) – Aircraft identifier from config.

Returns:

Interpolated p_PCF on precalculated contrail data grid.

Return type:

xr.DataArray

openairclim.calc_cont.calc_psac_airclim(config: dict, ds_cont: Dataset, ac: str) DataArray[source]

Calculate the probability that the Schmidt-Appleman Criterion is met using the legacy AirClim 2.1 method (Dahlmann et al., 2016) and simulations performed for the AHEAD project (Grewe et al., 2017).

Parameters:
  • config (dict) – Configuration dictionary from config file.

  • ds_cont (xr.Dataset) – Dataset of precalculated contrail data.

  • ac (str) – Aircraft identifier from config.

Returns:

Interpolated p_SAC on precalculated contrail data grid.

Return type:

xr.DataArray

openairclim.calc_cont.calc_weighted_cccov(comb_cccov_dict, cfdd_dict, comb_cfdd_dict)[source]

Calculate the contrail cirrus coverage cccov weighted by the difference in the contrail flight distance densities CFDD between the input inventory and the base inventory. This function is used when rel_to_base is TRUE. The keys of all dictionaries must match.

Parameters:
  • comb_cccov_dict (dict) – Dictionary with cccov values of the inventory and base summed together, keys are years.

  • cfdd_dict (dict) – Dictionary with CFDD values of the inventory (without base), keys are years.

  • comb_cfdd_dict (dict) – Dictionary with CFDD values of the inventory and base summed together, keys are years.

Returns:

Dictionary with weighted cccov values, keys are years.

Return type:

dict

openairclim.calc_cont.check_cont_input(config, ds_cont, inv_dict, base_inv_dict)[source]

Checks the input data for the contrail module.

Parameters:
  • config (dict) – Configuration dictionary from config file.

  • ds_cont (xr.Dataset) – Dataset of precalculated contrail data.

  • inv_dict (dict) – Dictionary of emission inventory xarrays, keys are inventory years.

  • base_inv_dict (dict) – Dictionary of base emission inventory xarrays, keys are inventory years.

openairclim.calc_cont.get_cont_grid(ds_cont: Dataset) tuple[source]

Get contrail grid from ds_cont.

Parameters:

ds_cont (xr.Dataset) – Dataset of precalculated contrail data.

Returns:

Contrail grid of shape (lon, lat, plev).

Return type:

tuple

openairclim.calc_cont.interp_base_inv_dict(inv_dict, base_inv_dict, intrp_vars, cont_grid)[source]

Create base emission inventories for years in inv_dict that do not exist in base_inv_dict.

Parameters:
  • inv_dict (dict) – Dictionary of emission inventory xarrays, keys are inventory years.

  • base_inv_dict (dict) – Dictionary of base emission inventory xarrays, keys are inventory years.

  • intrp_vars (list) – List of strings of data variables in base_inv_dict that are to be included in the missing base inventories, e.g. [“distance”, “fuel”].

  • cont_grid (tuple) – Precalculated contrail grid.

Returns:

Dictionary of base emission inventory xarrays including any

missing years compared to inv_dict, keys are inventory years.

Return type:

dict

Note

A custom nearest neighbour method is used for regridding and a linear interpolation method for calculating data in missing years. In future versions, the user will be able to select methods for both.

openairclim.calc_cont.logistic(x, l, k, x0)[source]

Computes the logistic function, a sigmoid curve, commonly used to model growth or decay. Function from Megill & Grewe (2025): https://github.com/liammegill/contrail-limiting-factors

Parameters:
  • x (float or np.ndarray) – The input values for which the logistic function will be computed.

  • l (float) – The maximum value or carrying capacity of the function.

  • k (float) – The steepness of the curve.

  • x0 (float) – The midpoint value of x where the function reaches half of l.

Returns:

The logistic function values for the given

input x.

Return type:

float or array-like

openairclim.calc_cont.logistic_gen(x, l, k, x0, d)[source]

Computes a generalized logistic function with an additional vertical shift. Function from Megill & Grewe (2025): https://github.com/liammegill/contrail-limiting-factors

Parameters:
  • x (float or np.ndarray) – The input values for which the logistic function will be computed.

  • l (float) – The maximum value or carrying capacity of the function.

  • k (float) – The steepness of the curve.

  • x0 (float) – The midpoint value of x where the function reaches half of l.

  • d (float) – The vertical shift applied to the function.

Returns:

The values of the shifted logistic function for

the input x.

Return type:

float or array-like