瀏覽代碼

Add Table 3.B(b) to AUS CRF/CRT spacification

Johannes Gütschow 1 年之前
父節點
當前提交
8d76a13ce1

+ 11 - 1
UNFCCC_GHG_data/UNFCCC_CRF_reader/UNFCCC_CRF_reader_core.py

@@ -156,6 +156,7 @@ def read_crf_table(
         data_year: Optional[Union[int, List[int]]]=None,
         date: Optional[str]=None,
         folder: Optional[str]=None,
+        debug: Optional[bool]=False,
 ) -> Tuple[pd.DataFrame, List[List], List[List]]:
     """
     Read CRF table for given submission year and country / or countries
@@ -189,6 +190,9 @@ def read_crf_table(
         Folder that contains the xls files. If not given fodlers are determined by the
         submissions_year and country_code variables
 
+    debug: bool (optional)
+        if true print some debug information like column headers
+
     Returns
     _______
         Tuple[pd.DataFrame, List[List], List[List]]:
@@ -272,7 +276,7 @@ def read_crf_table(
         try:
             int(file_info["data_year"])
             df_this_file, unknown_rows_this_file, last_row_info_this_file = \
-                read_crf_table_from_file(file, table, crf_spec[table])
+                read_crf_table_from_file(file, table, crf_spec[table], debug=debug)
             if df_all is None:
                 df_all = df_this_file.copy(deep=True)
                 unknown_rows = unknown_rows_this_file
@@ -291,6 +295,7 @@ def read_crf_table_from_file(
         file: Path,
         table: str,
         table_spec: Dict[str, Dict],
+        debug: Optional[bool]=False,
 ) -> Tuple[pd.DataFrame, List[List], List[List]]:
     """
     Read a single CRF table from a given file. This is the core function of the CRF
@@ -307,6 +312,9 @@ def read_crf_table_from_file(
     table_spec: Dict[str, Dict]
         Specification for the given table, e.g. CRF2021["Table4"]
 
+    debug: bool (optional)
+        if true print some debug information like column headers
+
     Returns
     _______
         Tuple[pd.DataFrame, List[List], List[List]]:
@@ -430,6 +438,8 @@ def read_crf_table_from_file(
 
     df_current.iloc[0] = units
     df_current.columns = entities
+    if debug:
+        print(f"Columns present: {entities}")
     # remove all columns to ignore
     df_current = df_current.drop(columns=table_properties["cols_to_ignore"])
 

+ 2 - 1
UNFCCC_GHG_data/UNFCCC_CRF_reader/UNFCCC_CRF_reader_devel.py

@@ -100,7 +100,8 @@ def read_year_to_test_specs(
             for table in tables:
                 # read table for all years
                 ds_table, new_unknown_categories, new_last_row_info = read_crf_table(
-                    country_code, table, submission_year, date=submission_date, data_year=[data_year])
+                    country_code, table, submission_year, date=submission_date,
+                    data_year=[data_year], debug=True)
 
                 # collect messages on unknown rows etc
                 unknown_categories = unknown_categories + new_unknown_categories

File diff suppressed because it is too large
+ 554 - 513
UNFCCC_GHG_data/UNFCCC_CRF_reader/crf_specifications/CRF2023_AUS_specification.py


+ 1 - 0
datasets/UNFCCC/CRF2023/CRF2023_raw_2023-09-17.csv

@@ -0,0 +1 @@
+../../../.git/annex/objects/qZ/gg/MD5E-s35724014--61b05b625eb4062e4447f991d0715d77.csv/MD5E-s35724014--61b05b625eb4062e4447f991d0715d77.csv

+ 1 - 0
datasets/UNFCCC/CRF2023/CRF2023_raw_2023-09-17.nc

@@ -0,0 +1 @@
+../../../.git/annex/objects/Kq/VP/MD5E-s65519347--322a62f553a3c2e2a68a898ae88a858f.nc/MD5E-s65519347--322a62f553a3c2e2a68a898ae88a858f.nc

+ 30 - 0
datasets/UNFCCC/CRF2023/CRF2023_raw_2023-09-17.yaml

@@ -0,0 +1,30 @@
+attrs:
+  references: https://unfccc.int/ghg-inventories-annex-i-parties/2023
+  rights: ''
+  contact: mail@johannes-guetschow.de
+  title: 'Data submitted in 2023 to the UNFCCC in the common reporting format (CRF)
+    by Australia. Submission date: 13042023'
+  comment: Read fom xlsx file by Johannes Gütschow
+  institution: United Nations Framework Convention on Climate Change (www.unfccc.int)
+  cat: category (CRF2013_2023)
+  area: area (ISO3)
+  scen: scenario (PRIMAP)
+  sec_cats:
+  - c
+  - l
+  - a
+  - s
+  - s
+time_format: '%Y'
+dimensions:
+  '*':
+  - time
+  - class
+  - provenance
+  - category (CRF2013_2023)
+  - area (ISO3)
+  - scenario (PRIMAP)
+  - source
+  - entity
+  - unit
+data_file: CRF2023_raw_2023-09-17.csv

Some files were not shown because too many files changed in this diff