Преглед изворни кода

[DATALAD] Recorded changes

Daniel Busch пре 2 месеци
родитељ
комит
31489316cf
4 измењених фајлова са 10 додато и 31 уклоњено
  1. 4 4
      poetry.lock
  2. 1 0
      pyproject.toml
  3. 3 3
      requirements.txt
  4. 2 24
      src/faostat_data_primap/read.py

+ 4 - 4
poetry.lock

@@ -591,13 +591,13 @@ colorama = {version = "*", markers = "platform_system == \"Windows\""}
 
 [[package]]
 name = "climate-categories"
-version = "0.10.5"
+version = "0.10.6"
 description = "Commonly used codes, categories, terminologies, and nomenclatures used in climate policy analysis as a Python package."
 optional = false
 python-versions = "<3.14,>=3.11"
 files = [
-    {file = "climate_categories-0.10.5-py3-none-any.whl", hash = "sha256:8a887c912e51b8c92a54d45f840ec5a1f94a73b89e211c2e793021ea2593d0ea"},
-    {file = "climate_categories-0.10.5.tar.gz", hash = "sha256:c97cec39ed838952d147a93b973d82ab0f14dda60459d2852863dd0a1a2f3edf"},
+    {file = "climate_categories-0.10.6-py3-none-any.whl", hash = "sha256:b96fd50c9d484aacbbb2a9a94e14e47e950c0ae11de0604f355a8590e31f4005"},
+    {file = "climate_categories-0.10.6.tar.gz", hash = "sha256:4b12dac466691b977c9a7fc324663e38c37b3a2643a41543c1eecc2307c49ef0"},
 ]
 
 [package.dependencies]
@@ -5354,4 +5354,4 @@ type = ["pytest-mypy"]
 [metadata]
 lock-version = "2.0"
 python-versions = ">=3.11,<3.13"
-content-hash = "49ecf834cde076e33ff5fd9b3aff9a20d09b4f24e0bf2fdbe97fba1c3fb81b73"
+content-hash = "0e21dcd8b6ad03c346dc4be69f84c84dfc995f4e5bbdeb217f17527a06b9eb86"

+ 1 - 0
pyproject.toml

@@ -24,6 +24,7 @@ xarray = "^2024.11.0"
 jupytext = "^1.16.5"
 jupyter = "^1.1.1"
 primap2 = "^0.12.1"
+climate-categories = "^0.10.6"
 
 
 [tool.poetry.group.tests.dependencies]

+ 3 - 3
requirements.txt

@@ -268,9 +268,9 @@ charset-normalizer==3.4.0 ; python_version >= "3.11" and python_version < "3.13"
 click==8.1.7 ; python_version >= "3.11" and python_version < "3.13" \
     --hash=sha256:ae74fb96c20a0277a1d615f1e4d73c8414f5a98db8b799a7931d1582f3390c28 \
     --hash=sha256:ca9853ad459e787e2192211578cc907e7594e294c7ccc834310722b41b9ca6de
-climate-categories==0.10.5 ; python_version >= "3.11" and python_version < "3.13" \
-    --hash=sha256:8a887c912e51b8c92a54d45f840ec5a1f94a73b89e211c2e793021ea2593d0ea \
-    --hash=sha256:c97cec39ed838952d147a93b973d82ab0f14dda60459d2852863dd0a1a2f3edf
+climate-categories==0.10.6 ; python_version >= "3.11" and python_version < "3.13" \
+    --hash=sha256:4b12dac466691b977c9a7fc324663e38c37b3a2643a41543c1eecc2307c49ef0 \
+    --hash=sha256:b96fd50c9d484aacbbb2a9a94e14e47e950c0ae11de0604f355a8590e31f4005
 cloudpickle==3.1.0 ; python_version >= "3.11" and python_version < "3.13" \
     --hash=sha256:81a929b6e3c7335c863c771d673d105f02efdb89dfaba0c90495d1c64796601b \
     --hash=sha256:fe11acda67f61aaaec473e3afe030feb131d78a43461b718185363384f1ba12e

+ 2 - 24
src/faostat_data_primap/read.py

@@ -286,7 +286,6 @@ def read_data(  # noqa: PLR0915 PLR0912
     result_proc_if = result_proc.pr.to_interchange_format()
 
     output_filename = f"FAOSTAT_Agrifood_system_emissions_{release_name}"
-    # output_folder = extracted_data_path / release_name
 
     if not output_folder.exists():
         output_folder.mkdir()
@@ -322,43 +321,22 @@ def process(ds: xarray.Dataset) -> xarray.Dataset:
         The processed dataset
 
     """
-    # make categorisation A from yaml
-    # categorisation_a = cc.FAO
-    # make categorisation B from yaml
-    # categorisation_b = cc.IPCC2006_PRIMAP
-
-    # category FAOSTAT not yet part of climate categories, so we need to add it manually
-    # cats = {
-    #     "FAO": categorisation_a,
-    #     "IPCC2006_PRIMAP": categorisation_b,
-    # }
-
     # drop UNFCCC data
     ds = ds.drop_sel(source="UNFCCC")
 
     # consistency check in original categorisation
     ds_checked = ds.pr.add_aggregates_coordinates(agg_info=agg_info_fao)  # noqa: F841
 
-    # We need a conversion CSV file for each entity
-    # That's a temporary workaround until the filter function in climate categories works
-    # conv_old = {}
     gases = ["CO2", "CH4", "N2O"]
-    #
-    # for var in gases:
-    #     conversion_path = root_path / f"conv_FAO_IPPCC2006_PRIMAP_{var}.csv"
-    #     conv_old[var] = cc.Conversion.from_csv(
-    #         conversion_path,
-    #         cats=cats,  # type: ignore
-    #     )
+
     conv = cc.FAO.conversion_to(cc.IPCC2006_PRIMAP)
+
     # convert for each entity
     da_dict = {}
     for var in gases:
         conv_for_gas = conv.filter(aux_dim="gas", values=[var])
-        # conv_for_gas_old = conv_old[var]
         da_dict[var] = ds[var].pr.convert(
             dim="category (FAO)",
-            # conversion=conv[var],
             conversion=conv_for_gas,
         )