openairclim.core.calc_swv

Calculates the impact of SWV.

openairclim.core.calc_swv.calc_swv_mass_conc(delta_ch4: ndarray, config: dict, display_distribution: bool = False) → tuple[ndarray, ndarray, DataFrame][source]

Calculates the SWV concentration and mass based on the oxidation of CH4.

It is based on the tropospheric CH4 change, the fractional release factor, and the Age-of-Air. Based on the thesis of A.J. Harmsen (2026): The Climate Impact of Stratospheric Water Vapour Caused by Aviation Emissions https://repository.tudelft.nl/record/uuid:98c4bda7-a17d-47a4-9b24-48b7b46e4bb6

Parameters:
  • delta_ch4 (numpy.ndarray) – Array of yearly changes in CH4 concentration due to an emission.

  • config (dict) – Configuration dictionary from config, used to resolve the CH4 vertical profile data (see get_alpha_aoa()) and, if display_distribution is set, the output directory to save the plot to.

  • display_distribution (bool) – Whether to plot the distribution of swv or not.

Returns:

delta_mass_swv, the total change in SWV mass in Tg due to CH4 oxidation for each year corresponding to delta_ch4; delta_conc_swv, the average stratospheric concentration change of SWV in ppbv due to CH4 oxidation for each year corresponding to delta_ch4; and final_swv_distribution, the final distribution of SWV concentration change in ppbv.

Return type:

tuple[numpy.ndarray, numpy.ndarray, pandas.DataFrame]

openairclim.core.calc_swv.calc_swv_rf(total_swv_mass: dict[str, ndarray]) → dict[str, ndarray][source]

Calculates RF due to a SWV perturbation mass.

Based on Pletzer (2024) The climate impact of hypersonic transport. https://doi.org/10.4233/uuid:39acca9a-53ba-4b9c-b9c0-b6c99f552e25.

Parameters:

total_swv_mass (dict[str, np.ndarray]) – A dict with key "SWV" and an array containing the SWV mass in Tg for the corresponding year.

Raises:
  • TypeError – if total_swv_mass is not a dict

  • ValueError – if the total mass is out of range of the plot of Pletzer (2024)

Returns:

A dict that contains the forcing due to SWV at that time

Return type:

dict[str, np.ndarray]

openairclim.core.calc_swv.construct_myhre_1m_df(config: dict) → DataFrame[source]

Reproduce HALOE data from Myhre et al. (2007).

This function produces the HALOE zonal mean vertical profile of CH4 over the period October 1991 throughout 1999. The function reads the data file configured at responses.SWV.file.

Parameters:

config (dict) – Configuration dictionary from config.

Returns:

a DataFrame that contains all data that is required by get_griddata() to provide a proper grid

Return type:

pd.DataFrame

openairclim.core.calc_swv.get_alpha_aoa(heights: ndarray, latitudes: ndarray, config: dict, plot_data: bool = False) → tuple[ndarray, DataFrame][source]

Calculate the fractional release factors and air-of-air.

This function constructs the fractional release factors for CH4 (alpha) for different altitude and latitude levels. It then calculates a matrix of age-og-air values, rounded to whole years.

Parameters:
  • heights (numpy.ndarray) – a np.array of heights in meters

  • latitudes (numpy.ndarray) – a np.array of latitudes in degrees

  • config (dict) – Configuration dictionary from config, used to resolve the CH4 vertical profile data (see construct_myhre_1m_df()) and, if plot_data is set, the output directory to save the plot to.

  • plot_data (bool) – whether to plot the data or not

Returns:

alpha, a matrix of fractional release factors for different altitude and latitude levels, and rounded_aoa, a matrix of the rounded age of air for different altitude and latitude levels.

Return type:

tuple[numpy.ndarray, pandas.DataFrame]

openairclim.core.calc_swv.get_griddata(df: DataFrame, heights: ndarray, latitudes: ndarray) → ndarray[source]

Transforms the data into an evenly spaced grid.

Uses scipy.interpolate.griddata() to transform an input dataframe df into a numpy.ndarray.

Parameters:
Returns:

A grid with x axis latitudes and y axis heights and for all gridpoints an interpolated value of df

Return type:

numpy.ndarray

openairclim.core.calc_swv.get_volume_matrix(heights: ndarray, latitudes: ndarray, delta_h: float, delta_deg: float) → ndarray[source]

Calculates the volume of every box of air in an altitude-latitude graph.

The heights and latitudes arrays should have a spacing equivalent to the corresponding delta

Parameters:
  • heights (np.ndarray) – Heights in meters

  • latitudes (np.ndarray) – Latitudes in degrees

  • delta_h (float) – Step between every height in meters

  • delta_deg (float) – Step between every latitude in degrees

Returns:

A matrix of volumes. Rows correspond to altitude levels, columns to latitudes

Return type:

np.ndarray

openairclim.core.calc_swv.plot_alpha_aoa(latitudes: ndarray, heights: ndarray, alpha: ndarray, rounded_aoa: DataFrame, output_dir: Path) → None[source]

Plot the alpha distribution as a latitude-pressure heatmap.

Plot the alpha distribution as a latitude-pressure contour plot. Plot the rounded age-of-air distribution as a latitude-pressure heatmap. Each plot is saved to output_dir.

Parameters:
  • latitudes (numpy.ndarray) – A 1D array of latitude values in degrees north.

  • heights (numpy.ndarray) – A 1D array of the heights in meters.

  • alpha (numpy.ndarray) – A 2D array of alpha values.

  • rounded_aoa (pandas.DataFrame) – A 2D frame of age-of-air values rounded to whole integer years.

  • output_dir (Path) – Directory to save the plots to.

openairclim.core.calc_swv.plot_swv_distribution(latitudes: ndarray, heights: ndarray, final_swv_distribution: DataFrame, output_dir: Path) → None[source]

Plot the SWV distribution as a latitude-pressure heatmap.

The plot is saved to output_dir.

Parameters:
  • latitudes (numpy.ndarray) – A 1D array of latitude values in degrees north.

  • heights (numpy.ndarray) – A 1D array of the heights in meters.

  • final_swv_distribution (pandas.DataFrame) – A 2D frame of SWV distribution values.

  • output_dir (Path) – Directory to save the plot to.