hgrecco / pint

Operate and manipulate physical quantities in Python
http://pint.readthedocs.org/
Other
2.42k stars 472 forks source link

Implementation of CO2eq (GWP) #1121

Closed lfaucheux closed 4 years ago

lfaucheux commented 4 years ago

Pint is really amazing. 3 Questions:

I am not physicist and I would like to implement (static) Global Warming Potentials. It all starts with radiative forcings, dimensionalized as W/m², i.e. an intensity, which already exists in the default registry,

# Intensity
[intensity] = [power] / [area]

Question 1

Does [intensity] have a given name when it is precisely instantiated as watt / meter ** 2 ?


Then it looks like we first have to imply the notion of absolute GWP (AGWP). Note that there is a time-horizon non-linear determinant behind any AGWP value. I made a python package some years ago to compute those things continuously. Yet, it seems that dealing with precomputed constants is the rule when dealing with GWPs, mainly for the sake of convenience. Let's thus adopt the culture: the most common used i) time horizons in the litterature are 5, 10, 20, 30, 50, 100 years and ii) ghgs are CO2 (of course), CH4 and N2O. The point is that the following constants are very likely -- I am not physicist -- to be true only for kilograms since the idea behind warming potential is precisely about timing of emissions <=> clearly not a linear-in-mass phenomenon.

Question 2

Does [intensity] / kg have a given name ?


In conjunction with of the notion of timing/temporality, [temporality], let's call it [absolute_global_warming_potential] for now. And only specify things for 100- and 50-year horizons for the sake of clarity,

#### Absolute Global Warming Potentials ####
agwp = [absolute_global_warming_potential] = [temporality] * [intensity] / kg

# 100-year horizon
agwp100 = nan agwp
co2_agwp100 = 8.69e-14 * agwp100
ch4_agwp100 = 2.1725e-12 * agwp100
n2o_agwp100 = 2.58962e-11 * agwp100

# 50-year horizon
agwp50 = nan agwp
co2_agwp50 = 5.100128578061494e-14 * agwp50
ch4_agwp50 = 2.1393321081948863e-12 * agwp50
n2o_agwp50 = 1.5742935781808625e-11 * agwp50

Finally, our (relative-to-CO2) GWPs

#### Relative-to-CO2 Global Warming Potentials ####
co2eq = [global_warming_potential]

# 100-year horizon
co2_gwp100 = 1.0 * co2eq
ch4_gwp100 = 25.0 * co2_gwp100 = ch4_agwp100 / co2_agwp100
n2o_gwp100 = 298.0 * co2_gwp100 = n2o_agwp100 / co2_agwp100

# 50-year horizon
co2_gwp50 = nan co2eq
ch4_gwp50 = 41.94663086333451 * co2_gwp50 = ch4_agwp50 / co2_agwp50
n2o_gwp50 = 308.6772331491366 * co2_gwp50 = n2o_agwp50 / co2_agwp50

Question 3

Any suggestion that makes more sense i) regarding Pint's conventions as such and ii) ontologically speaking ?

znicholls commented 4 years ago

hi @lfaucheux, this will probably save you a few headaches https://github.com/openscm/openscm-units (the notebook is a good starting point https://github.com/openscm/openscm-units/blob/master/notebooks/introduction.ipynb). Not all the GWPs are included but you should be able to add new ones without too much trouble in https://github.com/openscm/openscm-units/blob/master/src/openscm_units/data/metric_conversions.csv

We simply define everything in terms of CO2, and then use contexts to control how the conversion works. It means you don't have the timescale in the name (i.e. the units are 'Mt CO2/yr', not 'Mt CO2 GWP50 / yr') but it seems to do the trick and avoids requiring all these new units and conversions (and Pint makes sure you can't accidentally convert between e.g. CO2 and N2O if you haven't explicitly specified the unit context to use).

znicholls commented 4 years ago

@lfaucheux can we close this issue?

lfaucheux commented 4 years ago

@znicholls I'll be back to you in a few days about that. Thanks for your attention.

lfaucheux commented 4 years ago

@znicholls you can close it if you like. Thx again for taking time.

tfardet commented 2 years ago

Sorry for necroposting, but I was also looking for this and I suspect people that are not familiar with GitHub or development in general may miss this. Would you be OK with adding a ref to openscm-units somewhere in the doc? Maybe in the Defining units section or in the FAQ? (maybe tagging @hgrecco about that)

If it's fine with you, I can make a PR

hgrecco commented 2 years ago

@jules-ch was working on the new docs. Maybe we can put all packages using Pint in the same place.