Переглянути джерело

final fixes for AUS CRF/CRT spcifications (to fix an error in the tables)

Johannes Gütschow 1 рік тому
батько
коміт
ff9142fc3b

+ 17 - 9
UNFCCC_GHG_data/UNFCCC_CRF_reader/UNFCCC_CRF_reader_devel.py

@@ -133,18 +133,26 @@ def read_year_to_test_specs(
 
                     # if individual data for emissions and removals / recovery exist combine
                     # them
-                    if "CO2 removals" in ds_table_pm2.data_vars:
-                        # we can just sum to CO2 as in a table either net CO2 exists,
-                        # or separate removals and emissions
-                        ds_table_pm2["CO2"] = ds_table_pm2[["CO2 emissions", "CO2 removals"]].pr.sum(
+                    if (('CO2 removals' in ds_table_pm2.data_vars) and
+                            ('CO2 emissions' in ds_table_pm2.data_vars) and not
+                            ('CO2' in ds_table_pm2.data_vars)):
+                        # we can just sum to CO2 as we made sure that it doesn't exist.
+                        # If we have CO2 and removals but not emissions, CO2 already has
+                        # removals subtracted and we do nothing here
+                        ds_table_pm2["CO2"] = ds_table_pm2[["CO2 emissions",
+                                                            "CO2 removals"]].pr.sum(
                             dim="entity", skipna=True, min_count=1
                         )
                         ds_table_pm2["CO2"].attrs["entity"] = "CO2"
-                    
-                    if "CH4 removals" in ds_table_pm2.data_vars:
-                        # we can just sum to CO2 as in a table either net CO2 exists,
-                        # or separate removals and emissions
-                        ds_table_pm2["CH4"] = ds_table_pm2[["CH4 emissions", "CH4 removals"]].pr.sum(
+
+                    if (('CH4 removals' in ds_table_pm2.data_vars) and
+                            ('CH4 emissions' in ds_table_pm2.data_vars) and not
+                            ('CH4' in ds_table_pm2.data_vars)):
+                        # we can just sum to CH4 as we made sure that it doesn't exist.
+                        # If we have CH4 and removals but not emissions, CH4 already has
+                        # removals subtracted and we do nothing here
+                        ds_table_pm2["CH4"] = ds_table_pm2[["CH4 emissions",
+                                                            "CH4 removals"]].pr.sum(
                             dim="entity", skipna=True, min_count=1
                         )
                         ds_table_pm2["CH4"].attrs["entity"] = "CH4"

+ 4 - 2
UNFCCC_GHG_data/UNFCCC_CRF_reader/crf_specifications/CRF2023_AUS_specification.py

@@ -784,8 +784,10 @@ CRF2023_AUS = {
             ["NA", ["\IGNORE"], 1],
         ],
         "entity_mapping": {
-            "EMISSIONS (1) CH4": "CH4", # emissions",
-            "EMISSIONS (1) CO2": "CO2", # emissions",
+            "EMISSIONS (1) CH4": "CH4 emissions", # this is necessary because there
+            # is an error in the table and the CH4 emissions don't have the removals
+            # subtracted which would be correct according to the footnotes
+            "EMISSIONS (1) CO2": "CO2", #  emissions",
             "RECOVERY/FLARING (2) CH4": "CH4 removals",
             "RECOVERY/FLARING (2) CO2": "CO2 removals",
         },