Browse Source

Add Nigeria BUR2 code; small fix in Indonesia BUR3 (not affecting results)

Johannes Gütschow 1 year ago
parent
commit
37273b797b

+ 2 - 2
UNFCCC_GHG_data/UNFCCC_reader/Indonesia/read_IDN_BUR3_from_pdf.py

@@ -44,7 +44,7 @@ cat_codes_manual = {
     #'3A2b Direct N2O Emissions from Manure Management': '3.A.2',
 }
 
-cat_code_regexp = r'(?P<UNFCCC_GHG_data>^[a-zA-Z0-9]{1,4})\s.*'
+cat_code_regexp = r'(?P<code>^[a-zA-Z0-9]{1,4})\s.*'
 
 coords_cols = {
     "category": "category",
@@ -195,7 +195,7 @@ df_all["category"] = df_all["orig_cat_name"]
 # first the manual replacements
 df_all["category"] = df_all["category"].replace(cat_codes_manual)
 # then the regex replacements
-repl = lambda m: m.group('UNFCCC_GHG_data')
+repl = lambda m: m.group('code')
 df_all["category"] = df_all["category"].str.replace(cat_code_regexp, repl, regex=True)
 df_all = df_all.reset_index(drop=True)
 

+ 433 - 0
UNFCCC_GHG_data/UNFCCC_reader/Nigeria/config_NGA_BUR2.py

@@ -0,0 +1,433 @@
+gwp_to_use = 'AR5GWP100'
+
+tables_trends = {
+    '70': { # GHG by main sector
+        'page': '70',
+        'area': ['177,430,450,142'],
+        'cols': ['208,260,311,355,406'],
+        'coords_defaults': {
+            'entity': f'KYOTOGHG ({gwp_to_use})',
+            'unit': 'GgCO2eq',
+        },
+        'coords_cols': {
+            "category": "Year",
+        },
+        #'remove_cols': ['Per capita emissions (t)',
+        #                'GDP emissions index (Year 2000 = 100)'],
+        'coords_value_mapping': {
+            "unit": "PRIMAP1",
+            'category': {
+                'Total emissions': '0',
+                'Energy': '1',
+                'IPPU': '2',
+                'AFOLU': '3',
+                'Waste': '4',
+            },
+        },
+        'label_rows': [0, 1, 2],
+    },
+    '71': { # main gases by sector
+    'page': '71',
+        'area': ['82,760,509,454'],
+        'cols': ['124,186,249,326,388,454'],
+        'coords_defaults': {
+            'category': '0',
+            'unit': 'GgCO2eq',
+        },
+        'coords_cols': {
+            "entity": "Year",
+        },
+        'remove_cols': ['Total GHG emissions (CO₂-eq)',
+                        'Removals (CO₂) (CO₂-eq)',
+                        'CO₂ (Gg)'],
+        'coords_value_mapping': {
+            "unit": "PRIMAP1",
+            'entity': {
+                'Net emissions (CO₂-eq)': f'KYOTGHG ({gwp_to_use})',
+                'CO₂ (Gg)': 'CO2 emissions',
+                'CH₄ (CO₂-eq)': f'CH4 ({gwp_to_use})',
+                'N₂O (CO₂-eq)': f'N2O ({gwp_to_use})',
+            },
+        },
+        'label_rows':  [0, 1, 2, 3, 4],
+    },
+    '72_1': { # CO2 by main sector
+    'page': '72',
+        'area': ['122,760,496,472'],
+        'cols': ['159,212,265,311,355,406,456'],
+        'coords_defaults': {
+            'entity': 'CO2',
+            'unit': 'Gg',
+        },
+        'coords_cols': {
+            "category": "Year",
+        },
+        'remove_cols': ['Total emissions'],
+        'coords_value_mapping': {
+            "unit": "PRIMAP1",
+            'category': {
+                'Total net emissions': '0',
+                'Energy': '1',
+                'IPPU': '2',
+                'AFOLU - emissions': 'M.3.EMI',
+                'AFOLU - removals': 'M.3.REM',
+                'Waste': '4',
+            },
+        },
+        'label_rows':  [0, 1, 2],
+    },
+    '72_2': { # CH4 by sector
+    'page': '72',
+        'area': ['133,333,483,41'],
+        'cols': ['172,230,280,333,384,439'],
+        'coords_defaults': {
+            'entity': 'CH4',
+            'unit': 'Gg',
+        },
+        'coords_cols': {
+            "category": "Year",
+        },
+        'remove_cols': ['Total (Gg CO₂-eq)'],
+        'coords_value_mapping': {
+            "unit": "PRIMAP1",
+            'category': {
+                'Total': '0',
+                'Energy': '1',
+                'IPPU': '2',
+                'AFOLU - emissions': '3',
+                'Waste': '4',
+            },
+        },
+        'label_rows':  [0, 1, 2],
+    },
+    '73': { # N2O by sector
+    'page': '73',
+        'area': ['155,666,643,364'],
+        'cols': ['194,265,309,366,419'],
+        'coords_defaults': {
+            'entity': 'N2O',
+            'unit': 'Gg',
+        },
+        'coords_cols': {
+            "category": "Year",
+        },
+        'remove_cols': ['Total emissions (Gg CO₂-eq)'],
+        'coords_value_mapping': {
+            "unit": "PRIMAP1",
+            'category': {
+                'Total': '0',
+                'Energy': '1',
+                'AFOLU': '3',
+                'Waste': '4',
+            },
+        },
+        'label_rows':  [0, 1, 2],
+    },
+    '74': { # NOx by sector
+    'page': '74',
+        'area': ['148,457,467,166'],
+        'cols': ['190,254,304,359,421'],
+        'coords_defaults': {
+            'entity': 'NOX',
+            'unit': 'Gg',
+        },
+        'coords_cols': {
+            "category": "Year",
+        },
+        #'remove_cols': [],
+        'coords_value_mapping': {
+            "unit": "PRIMAP1",
+            'category': {
+                'Total emissions': '0',
+                'Energy': '1',
+                'IPPU': '2',
+                'AFOLU': '3',
+                'Waste': '4',
+            },
+        },
+        'label_rows':  [0, 1, 2],
+    },
+    '75': { # CO by sector
+    'page': '75',
+        'area': ['161,763,456,472'],
+        'cols': ['199,256,307,359,410'],
+        'coords_defaults': {
+            'entity': 'CO',
+            'unit': 'Gg',
+        },
+        'coords_cols': {
+            "category": "Year",
+        },
+        #'remove_cols': ['Total emissions (Gg CO2-eq)'],
+        'coords_value_mapping': {
+            "unit": "PRIMAP1",
+            'category': {
+                'Total emissions': '0',
+                'Energy': '1',
+                'IPPU': '2',
+                'AFOLU': '3',
+                'Waste': '4',
+            },
+        },
+        'label_rows':  [0, 1, 2],
+    },
+    '75_2': { # NMVOC by sector
+    'page': '75',
+        'area': ['177,325,441,50'],
+        'cols': ['219,287,340,395'],
+        'coords_defaults': {
+            'entity': 'NMVOC',
+            'unit': 'Gg',
+        },
+        'coords_cols': {
+            "category": "Year",
+        },
+        #'remove_cols': ['Total emissions (Gg CO2-eq)'],
+        'coords_value_mapping': {
+            "unit": "PRIMAP1",
+            'category': {
+                'Total emissions': '0',
+                'Energy': '1',
+                'IPPU': '2',
+                'Waste': '4',
+            },
+        },
+        'label_rows':  [0, 1, 2],
+    },
+    '76_1': { # NMVOC by sector
+    'page': '76',
+        'area': ['175,782,448,675'],
+        'cols': ['216,282,340,390'],
+        'coords_defaults': {
+            'entity': 'NMVOC',
+            'unit': 'Gg',
+        },
+        'coords_cols': {
+            "category": "Year",
+        },
+        #'remove_cols': ['Total emissions (Gg CO2-eq)'],
+        'coords_value_mapping': {
+            "unit": "PRIMAP1",
+            'category': {
+                'Total emissions': '0',
+                'Energy': '1',
+                'IPPU': '2',
+                'Waste': '4',
+            },
+        },
+        'label_rows':  [0, 1, 2],
+    },
+    '76_2': { # SO2 by sector
+    'page': '76',
+        'area': ['197,562,421,226'],
+        'cols': ['243,331,381'],
+        'coords_defaults': {
+            'entity': 'SO2',
+            'unit': 'Gg',
+        },
+        'coords_cols': {
+            "category": "Year",
+        },
+        #'remove_cols': ['Total emissions (Gg CO2-eq)'],
+        'coords_value_mapping': {
+            "unit": "PRIMAP1",
+            'category': {
+                'Total emissions': '0',
+                'Energy': '1',
+                'Waste': '4',
+            },
+        },
+        'label_rows':  [0],
+    },
+}
+
+pages_inventory = {
+    '78': 1,
+    '79': 0,
+    '80': 0,
+    '81': 0,
+    '82': 0,
+}
+
+year_inventory = 2017
+entity_row = 1
+unit_row = 0
+
+
+###
+index_cols = "Categories"
+units_inv = {
+    'Emissions (Gg)': 'Gg',
+    'Emissions CO2 Equivalents (Gg)': 'GgCO2eq',
+}
+# special header as category UNFCCC_GHG_data and name in one column
+header_long = ["category", "entity", "unit", "time", "data"]
+
+
+# manual category codes
+cat_codes_manual = {
+    'Total National Emissions and Removals': '0',
+    'International Bunkers': 'M.BK',
+}
+
+cat_code_regexp = r'(?P<code>^[a-zA-Z0-9\.]{1,9})\s.*'
+
+coords_cols = {
+    "category": "category",
+    "entity": "entity",
+    "unit": "unit",
+}
+
+# add_coords_cols = {
+#     "orig_cat_name": ["orig_cat_name", "category"],
+# }
+
+coords_terminologies = {
+    "area": "ISO3",
+    "category": "IPCC2006_PRIMAP",
+    "scenario": "PRIMAP",
+}
+
+coords_defaults = {
+    "source": "NGA-GHG-Inventory",
+    "provenance": "measured",
+    "area": "NGA",
+    "scenario": "BUR2",
+}
+
+coords_value_mapping = {
+    "unit": "PRIMAP1",
+    "category": "PRIMAP1",
+    "entity": {
+        'Net CO2 (1)(2)': 'CO2',
+        'CH4': f"CH4",
+        'N2O': f"N2O",
+        'HFCs': f"HFCS ({gwp_to_use})",
+        'PFCs': f"PFCS ({gwp_to_use})",
+        'SF6': f"SF6 ({gwp_to_use})",
+        #'NOx': 'NOX',
+        'CO': 'CO', # no mapping, just added for completeness here
+        'NMVOCs': 'NMVOC',
+        'SO2': 'SO2', # no mapping, just added for completeness here
+        'Other halogenated gases with CO2 eq conversion factors (3)':
+            f"UnspMixOfHFCs ({gwp_to_use})",
+    },
+}
+
+
+filter_remove = {
+    'f1': {
+        'entity': ['Other halogenated gases without CO2 eq conversion factors (4)']
+    },
+    'f2': {
+        'category': 'Memo'
+    },
+}
+
+filter_keep = {}
+
+meta_data = {
+    "references": "https://unfccc.int/documents/307085",
+    "rights": "",
+    "contact": "mail@johannes-guestchow.de",
+    "title": "Nigeria. Second Biennial Update Report (BUR2) to the United Nations "
+             "Framework Convention on Climate Change",
+    "comment": "Read fom pdf by Johannes Gütschow",
+    "institution": "UNFCCC",
+}
+
+# convert to mass units where possible
+entities_to_convert_to_mass = [
+    'CH4', 'N2O', 'SF6'
+]
+
+# CO2 equivalents don't make sense for these substances, so unit has to be Gg instead of Gg CO2 equivalents as indicated in the table
+entities_to_fix_unit = [
+    'NOx', 'CO', 'NMVOCs', 'SO2'
+]
+
+### processing
+
+processing_info_step1 = {
+    'aggregate_cats': {
+        '2.F': {'sources': ['2.F.2', '2.F.6'], # all 0, but for completeness
+              'name': 'Product uses as Substitutes for Ozone Depleting Substances'},
+        '2': {'sources': ['2.A', '2.B', '2.C', '2.D', '2.E', '2.F', '2.G'],
+              'name': 'IPPU'}, # for HFCs, PFCs, SO2, SF6, N2O (all 0)
+        '3': {'sources': ['M.3.EMI', 'M.3.REM'],
+              'name': 'AFOLU'}, # for CO2
+    },
+}
+
+processing_info_step2 =  {
+    'aggregate_cats': {
+        'M.AG.ELV': {'sources': ['3.C'], 'name': 'Agriculture excluding livestock emissions'},
+        'M.AG': {'sources': ['M.AG.ELV', '3.A'], 'name': 'Agriculture'},
+        'M.LULUCF': {'sources': ['3.B', '3.D'],
+                     'name': 'Land Use, Land Use Change, and Forestry'},
+        'M.0.EL': {'sources': ['1', '2', 'M.AG', '4', '5'], 'name': 'National Total Excluding LULUCF'},
+        '0': {'sources': ['1', '2', '3', '4', '5'], 'name': 'National Total'},
+    },
+    'downscale': {
+        'sectors': {
+            '1': {
+                'basket': '1',
+                'basket_contents': ['1.A', '1.B', '1.C'],
+                'entities': ['CO2', 'N2O', 'CH4'],
+                'dim': 'category (IPCC2006_PRIMAP)',
+            },
+            '1.A': {
+                'basket': '1.A',
+                'basket_contents': ['1.A.1', '1.A.2', '1.A.3', '1.A.4'],
+                'entities': ['CO2', 'N2O', 'CH4'],
+                'dim': 'category (IPCC2006_PRIMAP)',
+            },
+            '1.B': {
+                'basket': '1.B',
+                'basket_contents': ['1.B.1', '1.B.2', '1.B.3'],
+                'entities': ['CO2', 'N2O', 'CH4'],
+                'dim': 'category (IPCC2006_PRIMAP)',
+            },
+            'IPPU': {
+                'basket': '2',
+                'basket_contents': ['2.A', '2.B', '2.C', '2.D', '2.E',
+                                    '2.F', '2.G', '2.H'],
+                'entities': ['CO2', 'N2O', 'CH4'],
+                'dim': 'category (IPCC2006_PRIMAP)',
+            },
+            '3': {
+                'basket': '3',
+                'basket_contents': ['3.A', '3.B', '3.C', '3.D'],
+                'entities': ['CO2', 'CH4', 'N2O'],
+                'dim': 'category (IPCC2006_PRIMAP)',
+            },
+            # '3A': {
+            #     'basket': '3.A',
+            #     'basket_contents': ['3.A.1', '3.A.2'],
+            #     'entities': ['CH4', 'N2O'],
+            #     'dim': 'category (IPCC2006_PRIMAP)',
+            # },
+            # '3C': {
+            #     'basket': '3.C',
+            #     'basket_contents': ['3.C.1', '3.C.2', '3.C.3', '3.C.4', '3.C.5',
+            #                         '3.C.6', '3.C.7', '3.C.8'],
+            #     'entities': ['CO2', 'CH4', 'N2O'],
+            #     'dim': 'category (IPCC2006_PRIMAP)',
+            # },
+            # '3D': {
+            #     'basket': '3.D',
+            #     'basket_contents': ['3.D.1', '3.D.2'],
+            #     'entities': ['CO2', 'CH4', 'N2O'],
+            #     'dim': 'category (IPCC2006_PRIMAP)',
+            # },
+        },
+    },
+    'remove_ts': {
+        'fgases': { # unnecessary and complicates aggregation for
+            # other gases
+            'category': ['5'],
+            'entities': [f'HFCS ({gwp_to_use})', f'PFCS ({gwp_to_use})', 'SF6',
+                         f'UnspMixOfHFCs ({gwp_to_use})'],
+        },
+    },
+}

+ 228 - 0
UNFCCC_GHG_data/UNFCCC_reader/Nigeria/read_NGA_BUR2_from_pdf.py

@@ -0,0 +1,228 @@
+# this script reads data from Nigeria's BUR2
+# Data is read from the pdf file
+
+import pandas as pd
+import primap2 as pm2
+import numpy as np
+import camelot
+import locale
+from copy import deepcopy
+from UNFCCC_GHG_data.helper import downloaded_data_path, extracted_data_path
+from UNFCCC_GHG_data.helper import process_data_for_country, gas_baskets
+from config_NGA_BUR2 import tables_trends
+from config_NGA_BUR2 import pages_inventory, year_inventory, entity_row, unit_row, \
+   index_cols, header_long, units_inv
+from config_NGA_BUR2 import cat_code_regexp, cat_codes_manual
+from config_NGA_BUR2 import coords_cols, coords_defaults, coords_terminologies, \
+    coords_value_mapping, meta_data, filter_remove #, add_coords_cols
+from config_NGA_BUR2 import processing_info_step1, processing_info_step2
+
+# ###
+# configuration
+# ###
+# define locale to use for str to float conversion
+locale_to_use = 'en_NG.UTF-8'
+locale.setlocale(locale.LC_NUMERIC, locale_to_use)
+
+input_folder = downloaded_data_path / 'UNFCCC' / 'Nigeria' / 'BUR2'
+output_folder = extracted_data_path / 'UNFCCC' / 'Nigeria'
+if not output_folder.exists():
+   output_folder.mkdir()
+
+output_filename = 'NGA_BUR2_2021_'
+compression = dict(zlib=True, complevel=9)
+inventory_file = 'NIGERIA_BUR_2_-_Second_Biennial_Update_Report_%28BUR2%29.pdf'
+
+## read 2019 inventory
+df_inventory = None
+for page in pages_inventory.keys():
+    tables = camelot.read_pdf(str(input_folder / inventory_file), pages=str(page),
+                              flavor='lattice')
+    df_this_table = tables[pages_inventory[page]].df
+    # replace line breaks, double, and triple spaces in category names
+    df_this_table.iloc[:, 0] = df_this_table.iloc[:, 0].str.replace("\n", " ")
+    df_this_table.iloc[:, 0] = df_this_table.iloc[:, 0].str.replace("   ", " ")
+    df_this_table.iloc[:, 0] = df_this_table.iloc[:, 0].str.replace("  ", " ")
+    # replace line breaks in units and entities
+    df_this_table.iloc[entity_row] = df_this_table.iloc[entity_row].str.replace('\n',
+                                                                                '')
+    df_this_table.iloc[unit_row] = df_this_table.iloc[unit_row].str.replace('\n', '')
+
+    # fillna in unit row
+    df_this_table.iloc[unit_row][df_this_table.iloc[unit_row]==""] = np.nan
+    df_this_table.iloc[unit_row] = df_this_table.iloc[unit_row].fillna(
+        method='ffill')
+    df_this_table = pm2.pm2io.nir_add_unit_information(df_this_table, unit_row=unit_row,
+                                                       entity_row=entity_row,
+                                                       regexp_entity=".*",
+                                                       manual_repl_unit=units_inv,
+                                                       default_unit="")
+
+    # set index and convert to long format
+    df_this_table = df_this_table.set_index(index_cols)
+    df_this_table_long = pm2.pm2io.nir_convert_df_to_long(df_this_table, year_inventory,
+                                                          header_long)
+
+    # combine with tables for other sectors (merge not append)
+    if df_inventory is None:
+        df_inventory = df_this_table_long
+    else:
+        df_inventory = pd.concat([df_inventory, df_this_table_long], axis=0, join='outer')
+
+# replace cat names by codes in col "category"
+# first the manual replacements
+df_inventory["category"] = df_inventory["category"].replace(cat_codes_manual)
+# then the regex replacements
+repl = lambda m: m.group('code')
+df_inventory["category"] = df_inventory["category"].str.replace(cat_code_regexp, repl, regex=True)
+df_inventory = df_inventory.reset_index(drop=True)
+
+# ###
+# convert to PRIMAP2 interchange format
+# ###
+data_inv_if = pm2.pm2io.convert_long_dataframe_if(
+    df_inventory,
+    coords_cols=coords_cols,
+    #add_coords_cols=add_coords_cols,
+    coords_defaults=coords_defaults,
+    coords_terminologies=coords_terminologies,
+    coords_value_mapping=coords_value_mapping,
+    filter_remove=filter_remove,
+    meta_data=meta_data,
+    convert_str=True,
+    time_format='%Y',
+    )
+
+data_inv_pm2 = pm2.pm2io.from_interchange_format(data_inv_if)
+
+## trend tables
+data_trend_pm2 = None
+for table in tables_trends.keys():
+    print(table)
+    current_table = deepcopy(tables_trends[table])
+    tables = camelot.read_pdf(str(input_folder / inventory_file),
+                              pages=current_table["page"],
+                              table_areas=current_table["area"],
+                              columns=current_table["cols"],
+                              flavor='stream',
+                              split_text=True)
+    df_this_table = tables[0].df
+
+    # merge rows for entity and unit
+    rows_to_merge = df_this_table.iloc[current_table["label_rows"]]
+    indices_to_merge = rows_to_merge.index
+    # join the three rows
+    new_row = rows_to_merge.agg(' '.join)
+    df_this_table.loc[indices_to_merge[0]] = new_row
+    df_this_table = df_this_table.drop(indices_to_merge)
+    new_row = new_row.str.replace("  ", " ")
+    new_row = new_row.str.replace("   ", " ")
+    new_row = new_row.str.strip()
+
+    df_this_table.columns = new_row
+
+    # remove columns not needed
+    if 'remove_cols' in current_table.keys():
+        df_this_table = df_this_table.drop(columns=current_table["remove_cols"])
+
+    df_this_table = df_this_table.set_index("Year")
+
+    # transpose to wide format
+    df_this_table = df_this_table.transpose()
+
+    # remove "," (thousand sep) from data
+    for col in df_this_table.columns:
+        df_this_table.loc[:, col] = df_this_table.loc[:, col].str.strip()
+        repl = lambda m: m.group('part1') + m.group('part2')
+        df_this_table.loc[:, col] = df_this_table.loc[:, col].str.replace(
+            '(?P<part1>[0-9]+),(?P<part2>[0-9\.]+)$', repl, regex=True)
+        df_this_table[col][df_this_table[col].isnull()] = 'NaN'
+
+
+    # metadta in forst col instread of index
+    df_this_table = df_this_table.reset_index()
+    df_this_table = df_this_table.rename(columns={"index": "Year"})
+
+    # make sure we have str not a number format for the dates
+    df_this_table.columns = df_this_table.columns.map(str)
+
+    current_table["coords_defaults"].update(coords_defaults)
+    # convert to interchange format
+    data_current_if = pm2.pm2io.convert_wide_dataframe_if(
+        df_this_table,
+        coords_cols=current_table["coords_cols"],
+        coords_defaults=current_table["coords_defaults"],
+        coords_terminologies=coords_terminologies,
+        coords_value_mapping=current_table["coords_value_mapping"],
+        meta_data=meta_data,
+        convert_str=True,
+        time_format='%Y',
+    )
+# todo: convert to native format before merge
+    data_current_pm2 = pm2.pm2io.from_interchange_format(data_current_if)
+    if data_trend_pm2 is None:
+        data_trend_pm2 = data_current_pm2
+    else:
+        data_trend_pm2 = data_trend_pm2.pr.merge(data_current_pm2)
+
+data_pm2 = data_inv_pm2.pr.merge(data_trend_pm2, tolerance=0.05) # some rounding in
+# trends needs higher tolerance
+
+data_if = data_pm2.pr.to_interchange_format()
+
+# ###
+# save raw data to IF and native format
+# ###
+if not output_folder.exists():
+    output_folder.mkdir()
+pm2.pm2io.write_interchange_format(
+    output_folder / (output_filename + coords_terminologies["category"] + "_raw"),
+    data_if)
+
+encoding = {var: compression for var in data_pm2.data_vars}
+data_pm2.pr.to_netcdf(
+    output_folder / (output_filename + coords_terminologies["category"] + "_raw.nc"),
+    encoding=encoding)
+
+
+#### processing
+data_proc_pm2 = data_pm2
+terminology_proc = coords_terminologies["category"]
+
+# actual processing
+data_proc_pm2 = process_data_for_country(
+    data_proc_pm2,
+    entities_to_ignore=[],
+    gas_baskets={},
+    processing_info_country=processing_info_step1,
+)
+
+data_proc_pm2 = process_data_for_country(
+    data_proc_pm2,
+    entities_to_ignore=[],
+    gas_baskets=gas_baskets,
+    processing_info_country=processing_info_step2,
+    cat_terminology_out = terminology_proc,
+    #category_conversion = None,
+    #sectors_out = None,
+)
+
+# adapt source and metadata
+# TODO: processing info is present twice
+current_source = data_proc_pm2.coords["source"].values[0]
+data_temp = data_proc_pm2.pr.loc[{"source": current_source}]
+data_proc_pm2 = data_proc_pm2.pr.set("source", 'BUR_NIR', data_temp)
+
+# ###
+# save data to IF and native format
+# ###
+data_proc_if = data_proc_pm2.pr.to_interchange_format()
+if not output_folder.exists():
+    output_folder.mkdir()
+pm2.pm2io.write_interchange_format(
+    output_folder / (output_filename + terminology_proc), data_proc_if)
+
+encoding = {var: compression for var in data_proc_pm2.data_vars}
+data_proc_pm2.pr.to_netcdf(
+    output_folder / (output_filename + terminology_proc + ".nc"),
+    encoding=encoding)

+ 1 - 0
UNFCCC_GHG_data/UNFCCC_reader/folder_mapping.json

@@ -5,6 +5,7 @@
     "THA": "Thailand",
     "SGP": "Singapore",
     "ARG": "Argentina",
+    "NGA": "Nigeria",
     "MAR": "Morocco",
     "COL": "Colombia",
     "CHL": "Chile",