Selaa lähdekoodia

small fixes to UNFCCC submission reading

Johannes Gütschow 9 kuukautta sitten
vanhempi
commit
a6dad0b34b

+ 2 - 1
.pre-commit-config.yaml

@@ -19,10 +19,11 @@ repos:
       - id: debug-statements
       - id: detect-private-key
       - id: end-of-file-fixer
-        exclude: ".json"
+        exclude: ".json|.yaml"
       - id: fix-byte-order-marker
       - id: mixed-line-ending
       - id: trailing-whitespace
+        exclude: ".json|.yaml"
   - repo: local
     hooks:
       # Prevent committing .rej files

+ 1 - 1
extracted_data/non-UNFCCC/Republic_of_Korea/KOR_2023-Inventory_2023_IPCC1996_KOR_INV.nc

@@ -1 +1 @@
-../../../.git/annex/objects/xJ/qp/MD5E-s130043--c61e688981fcd57a82b9e8f31fa7f27b.nc/MD5E-s130043--c61e688981fcd57a82b9e8f31fa7f27b.nc
+../../../.git/annex/objects/jj/g0/MD5E-s117632--6b2f967e4a1d30894be5dcd22110ea4f.nc/MD5E-s117632--6b2f967e4a1d30894be5dcd22110ea4f.nc

+ 4 - 4
extracted_data/non-UNFCCC/Republic_of_Korea/KOR_2023-Inventory_2023_IPCC1996_KOR_INV.yaml

@@ -1,5 +1,5 @@
 attrs:
-  references:
+  references: 
     http://www.gir.go.kr/home/board/read.do?pagerOffset=0&maxPageItems=10&maxIndexPages=10&searchKey=&searchValue=&menuId=36&boardId=62&boardMasterId=2&boardCategoryId=
   rights: ''
   contact: mail@johannes-guetschow.de
@@ -14,11 +14,11 @@ time_format: '%Y'
 dimensions:
   '*':
   - time
-  - area (ISO3)
+  - scenario (PRIMAP)
+  - category (IPCC1996_KOR_INV)
   - source
+  - area (ISO3)
   - provenance
-  - category (IPCC1996_KOR_INV)
-  - scenario (PRIMAP)
   - entity
   - unit
 data_file: KOR_2023-Inventory_2023_IPCC1996_KOR_INV.csv

+ 1 - 1
extracted_data/non-UNFCCC/Republic_of_Korea/KOR_2023-Inventory_2023_IPCC2006_PRIMAP.nc

@@ -1 +1 @@
-../../../.git/annex/objects/wz/m1/MD5E-s121725--07b2eb4ec02eaecb12e9a7b8fc608103.nc/MD5E-s121725--07b2eb4ec02eaecb12e9a7b8fc608103.nc
+../../../.git/annex/objects/Gx/MK/MD5E-s109314--798b2f086e4572a9c08819e3d653408b.nc/MD5E-s109314--798b2f086e4572a9c08819e3d653408b.nc

+ 3 - 3
extracted_data/non-UNFCCC/Republic_of_Korea/KOR_2023-Inventory_2023_IPCC2006_PRIMAP.yaml

@@ -1,5 +1,5 @@
 attrs:
-  references:
+  references: 
     http://www.gir.go.kr/home/board/read.do?pagerOffset=0&maxPageItems=10&maxIndexPages=10&searchKey=&searchValue=&menuId=36&boardId=62&boardMasterId=2&boardCategoryId=
   rights: ''
   contact: mail@johannes-guetschow.de
@@ -14,11 +14,11 @@ time_format: '%Y'
 dimensions:
   '*':
   - time
-  - area (ISO3)
+  - scenario (PRIMAP)
   - source
+  - area (ISO3)
   - provenance
   - category (IPCC2006_PRIMAP)
-  - scenario (PRIMAP)
   - entity
   - unit
 data_file: KOR_2023-Inventory_2023_IPCC2006_PRIMAP.csv

+ 3 - 0
src/unfccc_ghg_data/helper/functions.py

@@ -944,6 +944,9 @@ def get_code_file(
     if submission[0:2] == "DI":
         return root_path / "unfccc_di_reader"
 
+    # replace "-" by "_" in submission
+    submission = submission.replace("-", "_")
+
     # obtain country code
     country_code = get_country_code(country_name)
 

+ 4 - 5
src/unfccc_ghg_data/unfccc_reader/Republic_of_Korea/read_KOR_2023_Inventory_from_xlsx.py

@@ -7,11 +7,7 @@ import sys
 
 import pandas as pd
 import primap2 as pm2
-from primap2.pm2io._data_reading import filter_data, matches_time_format
-
-from unfccc_ghg_data.helper import downloaded_data_path, extracted_data_path
-
-from .config_KOR_INV2023 import (
+from config_KOR_INV2023 import (
     aggregate_after_mapping,
     aggregate_before_mapping,
     cat_codes,
@@ -22,6 +18,9 @@ from .config_KOR_INV2023 import (
     filter_remove_after_agg,
     fix_rows,
 )
+from primap2.pm2io._data_reading import filter_data, matches_time_format
+
+from unfccc_ghg_data.helper import downloaded_data_path, extracted_data_path
 
 if __name__ == "__main__":
     # ###

+ 2 - 3
src/unfccc_ghg_data/unfccc_reader/read_UNFCCC_submission.py

@@ -10,11 +10,10 @@ run the appropriate script to extract the submission data
 import argparse
 
 import datalad.api
+from get_submissions_info import get_possible_inputs, get_possible_outputs
 
 from unfccc_ghg_data.helper import get_code_file, root_path
 
-from .get_submissions_info import get_possible_inputs, get_possible_outputs
-
 if __name__ == "__main__":
     # Find the right function and possible input and output files and
     # read the data using datalad run.
@@ -73,7 +72,7 @@ if __name__ == "__main__":
 
         print("Run the script using datalad run via the python api")
         datalad.api.run(
-            cmd=f"./venv/bin/python3 {script_name.as_posix()}",
+            cmd=f"python3 {script_name.as_posix()}",
             dataset=root_path,
             message=f"Read data for {country}, {submission}.",
             inputs=input_files,