From d243b42e6c4aff18f9002e5cca8ac9977e18dfb3 Mon Sep 17 00:00:00 2001 From: Veronika Samborska <32176660+veronikasamborska1994@users.noreply.github.com> Date: Mon, 30 Dec 2024 19:04:35 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=93=8A=20=20Tourism:=20CO2=20emissions=20?= =?UTF-8?q?due=20to=20aviation=20(#3774)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dag/archive/main.yml | 11 + dag/tourism.yml | 12 +- .../co2_air_transport.countries.json | 205 ++++++++++++++++++ .../2024-12-30/co2_air_transport.meta.yml | 119 ++++++++++ .../oecd/2024-12-30/co2_air_transport.py | 127 +++++++++++ .../oecd/2024-12-30/co2_air_transport.py | 32 +++ .../oecd/2024-12-30/co2_air_transport.py | 52 +++++ .../oecd/2024-12-30/co2_air_transport.csv.dvc | 37 ++++ .../oecd/2024-12-30/co2_air_transport.py | 22 ++ 9 files changed, 611 insertions(+), 6 deletions(-) create mode 100644 etl/steps/data/garden/oecd/2024-12-30/co2_air_transport.countries.json create mode 100644 etl/steps/data/garden/oecd/2024-12-30/co2_air_transport.meta.yml create mode 100644 etl/steps/data/garden/oecd/2024-12-30/co2_air_transport.py create mode 100644 etl/steps/data/grapher/oecd/2024-12-30/co2_air_transport.py create mode 100644 etl/steps/data/meadow/oecd/2024-12-30/co2_air_transport.py create mode 100644 snapshots/oecd/2024-12-30/co2_air_transport.csv.dvc create mode 100644 snapshots/oecd/2024-12-30/co2_air_transport.py diff --git a/dag/archive/main.yml b/dag/archive/main.yml index 62bdaa5042d..1da305cf6d0 100644 --- a/dag/archive/main.yml +++ b/dag/archive/main.yml @@ -190,6 +190,16 @@ steps: data://grapher/oecd/2023-05-19/co2_air_transport: - data://garden/oecd/2023-05-19/co2_air_transport + data://meadow/oecd/2024-08-21/co2_air_transport: + - snapshot://oecd/2024-08-21/co2_air_transport.csv + data://garden/oecd/2024-08-21/co2_air_transport: + - data://meadow/oecd/2024-08-21/co2_air_transport + - data://garden/tourism/2024-08-17/unwto + - data://garden/demography/2024-07-15/population + - data://garden/regions/2023-01-01/regions + data://grapher/oecd/2024-08-21/co2_air_transport: + - data://garden/oecd/2024-08-21/co2_air_transport + # Tourism datasets # UNWTO key indicators data://meadow/tourism/2023-05-05/unwto: @@ -231,6 +241,7 @@ steps: - data://garden/ggdc/2024-04-26/maddison_project_database - data://garden/ggdc/2022-12-23/maddison_database + # UN IGME Child Mortality data://meadow/un/2023-08-16/igme: - snapshot://un/2023-08-16/igme.zip diff --git a/dag/tourism.yml b/dag/tourism.yml index 1f6d2dbac61..67ea9a97a40 100644 --- a/dag/tourism.yml +++ b/dag/tourism.yml @@ -33,13 +33,13 @@ steps: - data://meadow/oecd/2024-08-19/ppp_exchange_rates # OECD CO2 emissions from air transport - data://meadow/oecd/2024-08-21/co2_air_transport: - - snapshot://oecd/2024-08-21/co2_air_transport.csv - data://garden/oecd/2024-08-21/co2_air_transport: - - data://meadow/oecd/2024-08-21/co2_air_transport + data://meadow/oecd/2024-12-30/co2_air_transport: + - snapshot://oecd/2024-12-30/co2_air_transport.csv + data://garden/oecd/2024-12-30/co2_air_transport: + - data://meadow/oecd/2024-12-30/co2_air_transport - data://garden/tourism/2024-08-17/unwto - data://garden/demography/2024-07-15/population - data://garden/regions/2023-01-01/regions - data://grapher/oecd/2024-08-21/co2_air_transport: - - data://garden/oecd/2024-08-21/co2_air_transport + data://grapher/oecd/2024-12-30/co2_air_transport: + - data://garden/oecd/2024-12-30/co2_air_transport diff --git a/etl/steps/data/garden/oecd/2024-12-30/co2_air_transport.countries.json b/etl/steps/data/garden/oecd/2024-12-30/co2_air_transport.countries.json new file mode 100644 index 00000000000..5a73f862bca --- /dev/null +++ b/etl/steps/data/garden/oecd/2024-12-30/co2_air_transport.countries.json @@ -0,0 +1,205 @@ +{ + "Afghanistan": "Afghanistan", + "Albania": "Albania", + "Algeria": "Algeria", + "Angola": "Angola", + "Antigua and Barbuda": "Antigua and Barbuda", + "Argentina": "Argentina", + "Armenia": "Armenia", + "Australia": "Australia", + "Austria": "Austria", + "Azerbaijan": "Azerbaijan", + "Bahamas": "Bahamas", + "Bahrain": "Bahrain", + "Bangladesh": "Bangladesh", + "Barbados": "Barbados", + "Belarus": "Belarus", + "Belgium": "Belgium", + "Belize": "Belize", + "Benin": "Benin", + "Bhutan": "Bhutan", + "Bolivia": "Bolivia", + "Bosnia and Herzegovina": "Bosnia and Herzegovina", + "Botswana": "Botswana", + "Brazil": "Brazil", + "Brunei Darussalam": "Brunei", + "Bulgaria": "Bulgaria", + "Burkina Faso": "Burkina Faso", + "Burundi": "Burundi", + "Cabo Verde": "Cape Verde", + "Cambodia": "Cambodia", + "Cameroon": "Cameroon", + "Canada": "Canada", + "Central African Republic": "Central African Republic", + "Chad": "Chad", + "Chile": "Chile", + "Chinese Taipei": "Taiwan", + "Christmas Island": "Christmas Island", + "Cocos (Keeling) Islands": "Cocos Islands", + "Colombia": "Colombia", + "Comoros": "Comoros", + "Congo": "Congo", + "Cook Islands": "Cook Islands", + "Costa Rica": "Costa Rica", + "Croatia": "Croatia", + "Cuba": "Cuba", + "Cyprus": "Cyprus", + "Czechia": "Czechia", + "C\u00f4te d\u2019Ivoire": "Cote d'Ivoire", + "Democratic Republic of the Congo": "Democratic Republic of Congo", + "Denmark": "Denmark", + "Djibouti": "Djibouti", + "Dominica": "Dominica", + "Dominican Republic": "Dominican Republic", + "Ecuador": "Ecuador", + "Egypt": "Egypt", + "El Salvador": "El Salvador", + "Equatorial Guinea": "Equatorial Guinea", + "Eritrea": "Eritrea", + "Estonia": "Estonia", + "Eswatini": "Eswatini", + "Ethiopia": "Ethiopia", + "Fiji": "Fiji", + "Finland": "Finland", + "France": "France", + "Gabon": "Gabon", + "Gambia": "Gambia", + "Georgia": "Georgia", + "Germany": "Germany", + "Ghana": "Ghana", + "Greece": "Greece", + "Grenada": "Grenada", + "Guatemala": "Guatemala", + "Guinea": "Guinea", + "Guinea-Bissau": "Guinea-Bissau", + "Guyana": "Guyana", + "Haiti": "Haiti", + "Honduras": "Honduras", + "Hungary": "Hungary", + "Iceland": "Iceland", + "India": "India", + "Indonesia": "Indonesia", + "Iran": "Iran", + "Iraq": "Iraq", + "Ireland": "Ireland", + "Israel": "Israel", + "Italy": "Italy", + "Jamaica": "Jamaica", + "Japan": "Japan", + "Jersey": "Jersey", + "Jordan": "Jordan", + "Kazakhstan": "Kazakhstan", + "Kenya": "Kenya", + "Kiribati": "Kiribati", + "Kosovo": "Kosovo", + "Kuwait": "Kuwait", + "Kyrgyzstan": "Kyrgyzstan", + "Latvia": "Latvia", + "Lebanon": "Lebanon", + "Lesotho": "Lesotho", + "Liberia": "Liberia", + "Libya": "Libya", + "Lithuania": "Lithuania", + "Luxembourg": "Luxembourg", + "Madagascar": "Madagascar", + "Malawi": "Malawi", + "Malaysia": "Malaysia", + "Maldives": "Maldives", + "Mali": "Mali", + "Malta": "Malta", + "Marshall Islands": "Marshall Islands", + "Mauritania": "Mauritania", + "Mauritius": "Mauritius", + "Mexico": "Mexico", + "Micronesia": "Micronesia (country)", + "Moldova": "Moldova", + "Monaco": "Monaco", + "Mongolia": "Mongolia", + "Montenegro": "Montenegro", + "Morocco": "Morocco", + "Mozambique": "Mozambique", + "Myanmar": "Myanmar", + "Namibia": "Namibia", + "Nauru": "Nauru", + "Nepal": "Nepal", + "Netherlands": "Netherlands", + "New Zealand": "New Zealand", + "Nicaragua": "Nicaragua", + "Niger": "Niger", + "Nigeria": "Nigeria", + "Niue": "Niue", + "North Macedonia": "North Macedonia", + "Norway": "Norway", + "Oman": "Oman", + "Pakistan": "Pakistan", + "Palau": "Palau", + "Panama": "Panama", + "Papua New Guinea": "Papua New Guinea", + "Paraguay": "Paraguay", + "Peru": "Peru", + "Philippines": "Philippines", + "Poland": "Poland", + "Portugal": "Portugal", + "Qatar": "Qatar", + "Romania": "Romania", + "Russia": "Russia", + "Rwanda": "Rwanda", + "Saint Kitts and Nevis": "Saint Kitts and Nevis", + "Saint Lucia": "Saint Lucia", + "Saint Vincent and the Grenadines": "Saint Vincent and the Grenadines", + "Samoa": "Samoa", + "San Marino": "San Marino", + "Sao Tome and Principe": "Sao Tome and Principe", + "Saudi Arabia": "Saudi Arabia", + "Senegal": "Senegal", + "Serbia": "Serbia", + "Seychelles": "Seychelles", + "Sierra Leone": "Sierra Leone", + "Singapore": "Singapore", + "Slovak Republic": "Slovakia", + "Slovenia": "Slovenia", + "Solomon Islands": "Solomon Islands", + "Somalia": "Somalia", + "South Africa": "South Africa", + "South Sudan": "South Sudan", + "Spain": "Spain", + "Sri Lanka": "Sri Lanka", + "Sudan": "Sudan", + "Suriname": "Suriname", + "Sweden": "Sweden", + "Switzerland": "Switzerland", + "Syrian Arab Republic": "Syria", + "Tajikistan": "Tajikistan", + "Tanzania": "Tanzania", + "Thailand": "Thailand", + "Timor-Leste": "East Timor", + "Togo": "Togo", + "Tonga": "Tonga", + "Trinidad and Tobago": "Trinidad and Tobago", + "Tunisia": "Tunisia", + "Turkmenistan": "Turkmenistan", + "Tuvalu": "Tuvalu", + "Uganda": "Uganda", + "Ukraine": "Ukraine", + "United Arab Emirates": "United Arab Emirates", + "United Kingdom": "United Kingdom", + "United States": "United States", + "Uruguay": "Uruguay", + "Uzbekistan": "Uzbekistan", + "Vanuatu": "Vanuatu", + "Venezuela": "Venezuela", + "Viet Nam": "Vietnam", + "World": "World", + "Yemen": "Yemen", + "Zambia": "Zambia", + "Zimbabwe": "Zimbabwe", + "China (People\u2019s Republic of)": "China", + "Democratic People\u2019s Republic of Korea": "North Korea", + "Hong Kong (China)": "Hong Kong", + "Korea": "South Korea", + "Lao People\u2019s Democratic Republic": "Laos", + "Macau (China)": "Macao", + "OECD": "OECD", + "Sint Maarten": "Sint Maarten (Dutch part)", + "T\u00fcrkiye": "Turkey" +} \ No newline at end of file diff --git a/etl/steps/data/garden/oecd/2024-12-30/co2_air_transport.meta.yml b/etl/steps/data/garden/oecd/2024-12-30/co2_air_transport.meta.yml new file mode 100644 index 00000000000..68375ce64da --- /dev/null +++ b/etl/steps/data/garden/oecd/2024-12-30/co2_air_transport.meta.yml @@ -0,0 +1,119 @@ +# NOTE: To learn more about the fields, hover over their names. +definitions: + common: + presentation: + topic_tags: + - Tourism + display: + numDecimalPlaces: 0 + + desc_short_int: &desc_short_int |- + International aviation emissions are assigned to the country of departure. CO₂ emissions from commercial passenger flights only. + desc_short_dom: &desc_short_dom |- + Domestic aviation represents flights which depart and arrive within the same country. CO₂ emissions from commercial passenger flights only. + desc_process_per_capita: &desc_process_per_capita |- + CO₂ emissions per capita from aviation are calculated by dividing emissions from aviation by the total population of the country. This allows us to understand the average amount of CO₂ emissions attributed to each individual as a result of air travel. + description_processing_tour_adj: &description_processing_tour_adj |- + - CO₂ emission footprints do not necessarily reflect the amount of travel by locals in a given location. This is especially true if a country has high tourist volumes - much of the departures will result from travellers rather than local residents. + + - We have therefore also calculated 'adjusted' aviation footprints by multiplying international CO₂ emissions by an adjustment factor. + + - This adjustment factor is taken as the ratio between outbound and inbound tourist trips. + + - A high ratio of outbound-to-inbound tourist trips indicates that a country receives less visitors than its residents travel abroad. This results in a relatively lower burden of emissions from international flights being allocated to the country whose residents don't travel internationally as frequently. +# Learn more about the available fields: +# http://docs.owid.io/projects/etl/architecture/metadata/reference/ +dataset: + update_period_days: 365 + + +tables: + co2_air_transport: + variables: + ter_dom_a: + title: Annual CO₂ emissions from domestic aviation + description_short: *desc_short_dom + unit: tonnes + short_unit: t + + ter_int_a: + title: Annual CO₂ emissions from international aviation + description_short: *desc_short_int + unit: tonnes + short_unit: t + + per_capita_ter_dom_a: + title: Per capita CO₂ emissions from domestic aviation + unit: kilograms + description_short: *desc_short_dom + description_processing: *desc_process_per_capita + short_unit: kg + + per_capita_ter_int_a: + title: Per capita CO₂ emissions from international aviation + description_short: *desc_short_int + description_processing: *desc_process_per_capita + unit: kilograms + short_unit: kg + + int_inb_out_per_capita: + title: Per capita CO₂ emissions from international flights, international tourism-adjusted + description_short: International aviation emissions are allocated to the country of departure, then [adjusted for tourism](#dod:tourism-adjusted). + description_processing: *description_processing_tour_adj + unit: kilograms + short_unit: kg + + int_inb_out_tot: + title: CO₂ emissions from international flights, international tourism-adjusted + description_short: International aviation emissions are allocated to the country of departure, then [adjusted for tourism](#dod:tourism-adjusted). + description_processing: *description_processing_tour_adj + unit: kilograms + short_unit: kg + + ter_dom_m: + title: Monthly CO₂ emissions from domestic aviation + description_short: *desc_short_dom + unit: tonnes + short_unit: t + display: + zeroDay: '2019-01-01' + yearIsDay: true + + ter_int_m: + title: Monthly CO₂ emissions from international aviation + description_short: *desc_short_int + unit: tonnes + short_unit: t + display: + zeroDay: '2019-01-01' + yearIsDay: true + + per_capita_ter_dom_m: + title: Monthly CO₂ emissions from domestic aviation per capita + description_short: *desc_short_dom + description_processing: *desc_process_per_capita + unit: kilograms + short_unit: kg + display: + zeroDay: '2019-01-01' + yearIsDay: true + + per_capita_ter_int_m: + title: Monthly CO₂ emissions from international aviation per capita + description_short: *desc_short_int + description_processing: *desc_process_per_capita + unit: kilograms + short_unit: kg + display: + zeroDay: '2019-01-01' + yearIsDay: true + + total_monthly_emissions: + title: Monthly CO₂ total emissions from aviation + description_short: Includes emissions from both domestic and international aviation. International aviation emissions are assigned to the country of departure. CO₂ emissions from commercial passenger flights only. + unit: tonnes + short_unit: t + display: + zeroDay: '2019-01-01' + yearIsDay: true + diff --git a/etl/steps/data/garden/oecd/2024-12-30/co2_air_transport.py b/etl/steps/data/garden/oecd/2024-12-30/co2_air_transport.py new file mode 100644 index 00000000000..c87226b3fd3 --- /dev/null +++ b/etl/steps/data/garden/oecd/2024-12-30/co2_air_transport.py @@ -0,0 +1,127 @@ +"""Load a meadow dataset and create a garden dataset.""" + +import pandas as pd +from owid.catalog import processing as pr + +from etl.data_helpers import geo +from etl.helpers import PathFinder, create_dataset + +# Get paths and naming conventions for current step. +paths = PathFinder(__file__) + +# Define regions to aggregate +REGIONS = ["Europe", "Asia", "North America", "South America", "Africa", "Oceania"] + +# Define fraction of allowed NaNs per year +FRAC_ALLOWED_NANS_PER_YEAR = 0.2 + + +def run(dest_dir: str) -> None: + # + # Load inputs. + # + # Load meadow dataset. + ds_meadow = paths.load_dataset("co2_air_transport") + ds_tourism = paths.load_dataset("unwto") + ds_population = paths.load_dataset("population") + ds_regions = paths.load_dataset("regions") + + # Read table from meadow dataset. + tb = ds_meadow["co2_air_transport"].reset_index() + tb_tourism = ds_tourism["unwto"].reset_index() + + # + # Process data. + # + tb = geo.harmonize_countries(df=tb, countries_file=paths.country_mapping_path) + tb = tb[tb["flight_type"] == "Passenger flights"] + tb = tb.drop("flight_type", axis=1) + tb = tb[tb["emissions_source"].isin(["TER_DOM", "TER_INT"])] + + tb_annual = process_annual_data(tb) + tb_annual = geo.add_population_to_table(tb_annual, ds_population) + + emissions_columns = [col for col in tb_annual.columns if col not in ("country", "year", "population")] + + # Generate per capital co2 emissions data and add it do the dataframe and convert to kg + for col in emissions_columns: + tb_annual[f"per_capita_{col}"] = (tb_annual[col] * 1000) / tb_annual["population"] + + tb_annual = add_inbound_outbound_tour(tb_annual, tb_tourism) + + tb_monthly = process_monthly_data(tb) + emissions_columns = [col for col in tb_monthly.columns if col not in ("country", "year", "population")] + + # Generate per capital co2 emissions data and add it do the dataframe and convert to kg + for col in emissions_columns: + tb_monthly[f"per_capita_{col}"] = (tb_monthly[col] * 1000) / tb_annual["population"] + + tb = pr.merge(tb_annual, tb_monthly, on=["year", "country"], how="outer") + + tb = tb[tb["year"] != 2024] + tb = tb.drop(["population"], axis=1) + tb["total_monthly_emissions"] = tb["TER_INT_m"] + tb["TER_DOM_m"] + + tb = geo.add_regions_to_table(tb=tb, ds_regions=ds_regions, regions=REGIONS, frac_allowed_nans_per_year=0.9) + + tb = tb.format(["country", "year"]) + + # + # Save outputs. + # + # Create a new garden dataset with the same metadata as the meadow dataset. + ds_garden = create_dataset( + dest_dir, tables=[tb], check_variables_metadata=True, default_metadata=ds_meadow.metadata + ) + + # Save changes in the new garden dataset. + ds_garden.save() + + +def process_annual_data(tb): + tb = tb[tb["frequency_of_observation"] == "Annual"] + tb = tb.drop(["frequency_of_observation", "month"], axis=1) + + tb["emissions_source"] = tb["emissions_source"].apply(lambda x: x + "_a") + + tb = tb.pivot(values="value", index=["country", "year"], columns=["emissions_source"]) + tb = tb.reset_index() + + return tb + + +def process_monthly_data(tb): + tb = tb[tb["frequency_of_observation"] == "Monthly"] + tb = tb.drop(["frequency_of_observation"], axis=1) + # Remove rows with NaN values in 'year' or 'month' + tb = tb.dropna(subset=["month"]) + + # Create a new 'date' column separately + date_column = pd.to_datetime(tb["year"].astype(str) + "-" + tb["month"].astype(str) + "-15", format="mixed") + tb["date"] = date_column + tb["emissions_source"] = tb["emissions_source"].apply(lambda x: x + "_m") + + # Calculate the number of days since 2019 + tb["days_since_2019"] = (tb["date"] - pd.to_datetime("2019-01-01")).dt.days + tb = tb.drop(["month", "year", "date"], axis=1) + tb = tb.rename(columns={"days_since_2019": "year"}) + + # Pivot the table for monthly data + tb = tb.pivot(values="value", index=["country", "year"], columns=["emissions_source"]) + tb = tb.reset_index() + + return tb + + +def add_inbound_outbound_tour(tb, tb_tourism): + just_inb_ratio = tb_tourism[["country", "year", "inbound_outbound_tourism"]] + tb = pr.merge(tb, just_inb_ratio, on=["year", "country"]) + + # Calculate the interaction between TER_INT_a and inb_outb_tour + tb["int_inb_out_per_capita"] = tb["per_capita_TER_INT_a"] / tb["inbound_outbound_tourism"] + tb["int_inb_out_tot"] = tb["TER_INT_a"] * tb["inbound_outbound_tourism"] + + # Drop the 'inb_outb_tour' column + tb = tb.drop(["inbound_outbound_tourism"], axis=1) + + return tb diff --git a/etl/steps/data/grapher/oecd/2024-12-30/co2_air_transport.py b/etl/steps/data/grapher/oecd/2024-12-30/co2_air_transport.py new file mode 100644 index 00000000000..f5bd6dfda89 --- /dev/null +++ b/etl/steps/data/grapher/oecd/2024-12-30/co2_air_transport.py @@ -0,0 +1,32 @@ +"""Load a garden dataset and create a grapher dataset.""" + +from etl.helpers import PathFinder, create_dataset + +# Get paths and naming conventions for current step. +paths = PathFinder(__file__) + + +def run(dest_dir: str) -> None: + # + # Load inputs. + # + # Load garden dataset. + ds_garden = paths.load_dataset("co2_air_transport") + + # Read table from garden dataset. + tb = ds_garden["co2_air_transport"] + + # + # Process data. + # + + # + # Save outputs. + # + # Create a new grapher dataset with the same metadata as the garden dataset. + ds_grapher = create_dataset( + dest_dir, tables=[tb], check_variables_metadata=True, default_metadata=ds_garden.metadata + ) + + # Save changes in the new grapher dataset. + ds_grapher.save() diff --git a/etl/steps/data/meadow/oecd/2024-12-30/co2_air_transport.py b/etl/steps/data/meadow/oecd/2024-12-30/co2_air_transport.py new file mode 100644 index 00000000000..394313ebf76 --- /dev/null +++ b/etl/steps/data/meadow/oecd/2024-12-30/co2_air_transport.py @@ -0,0 +1,52 @@ +"""Load a snapshot and create a meadow dataset.""" + +import pandas as pd + +from etl.helpers import PathFinder, create_dataset + +# Get paths and naming conventions for current step. +paths = PathFinder(__file__) + + +def run(dest_dir: str) -> None: + # + # Load inputs. + # + # Retrieve snapshot. + snap = paths.load_snapshot("co2_air_transport.csv") + + # Load data from snapshot. + tb = snap.read(safe_types=False) + columns_to_use = [ + "Reference area", + "Frequency of observation", + "EMISSIONS_SOURCE", + "Flight type", + "TIME_PERIOD", + "OBS_VALUE", + ] + tb = tb[columns_to_use] + + # Convert the 'year' column to datetime + tb["TIME_PERIOD"] = pd.to_datetime(tb["TIME_PERIOD"], format="mixed") + + # Extract the month and year from 'year' column and create new columns + tb["month"] = tb["TIME_PERIOD"].dt.month + tb["year"] = tb["TIME_PERIOD"].dt.year + tb = tb.drop(["TIME_PERIOD"], axis=1) + + tb = tb.rename(columns={"Reference area": "country", "OBS_VALUE": "value"}) + # + # Process data. + # + # Ensure all columns are snake-case, set an appropriate index, and sort conveniently. + tb = tb.format(["country", "year", "month", "flight_type", "frequency_of_observation", "emissions_source"]) + + # + # Save outputs. + # + # Create a new meadow dataset with the same metadata as the snapshot. + ds_meadow = create_dataset(dest_dir, tables=[tb], check_variables_metadata=True, default_metadata=snap.metadata) + + # Save changes in the new meadow dataset. + ds_meadow.save() diff --git a/snapshots/oecd/2024-12-30/co2_air_transport.csv.dvc b/snapshots/oecd/2024-12-30/co2_air_transport.csv.dvc new file mode 100644 index 00000000000..e3b242722fe --- /dev/null +++ b/snapshots/oecd/2024-12-30/co2_air_transport.csv.dvc @@ -0,0 +1,37 @@ +# http://docs.owid.io/projects/etl/architecture/metadata/reference/ +meta: + origin: + # Data product / Snapshot + title: Air transport CO2 emissions (experimental) + description: |- + This database provides annual, quarterly and monthly estimates for carbon dioxide (CO2) emissions from commercial passenger, freight and general aviation flights. The emissions are estimated for 186 countries by the OECD, based on a consistent methodology across countries. From 2019, the estimates are compiled using Automatic Dependent Surveillance-Broadcast (ADS-B) flight data from the International Civil Aviation Organisation (ICAO). + + The database provides measures of CO2 emissions on a territory basis, which is used for reporting in the UN Framework Convention on Climate Change (UNFCCC) inventories; and also on a residence basis, which is used to estimate the emissions of air transport (H51 in the International Standard Industrial Classification of All Economic Activities, or ISIC) in the Air Emission Accounts (AEAs). + + Seven components of these CO2 emissions measures can be selected from the ‘Emissions ’ filter. In the tables, these are also shown with the letters A, B, C, D, E, F and G. The UNFCCC inventories and AEA air transport (ISIC H51) measures of CO2 emissions are calculated as: + Inventories: domestic aviation = A + C + Inventories: international aviation (memo item) = D + G + Air emissions accounts: air transport (ISIC H51) = A + B + D + E + F + Three categories of flight are shown on the database: total flights, passenger flights, and freight flights. General aviation (non-freight flights with fewer than 19 passengers such as agricultural planes and private jets) is included with passenger flights. + + The estimation methodology is described in the OECD Working Paper CO2 Emissions from Air Transport - A Near-Real-Time Global Database for Policy Analysis. and in the note Air transport CO2 emissions methodology update. + date_published: 2024-10-23 + + # Citation + producer: OECD + citation_full: |- + OECD (2024). OECD Data Explorer. Air transport CO2 emissions (experimental). + + # Files + url_main: https://data-explorer.oecd.org/vis?df[ds]=DisseminateFinalDMZ&df[id]=DSD_AIR_TRANSPORT%40DF_AIR_TRANSPORT&df[ag]=OECD.SDD.NAD.SEEA&dq=W%2BZWE%2BZMB%2BYEM%2BVNM%2BVEN%2BVUT%2BUZB%2BURY%2BARE%2BUKR%2BUGA%2BTUV%2BTKM%2BTUN%2BTTO%2BTON%2BTGO%2BTLS%2BTHA%2BTZA%2BTJK%2BSYR%2BTWN%2BSUR%2BSDN%2BLKA%2BSSD%2BZAF%2BSOM%2BSLB%2BSXM%2BSLE%2BSGP%2BSYC%2BSRB%2BSEN%2BSAU%2BSTP%2BSMR%2BWSM%2BVCT%2BLCA%2BKNA%2BRWA%2BRUS%2BROU%2BQAT%2BPHL%2BPER%2BPRY%2BPNG%2BPAN%2BPLW%2BPAK%2BOMN%2BMKD%2BNGA%2BNIU%2BNIC%2BNER%2BNRU%2BNPL%2BNAM%2BMMR%2BMOZ%2BMAR%2BMNE%2BMNG%2BMCO%2BMDA%2BFSM%2BMUS%2BMRT%2BMHL%2BMLT%2BMLI%2BMDV%2BMYS%2BMWI%2BMDG%2BMAC%2BLBY%2BLBR%2BLSO%2BLBN%2BLAO%2BKWT%2BKGZ%2BXKV%2BKIR%2BKEN%2BKAZ%2BJOR%2BJEY%2BJAM%2BIRQ%2BIDN%2BIRN%2BIND%2BHKG%2BHND%2BHTI%2BGUY%2BGNB%2BGIN%2BGTM%2BGRD%2BGHA%2BGEO%2BGMB%2BGAB%2BFJI%2BETH%2BSWZ%2BERI%2BGNQ%2BSLV%2BEGY%2BECU%2BDOM%2BDMA%2BCOD%2BDJI%2BPRK%2BCYP%2BCUB%2BHRV%2BCIV%2BCOK%2BCOG%2BCCK%2BCOM%2BCXR%2BCHN%2BTCD%2BCAF%2BCMR%2BKHM%2BCPV%2BBDI%2BBFA%2BBGR%2BBRN%2BBRA%2BBWA%2BBIH%2BBOL%2BBTN%2BBEN%2BBLZ%2BBLR%2BBRB%2BBGD%2BBHR%2BBHS%2BAZE%2BARM%2BARG%2BATG%2BAGO%2BDZA%2BALB%2BAFG%2BWXOECD%2BOECD%2BUSA%2BGBR%2BTUR%2BCHE%2BSWE%2BESP%2BSVN%2BSVK%2BPRT%2BPOL%2BNOR%2BNZL%2BNLD%2BMEX%2BLUX%2BLTU%2BLVA%2BKOR%2BJPN%2BITA%2BISR%2BIRL%2BISL%2BGRC%2BHUN%2BDEU%2BFIN%2BEST%2BDNK%2BCZE%2BCRI%2BCOL%2BCHL%2BBEL%2BCAN%2BAUT%2BAUS%2BFRA.M.....P.RES_TOTAL%2BTER_INT%2BTER_DOM%2BRES_ABROAD%2BNRES_TERR%2BNRES_INT_FROM%2BRES_INT_OUT%2BRES_INT_TO%2BRES_INT_FROM%2BNRES_DOM_IN%2BRES_DOM_OUT%2BRES_DOM_IN.&pd=2013-01%2C2024-09&to[TIME_PERIOD]=false&ly[cl]=TIME_PERIOD&ly[rw]=EMISSIONS_SOURCE%2CCOMBINED_UNIT_MEASURE%2CREF_AREA&vw=tb + url_download: https://sdmx.oecd.org/public/rest/data/OECD.SDD.NAD.SEEA,DSD_AIR_TRANSPORT@DF_AIR_TRANSPORT,/all?dimensionAtObservation=AllDimensions&format=csvfilewithlabels + date_accessed: 2024-12-30 + + # License + license: + name: OECD Terms of Conditions + url: https://www.oecd.org/en/about/terms-conditions.html +outs: + - md5: aee9eb3b10f767d02103c64a23a64ab6 + size: 157089022 + path: co2_air_transport.csv diff --git a/snapshots/oecd/2024-12-30/co2_air_transport.py b/snapshots/oecd/2024-12-30/co2_air_transport.py new file mode 100644 index 00000000000..66b6e5e7562 --- /dev/null +++ b/snapshots/oecd/2024-12-30/co2_air_transport.py @@ -0,0 +1,22 @@ +from pathlib import Path + +import click + +from etl.snapshot import Snapshot + +# Version for current snapshot dataset. +SNAPSHOT_VERSION = Path(__file__).parent.name + + +@click.command() +@click.option("--upload/--skip-upload", default=True, type=bool, help="Upload dataset to Snapshot") +def main(upload: bool) -> None: + # Create a new snapshot. + snap = Snapshot(f"oecd/{SNAPSHOT_VERSION}/co2_air_transport.csv") + + # Download data from source, add file to DVC and upload to S3. + snap.create_snapshot(upload=upload) + + +if __name__ == "__main__": + main()