Browse Source

[DATALAD] Recorded changes

Daniel Busch 3 months ago
parent
commit
ddaa097492

+ 30 - 4
src/faostat_data_primap/helper/FAO_categorisation_temp.py

@@ -1,4 +1,4 @@
-"""Do not edit this file."""
+"""Do not edit this file"""
 spec = {
     "name": "FAO",
     "title": "Food and Agriculture Organization of the United Nations (FAO) FAOSTAT data set categorisation",
@@ -2102,21 +2102,44 @@ spec = {
                 ]
             },
         },
-        "7.K": {
+        "7.J": {
             "title": "Energy Use (Pre- and Post-Production)",
             "comment": "Energy Use (Pre- and Post-Production)",
             "info": {"gases": ["CO2", "CH4", "N2O", "KYOTOGHG (AR5GWP100)"]},
         },
-        "7.L": {
+        "7.K": {
             "title": "Agrifood Systems Waste Disposal",
             "comment": "Agrifood Systems Waste Disposal",
             "info": {"gases": ["CO2", "CH4", "N2O", "KYOTOGHG (AR5GWP100)"]},
         },
-        "7.M": {
+        "7.L": {
             "title": "Cold Chain F-Gas",
             "comment": "Cold Chain F-Gas",
             "info": {"gases": ["FGASES (AR5GWP100)"]},
         },
+        "7.M": {
+            "title": "Pesticides Manufacturing",
+            "comment": "Pesticides Manufacturing",
+            "info": {"gases": ["CO2", "CH4", "N2O", "KYOTOGHG (AR5GWP100)"]},
+        },
+        "7.N": {
+            "title": "Food Processing",
+            "comment": "Food Processing",
+            "info": {
+                "gases": [
+                    "CO2",
+                    "CH4",
+                    "N2O",
+                    "KYOTOGHG (AR5GWP100)",
+                    "FGASES (AR5GWP100)",
+                ]
+            },
+        },
+        "7.O": {
+            "title": "Food Packaging",
+            "comment": "Food Packaging",
+            "info": {"gases": ["CO2", "CH4", "N2O", "KYOTOGHG (AR5GWP100)"]},
+        },
         "7": {
             "title": "Pre and post agricultural production",
             "comment": "Pre and post agricultural production",
@@ -2140,9 +2163,12 @@ spec = {
                     "7.G",
                     "7.H",
                     "7.I",
+                    "7.J",
                     "7.K",
                     "7.L",
                     "7.M",
+                    "7.N",
+                    "7.O",
                 ]
             ],
         },

+ 88 - 0
src/faostat_data_primap/helper/definitions.py

@@ -491,6 +491,32 @@ read_config_all: Any = {
                 "Emissions (N2O)": "N2O",
                 "Emissions (CO2)": "CO2",
             },
+            "category_mapping_item_element": {
+                "Forest fires - Emissions (CH4)": "6.A",
+                "Forest fires - Emissions (N2O)": "6.A",
+                "Forest fires - Emissions (CO2)": "6.A",
+                "Humid tropical forest - Emissions (CH4)": "6.A.1",
+                "Humid tropical forest - Emissions (N2O)": "6.A.1",
+                "Other forest - Emissions (CH4)": "6.A.2",
+                "Other forest - Emissions (N2O)": "6.A.2",
+                "Other forest - Emissions (CO2)": "6.A.2",
+                "Savanna fires - Emissions (CH4)": "6.B",
+                "Savanna fires - Emissions (N2O)": "6.B",
+                "Closed shrubland - Emissions (CH4)": "6.B.1",
+                "Closed shrubland - Emissions (N2O)": "6.B.1",
+                "Grassland - Emissions (CH4)": "6.B.2",
+                "Grassland - Emissions (N2O)": "6.B.2",
+                "Open shrubland - Emissions (CH4)": "6.B.3",
+                "Open shrubland - Emissions (N2O)": "6.B.3",
+                "Savanna - Emissions (CH4)": "6.B.4",
+                "Savanna - Emissions (N2O)": "6.B.4",
+                "Woody savanna - Emissions (CH4)": "6.B.5",
+                "Woody savanna - Emissions (N2O)": "6.B.5",
+                "Fires in organic soils - Emissions (CH4)": "6.C",
+                "Fires in organic soils - Emissions (CO2)": "6.C",
+                "Humid tropical forest - Emissions (CO2)": "6.A.1",
+                "Savanna fires - Emissions (CO2)": "6.B",
+            },
             "columns_to_drop": [
                 "Element",
                 "Element Code",
@@ -514,6 +540,11 @@ read_config_all: Any = {
                 "Area",
             ],
             "entity_mapping": {"Net emissions/removals (CO2) (Forest land)": "CO2"},
+            "category_mapping_item_element": {
+                "Forestland - Net emissions/removals (CO2) (Forest land)": "4.A",
+                "Net Forest conversion - Net emissions/removals (CO2) (Forest land)": "4.B",
+                "Carbon stock change in forests - Net emissions/removals (CO2) (Forest land)": "4",
+            },
             "columns_to_drop": [
                 "Element",
                 "Element Code",
@@ -577,6 +608,63 @@ read_config_all: Any = {
                 "Emissions (N2O)": "N2O",
                 "Emissions (CO2eq) from F-gases (AR5)": "FGASES (AR5GWP100)",
             },
+            "category_mapping_item_element": {
+                "Fertilizers Manufacturing - Emissions (CO2)": "7.A",
+                "Fertilizers Manufacturing - Emissions (CO2eq) (AR5)": "7.A",
+                "Food Transport - Emissions (CO2)": "7.B",
+                "Food Transport - Emissions (CH4)": "7.B",
+                "Food Transport - Emissions (N2O)": "7.B",
+                "Food Transport - Emissions (CO2eq) (AR5)": "7.B",
+                "Food Retail - Emissions (CO2)": "7.C",
+                "Food Retail - Emissions (CH4)": "7.C",
+                "Food Retail - Emissions (N2O)": "7.C",
+                "Food Retail - Emissions (CO2eq) from F-gases (AR5)": "7.C",
+                "Food Retail - Emissions (CO2eq) (AR5)": "7.C",
+                "Food Household Consumption - Emissions (CO2)": "7.D",
+                "Food Household Consumption - Emissions (CH4)": "7.D",
+                "Food Household Consumption - Emissions (N2O)": "7.D",
+                "Food Household Consumption - Emissions (CO2eq) (AR5)": "7.D",
+                "Solid Food Waste - Emissions (CH4)": "7.E",
+                "Solid Food Waste - Emissions (CO2eq) (AR5)": "7.E",
+                "Domestic Wastewater - Emissions (CH4)": "7.F",
+                "Domestic Wastewater - Emissions (N2O)": "7.F",
+                "Domestic Wastewater - Emissions (CO2eq) (AR5)": "7.F",
+                "Industrial Wastewater - Emissions (CH4)": "7.G",
+                "Industrial Wastewater - Emissions (N2O)": "7.G",
+                "Industrial Wastewater - Emissions (CO2eq) (AR5)": "7.G",
+                "Incineration - Emissions (CO2)": "7.H",
+                "Incineration - Emissions (CO2eq) (AR5)": "7.H",
+                "Pre- and Post- Production - Emissions (CO2)": "7.I",
+                "Pre- and Post- Production - Emissions (CH4)": "7.I",
+                "Pre- and Post- Production - Emissions (N2O)": "7.I",
+                "Pre- and Post- Production - Emissions (CO2eq) from F-gases (AR5)": "7.I",
+                "Pre- and Post- Production - Emissions (CO2eq) (AR5)": "7.I",
+                "Energy Use (Pre- and Post-Production) - Emissions (CO2)": "7.J",
+                "Energy Use (Pre- and Post-Production) - Emissions (CH4)": "7.J",
+                "Energy Use (Pre- and Post-Production) - Emissions (N2O)": "7.J",
+                "Energy Use (Pre- and Post-Production) - Emissions (CO2eq) (AR5)": "7.J",
+                "Agrifood Systems Waste Disposal - Emissions (CO2)": "7.K",
+                "Agrifood Systems Waste Disposal - Emissions (CH4)": "7.K",
+                "Agrifood Systems Waste Disposal - Emissions (N2O)": "7.K",
+                "Agrifood Systems Waste Disposal - Emissions (CO2eq) (AR5)": "7.K",
+                "Cold Chain F-Gas - Emissions (CO2eq) from F-gases (AR5)": "7.L",
+                "Pesticides Manufacturing - Emissions (CO2)": "7.M",
+                "Pesticides Manufacturing - Emissions (CH4)": "7.M",
+                "Pesticides Manufacturing - Emissions (N2O)": "7.M",
+                "Pesticides Manufacturing - Emissions (CO2eq) (AR5)": "7.M",
+                "Food Processing - Emissions (CO2)": "7.N",
+                "Food Processing - Emissions (CH4)": "7.N",
+                "Food Processing - Emissions (N2O)": "7.N",
+                "Food Processing - Emissions (CO2eq) from F-gases (AR5)": "7.N",
+                "Food Processing - Emissions (CO2eq) (AR5)": "7.N",
+                "Food Transport - Emissions (CO2eq) from F-gases (AR5)": "7.B",
+                "Food Packaging - Emissions (CO2)": "7.O",
+                "Food Packaging - Emissions (CH4)": "7.O",
+                "Food Packaging - Emissions (N2O)": "7.O",
+                "Food Packaging - Emissions (CO2eq) (AR5)": "7.O",
+                "Food Household Consumption - Emissions (CO2eq) from F-gases (AR5)": "7.D",
+                "Fertilizers Manufacturing - Emissions (N2O)": "7.A",
+            },
             "columns_to_drop": [
                 "Element",
                 "Element Code",

+ 29 - 3
tests/unit/FAO.py

@@ -2103,21 +2103,44 @@ spec = {
                 ]
             },
         },
-        "7.K": {
+        "7.J": {
             "title": "Energy Use (Pre- and Post-Production)",
             "comment": "Energy Use (Pre- and Post-Production)",
             "info": {"gases": ["CO2", "CH4", "N2O", "KYOTOGHG (AR5GWP100)"]},
         },
-        "7.L": {
+        "7.K": {
             "title": "Agrifood Systems Waste Disposal",
             "comment": "Agrifood Systems Waste Disposal",
             "info": {"gases": ["CO2", "CH4", "N2O", "KYOTOGHG (AR5GWP100)"]},
         },
-        "7.M": {
+        "7.L": {
             "title": "Cold Chain F-Gas",
             "comment": "Cold Chain F-Gas",
             "info": {"gases": ["FGASES (AR5GWP100)"]},
         },
+        "7.M": {
+            "title": "Pesticides Manufacturing",
+            "comment": "Pesticides Manufacturing",
+            "info": {"gases": ["CO2", "CH4", "N2O", "KYOTOGHG (AR5GWP100)"]},
+        },
+        "7.N": {
+            "title": "Food Processing",
+            "comment": "Food Processing",
+            "info": {
+                "gases": [
+                    "CO2",
+                    "CH4",
+                    "N2O",
+                    "KYOTOGHG (AR5GWP100)",
+                    "FGASES (AR5GWP100)",
+                ]
+            },
+        },
+        "7.O": {
+            "title": "Food Packaging",
+            "comment": "Food Packaging",
+            "info": {"gases": ["CO2", "CH4", "N2O", "KYOTOGHG (AR5GWP100)"]},
+        },
         "7": {
             "title": "Pre and post agricultural production",
             "comment": "Pre and post agricultural production",
@@ -2141,9 +2164,12 @@ spec = {
                     "7.G",
                     "7.H",
                     "7.I",
+                    "7.J",
                     "7.K",
                     "7.L",
                     "7.M",
+                    "7.N",
+                    "7.O",
                 ]
             ],
         },

+ 34 - 3
tests/unit/FAO.yaml

@@ -2597,7 +2597,7 @@ categories:
       - N2O
       - KYOTOGHG (AR5GWP100)
       - FGASES (AR5GWP100)
-  7.K:
+  7.J:
     title: Energy Use (Pre- and Post-Production)
     comment: Energy Use (Pre- and Post-Production)
     info:
@@ -2606,7 +2606,7 @@ categories:
       - CH4
       - N2O
       - KYOTOGHG (AR5GWP100)
-  7.L:
+  7.K:
     title: Agrifood Systems Waste Disposal
     comment: Agrifood Systems Waste Disposal
     info:
@@ -2615,12 +2615,40 @@ categories:
       - CH4
       - N2O
       - KYOTOGHG (AR5GWP100)
-  7.M:
+  7.L:
     title: Cold Chain F-Gas
     comment: Cold Chain F-Gas
     info:
       gases:
       - FGASES (AR5GWP100)
+  7.M:
+    title: Pesticides Manufacturing
+    comment: Pesticides Manufacturing
+    info:
+      gases:
+      - CO2
+      - CH4
+      - N2O
+      - KYOTOGHG (AR5GWP100)
+  7.N:
+    title: Food Processing
+    comment: Food Processing
+    info:
+      gases:
+      - CO2
+      - CH4
+      - N2O
+      - KYOTOGHG (AR5GWP100)
+      - FGASES (AR5GWP100)
+  7.O:
+    title: Food Packaging
+    comment: Food Packaging
+    info:
+      gases:
+      - CO2
+      - CH4
+      - N2O
+      - KYOTOGHG (AR5GWP100)
   '7':
     title: Pre and post agricultural production
     comment: Pre and post agricultural production
@@ -2641,6 +2669,9 @@ categories:
       - 7.G
       - 7.H
       - 7.I
+      - 7.J
       - 7.K
       - 7.L
       - 7.M
+      - 7.N
+      - 7.O

+ 3 - 3
tests/unit/test_conversion.py

@@ -11,10 +11,10 @@ def test_read(tmp_path):
         # ("farm_gate_agriculture_energy", "2024-11-14"),
         # ("farm_gate_emissions_crops", "2024-11-14"),
         # ("farm_gate_livestock", "2024-11-14"),
-        ("land_use_drained_organic_soils", "2024-11-14"),
+        # ("land_use_drained_organic_soils", "2024-11-14"),
         # ("land_use_fires", "2024-11-14"),
         # ("land_use_forests", "2024-11-14"),
-        # ("pre_post_agricultural_production", "2024-11-14"),
+        ("pre_post_agricultural_production", "2024-11-14"),
     ]
 
     read_data(
@@ -564,7 +564,7 @@ def test_make_dict_comprehension_for_faster_typing():  # noqa: PLR0912 PLR0915
         "Food Processing",
         "Food Packaging",
     ]
-    pre_post_production_categories_codes = ["7." + i for i in "ABCDEFGHIKLM"]
+    pre_post_production_categories_codes = ["7." + i for i in "ABCDEFGHIJKLMNO"]
     pre_post_production_categories_gases = [
         ["CO2", "N2O", "KYOTOGHG (AR5GWP100)"],
         ["CO2", "CH4", "N2O", "KYOTOGHG (AR5GWP100)", "FGASES (AR5GWP100)"],