Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update global warming potential factors #1905

Merged
merged 3 commits into from
Nov 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions dag/emissions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,16 @@ steps:
- data://meadow/emissions/2023-10-10/net_zero_tracker
data://grapher/emissions/2023-10-10/net_zero_tracker:
- data://garden/emissions/2023-10-10/net_zero_tracker
#
# Global Warming Potential factors (IPCC, 2021).
#
data://meadow/emissions/2023-11-06/global_warming_potential_factors:
- snapshot://emissions/2023-11-06/global_warming_potential_factors.csv
data://garden/emissions/2023-11-06/global_warming_potential_factors:
- data://meadow/emissions/2023-11-06/global_warming_potential_factors
data://grapher/emissions/2023-11-06/global_warming_potential_factors:
- data://garden/emissions/2023-11-06/global_warming_potential_factors

######################################################################################################################
# Older versions to be archived once they are not used by any other steps.
#
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# NOTE: To learn more about the fields, hover over their names.
definitions:
common:
presentation:
topic_tags:
- CO2 & Greenhouse Gas Emissions
- Climate Change


# Learn more about the available fields:
# http://docs.owid.io/projects/etl/architecture/metadata/reference/dataset/
dataset:
title: Global warming potential factors
update_period_days: 365

# Learn more about the available fields:
# http://docs.owid.io/projects/etl/architecture/metadata/reference/tables/
tables:
global_warming_potential_factors:
# Learn more about the available fields:
# http://docs.owid.io/projects/etl/architecture/metadata/reference/indicator/
variables:
gwp_100:
title: Global Warming Potentials with a 100-year time horizon (GWP-100)
unit: ""
short_unit: ""
description_short: "[Global warming potential](#dod:gwp) measures the relative warming impact of one unit mass of a greenhouse gas relative to carbon dioxide."
description_key:
- GWP values are used to convert greenhouse gases into a carbon dioxide equivalent metric by multiplying emissions in mass terms by their respective GWP factors.
- For example, a GWP value of 25 for a certain gas means that one tonne of that ags has 25 times the warming impact of one tonne of carbon dioxide.
processing_level: minor
display:
numDecimalPlaces: 1
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
"""Load a meadow dataset and create a garden 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 meadow dataset and read its main table.
ds_meadow = paths.load_dataset("global_warming_potential_factors")
tb = ds_meadow["global_warming_potential_factors"].reset_index()

#
# Process data.
#
# Combine the name and the formula of each greenhouse gas.
tb = tb.astype({"name": str, "formula": str})
tb["greenhouse_gas"] = tb["name"] + " (" + tb["formula"] + ")"
tb = tb.drop(columns=["name", "formula"])

# Set an appropriate index and sort conveniently.
tb = tb.set_index(["greenhouse_gas"], verify_integrity=True).sort_index()

#
# 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
)
ds_garden.save()
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
"""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 and read its main table.
ds_garden = paths.load_dataset("global_warming_potential_factors")
tb = ds_garden["global_warming_potential_factors"].reset_index()

#
# Process data.
#
# Grapher requires a column named "country", and another named "year".
# We assign the year of publication of the document where the data was extracted from.
tb = tb.rename(columns={"greenhouse_gas": "country"})
tb["year"] = int(tb["gwp_100"].metadata.origins[0].date_published.split("-")[0])

# Set an appropriate index and sort conveniently.
tb = tb.set_index(["country", "year"], verify_integrity=True).sort_index()

#
# 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
)
ds_grapher.save()
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
"""Load a snapshot and create a meadow 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.
#
# Retrieve snapshot.
snap = paths.load_snapshot("global_warming_potential_factors.csv")

# Load data from snapshot.
tb = snap.read()

#
# Process data.
#
# Ensure all columns are snake-case, set an appropriate index, and sort conveniently.
tb = tb.underscore().set_index(["name"], verify_integrity=True).sort_index()

#
# 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()
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Learn more at:
# http://docs.owid.io/projects/etl/architecture/metadata/reference/origin/
meta:
origin:
# Data product / Snapshot
title: IPCC 6th Assessment Report, Working Group I, Chapter 7 Supplementary Material
description: |-
Global warming potential for a 100-year time horizon (GWP-100) for a selection of greenhouse gases.

date_published: 2021-08-09

# Citation
producer: IPCC
citation_full: |-
Working Group I (WGI) Contribution to the Sixth Assessment Report (AR6) of the Intergovernmental Panel on Climate Change (IPCC), Chapter 7: The Earth's Energy Budget, Climate Feedbacks, and Climate Sensitivity.

Data extracted from the Supplementary Materials, Table 7.SM.7: Greenhouse gas lifetimes, radiative efficiencies, global warming potentials (GWPs), global temperature potentials (GTPs) and cumulative global temperature potentials (CGTPs).

Forster, P., T. Storelvmo, K. Armour, W. Collins, J.-L. Dufresne, D. Frame, D.J. Lunt, T. Mauritsen, M.D. Palmer, M. Watanabe, M. Wild, and H. Zhang, 2021: The Earth's Energy Budget, Climate Feedbacks, and Climate Sensitivity. In Climate Change 2021: The Physical Science Basis. Contribution of Working Group I to the Sixth Assessment Report of the Intergovernmental Panel on Climate Change [Masson-Delmotte, V., P. Zhai, A. Pirani, S.L. Connors, C. Péan, S. Berger, N. Caud, Y. Chen, L. Goldfarb, M.I. Gomis, M. Huang, K. Leitzell, E. Lonnoy, J.B.R. Matthews, T.K. Maycock, T. Waterfield, O. Yelekçi, R. Yu, and B. Zhou (eds.)]. Cambridge University Press, Cambridge, United Kingdom and New York, NY, USA, pp. 923-1054, [doi: 10.1017/9781009157896.009](https://www.cambridge.org/core/books/climate-change-2021-the-physical-science-basis/earths-energy-budget-climate-feedbacks-and-climate-sensitivity/AE57C97E588FF3060C7C7E47DD4F3C6E).
attribution_short: IPCC

# Files
url_main: https://www.ipcc.ch/report/ar6/wg1/chapter/chapter-7/
url_download:
https://www.ipcc.ch/report/ar6/wg1/downloads/report/IPCC_AR6_WGI_Chapter07_SM.pdf
date_accessed: 2023-11-06

# License
license:
name: CC BY 4.0
url: https://www.ipcc.ch/report/ar6/wg1/resources/data-access/

wdir: ../../../data/snapshots/emissions/2023-11-06
outs:
- md5: 71d94db83502c78221b63670daab2cce
size: 173
path: global_warming_potential_factors.csv
37 changes: 37 additions & 0 deletions snapshots/emissions/2023-11-06/global_warming_potential_factors.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
"""Script to create a snapshot of dataset."""

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"emissions/{SNAPSHOT_VERSION}/global_warming_potential_factors.csv")

# Manually extract data on global warming potential (GWP-100) from Table 7.SM.7.
tb = snap.read_from_records(
[
("Carbon dioxide", "CO₂", 1),
("Methane", "CH₄", 27.9),
("Nitrous oxide", "N₂O", 273),
("PFC-14", "CF₄", 7380),
("HFC-152a", "CH₃CHF₂", 164),
("Sulphur hexafluoride", "SF₆", 24300),
],
columns=["Name", "Formula", "GWP-100"],
)

# Download data from source, add file to DVC and upload to S3.
snap.create_snapshot(upload=upload, data=tb)


if __name__ == "__main__":
main()