Sfoglia il codice sorgente

fix bugs in CRF / CRF reading

Johannes Gütschow 9 mesi fa
parent
commit
565bf45c2f

+ 6 - 6
src/unfccc_ghg_data/unfccc_crf_reader/crf_specifications/crt1_specification.py

@@ -334,12 +334,12 @@ CRT1 = {
             ["Biomass (3)", ["1.A.2.f", "Biomass"], 2],
             # g. other
             ["1.A.2.g. Other (11)", ["1.A.2.g", "Total"], 1],
-            ["Liquid fuels", ["1.A.2.f", "Liquid"], 2],
-            ["Solid fuels", ["1.A.2.f", "Solid"], 2],
-            ["Gaseous fuels (6)", ["1.A.2.f", "Gaseous"], 2],
-            ["Other fossil fuels (7)", ["1.A.2.f", "OtherFF"], 2],
-            ["Peat (8)", ["1.A.2.f", "Peat"], 2],
-            ["Biomass (3)", ["1.A.2.f", "Biomass"], 2],
+            ["Liquid fuels", ["1.A.2.g", "Liquid"], 2],
+            ["Solid fuels", ["1.A.2.g", "Solid"], 2],
+            ["Gaseous fuels (6)", ["1.A.2.g", "Gaseous"], 2],
+            ["Other fossil fuels (7)", ["1.A.2.g", "OtherFF"], 2],
+            ["Peat (8)", ["1.A.2.g", "Peat"], 2],
+            ["Biomass (3)", ["1.A.2.g", "Biomass"], 2],
             ["Drop-down list:", ["\\IGNORE", "\\IGNORE"], 2],
             # 1.A.2.g.i Manufacturing of machinery
             ["1.A.2.g.i. Manufacturing of machinery", ["1.A.2.g.i", "Total"], 2],

+ 3 - 0
src/unfccc_ghg_data/unfccc_crf_reader/read_new_unfccc_crf_for_year.py

@@ -21,6 +21,7 @@ if __name__ == "__main__":
     parser.add_argument(
         "--re_read", help="Read data also if already read before", action="store_true"
     )
+    parser.add_argument("--type", help="CRF or CRT tables", default="CRF")
 
     args = parser.parse_args()
 
@@ -29,9 +30,11 @@ if __name__ == "__main__":
     #    countries = None
     submission_year = args.submission_year
     re_read = args.re_read
+    type = args.type
     print(f"!!!!!!!!!!!!!!!!!!!!script: re_read={re_read}")
     read_new_crf_for_year(
         submission_year=int(submission_year),
         #    countries=countries,
         re_read=re_read,
+        type=type,
     )

+ 3 - 0
src/unfccc_ghg_data/unfccc_crf_reader/read_unfccc_crf_submission.py

@@ -21,6 +21,7 @@ if __name__ == "__main__":
     parser.add_argument(
         "--re_read", help="Read data also if already read before", action="store_true"
     )
+    parser.add_argument("--type", help="CRF or CRT tables", default="CRF")
 
     args = parser.parse_args()
 
@@ -28,6 +29,7 @@ if __name__ == "__main__":
     submission_year = args.submission_year
     submission_date = args.submission_date
     re_read = args.re_read
+    type = args.type
     if submission_date == "None":
         submission_date = None
 
@@ -36,4 +38,5 @@ if __name__ == "__main__":
         submission_year=submission_year,
         submission_date=submission_date,
         re_read=re_read,
+        type=type,
     )

+ 1 - 0
src/unfccc_ghg_data/unfccc_crf_reader/unfccc_crf_reader_devel.py

@@ -262,6 +262,7 @@ def read_year_to_test_specs(  # noqa: PLR0912, PLR0915
         save_last_row_info(last_row_info, log_location)
 
     # save the data:
+    print(f"Save dataset to log folder: {log_path}")
     compression = dict(zlib=True, complevel=9)
     output_folder = log_path / f"test_read_{type}{submission_year}"
     if country_code is not None:

+ 4 - 1
src/unfccc_ghg_data/unfccc_crf_reader/unfccc_crf_reader_prod.py

@@ -299,7 +299,10 @@ def read_crf_for_country_datalad(
         raise ValueError("Type must be CRF or CRT")  # noqa: TRY003
     # get all the info for the country
     country_info = get_input_and_output_files_for_country(
-        country, submission_year=submission_year, verbose=True
+        country,
+        submission_year=submission_year,
+        verbose=True,
+        type=type,
     )
 
     print(f"Attempting to read data for {type}{submission_year} from {country}.")