Browse Source

more cRF bugfixes and update annexI for 2023

Johannes Gütschow 9 months ago
parent
commit
3a65883288

+ 1 - 1
dodo.py

@@ -450,7 +450,7 @@ def task_read_new_unfccc_crf_for_year():
             re_read = False
         read_new_crf_for_year_datalad(
             submission_year=int(read_config_crf["submission_year"]),
-            countries=read_config_crf["countries"],
+            # countries=read_config_crf["countries"],
             re_read=re_read,
             type=read_config_crf["type"],
         )

+ 1 - 1
downloaded_data/UNFCCC/submissions-annexI_2023.csv

@@ -1 +1 @@
-../../.git/annex/objects/2X/Xm/MD5E-s24273--fba3f5eca40640c65dbeb96a2d7d3eb5.csv/MD5E-s24273--fba3f5eca40640c65dbeb96a2d7d3eb5.csv
+../../.git/annex/objects/ww/3V/MD5E-s24293--25d23f83fe67ce10def1a03865c4005d.csv/MD5E-s24293--25d23f83fe67ce10def1a03865c4005d.csv

+ 0 - 39
src/unfccc_ghg_data/unfccc_crf_reader/read_new_unfccc_crf_for_year_datalad.py

@@ -1,39 +0,0 @@
-"""
-Wrapper around read_crf_for_country_datalad
-
-Wrapper around read_crf_for_country_datalad such that it can be called
-from doit in the current setup where doit runs on system python and
-not in the venv.
-"""
-
-import argparse
-
-from unfccc_ghg_data.unfccc_crf_reader.unfccc_crf_reader_prod import (
-    read_new_crf_for_year_datalad,
-)
-from unfccc_ghg_data.unfccc_crf_reader.util import NoCRFFilesError
-
-if __name__ == "__main__":
-    parser = argparse.ArgumentParser()
-    # parser.add_argument('--countries', help='List of country codes', default=None)
-    parser.add_argument("--submission_year", help="Submission round to read")
-    parser.add_argument(
-        "--re_read", help="Read data also if already read before", action="store_true"
-    )
-
-    args = parser.parse_args()
-
-    # countries = args.countries
-    # if countries == "None":
-    #    countries = None
-    submission_year = args.submission_year
-    re_read = args.re_read
-    print(f"!!!!!!!!!!!!!!!!!!!!script_dl: re_read={re_read}")
-    try:
-        read_new_crf_for_year_datalad(
-            submission_year=int(submission_year),
-            #        countries=countries,
-            re_read=re_read,
-        )
-    except NoCRFFilesError as err:
-        print(f"NoCRFFilesError: {err}")

+ 0 - 41
src/unfccc_ghg_data/unfccc_crf_reader/read_unfccc_crf_submission_datalad.py

@@ -1,41 +0,0 @@
-"""
-Wrapper around read_crf_for_country_datalad
-
-wrapper around read_crf_for_country_datalad such that it can be called
-from doit in the current setup where doit runs on system python and
-not in the venv.
-"""
-
-import argparse
-
-from unfccc_ghg_data.unfccc_crf_reader.unfccc_crf_reader_prod import (
-    read_crf_for_country_datalad,
-)
-
-if __name__ == "__main__":
-    parser = argparse.ArgumentParser()
-    parser.add_argument("--country", help="Country name or code")
-    parser.add_argument("--submission_year", help="Submission round to read")
-    parser.add_argument(
-        "--submission_date", help="Date of submission to read", default=None
-    )
-    parser.add_argument(
-        "--re_read", help="Read data also if already read before", action="store_true"
-    )
-
-    args = parser.parse_args()
-
-    country = args.country
-    submission_year = args.submission_year
-    submission_date = args.submission_date
-    re_read = args.re_read
-
-    if submission_date == "None":
-        submission_date = None
-
-    read_crf_for_country_datalad(
-        country,
-        submission_year=int(submission_year),
-        submission_date=submission_date,
-        re_read=re_read,
-    )

+ 10 - 2
src/unfccc_ghg_data/unfccc_crf_reader/unfccc_crf_reader_prod.py

@@ -428,7 +428,7 @@ def read_new_crf_for_year(
     return read_countries
 
 
-def read_new_crf_for_year_datalad(
+def read_new_crf_for_year_datalad(  # noqa: PLR0912
     submission_year: int,
     countries: Optional[list[str]] = None,
     re_read: Optional[bool] = False,
@@ -463,7 +463,15 @@ def read_new_crf_for_year_datalad(
             f"Reading {type}{submission_year} for all countries "
             f"using unfccc_crf_reader."
         )
-        countries = all_crf_countries
+        if type == "CRF":
+            if countries is None:
+                countries = all_crf_countries
+        elif type == "CRT":
+            if countries is None:
+                countries = all_countries
+        else:
+            raise ValueError("Type must be CRF or CRT")  # noqa: TRY003
+
     print("#" * 80)
     print("")
     if re_read: