tools to calculate the mean age of air from mixing ratios relative to a reference time series
Make sure to have the mandatory packages installed in your python environment:
pandas
numpy
scipy
matplotlib
the code has been tested with the following package versions, but should work for a lot of other versions, too:
pandas=2.1.1
numpy=1.26.2
scipy=1.11.3
matplotlib=3.8.0
Download the package
E.g. create an empty python file (e.g. my_project.py
) within your downloaded package
within my_project.py
you can then use the SF6_to_AoA()
and the CO2_to_AoA()
functions to derive mean age from observations:
# import everything from the run_convolution_method.py file into your current python session:
from run_convolution_method import *
t_obs_sf6 = 2022.3 # float value in fractional year, single value only
sf6mr = np.arange(9.5, 11, 0.1) # can be single value or array
ratio_of_moments = 1.2 # single value only
mean_age = SF6_to_AoA(t_obs=t_obs_sf6, SF6_obs=sf6mr, rom=ratio_of_moments)
print(mean_age)
t_obs_co2 = 2022.3 # float value in fractional year, single value only
co2mr = np.arange(400, 420, 0.5) # can be single value or array ch4mr = np.ones(co2mr.shape) * 1100.3 # must be the same size as co2mr
ratio_of_moments = 1.2 # single value only
mean_age = CO2_to_AoA(t_obs=t_obs_co2, CO2_obs=co2mr, rom=ratio_of_moments, CH4_obs=ch4mr)
print(mean_age)