Closed rouille closed 3 months ago
Some changes requested. It would be helpful if you could test passing the following to see what it returns:
* 2022 (should return AR6 numbers) * "AR4" (should return AR4) * Test several variations of AR5 with and without the CC feedback.
In the last version of the code where I have a print of the ipcc_version
(to be removed before merging) at the end of the if
/else
logic, I have got the following:
>>> import pandas as pd
>>> from emissions import calculate_co2e_mass
>>> calculate_co2e_mass(pd.DataFrame(), 2022)
AR6
>>> calculate_co2e_mass(pd.DataFrame(), "latest")
AR6
>>> calculate_co2e_mass(pd.DataFrame(), "AR4")
AR4
>>> calculate_co2e_mass(pd.DataFrame(), "AR5")
AR5
>>> calculate_co2e_mass(pd.DataFrame(), "AR5_cc")
AR5_cc
>>> calculate_co2e_mass(pd.DataFrame(), "AR5", ar5_climate_carbon_feedback=True)
AR5
>>> calculate_co2e_mass(pd.DataFrame(), "AR5", ar5_climate_carbon_feedback=False)
AR5
>>> calculate_co2e_mass(pd.DataFrame(), "AR5_cc", ar5_climate_carbon_feedback=False)
AR5_cc
>>> calculate_co2e_mass(pd.DataFrame(), "AR5_cc", ar5_climate_carbon_feedback=True)
AR5_cc
>>> calculate_co2e_mass(pd.DataFrame(), "AR7")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/brdo/Singularity/open-grid-emissions/src/oge/emissions.py", line 418, in calculate_co2e_mass
raise ValueError(
ValueError: version must be a year > 1995 or a valid AR
>>> calculate_co2e_mass(pd.DataFrame(), 1990)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/brdo/Singularity/open-grid-emissions/src/oge/emissions.py", line 418, in calculate_co2e_mass
raise ValueError(
ValueError: version must be a year >= 1995 or a valid AR
>>>
Looks good to me! Should be ready to merge.
Purpose
Allow to calculate a CO2 mass equivalent value using a Global Warming Potential (GWP) value published in any available IPCC's assessment report (AR).
What the code is doing
Modify the
calculate_co2e_mass
function such that its second parameter can be used to fetch not only the most recent AR that was available in the given year as done previously but also to directly fetch the AR.Testing
Tested manually
Where to look
In the
oge.emissions
moduleUsage Example/Visuals
Review estimate
2min
Future work
N/A
Checklist
black