-
-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update global warming potential factors (#1905)
* Add global warming potential factors data * Improve metadata
- Loading branch information
1 parent
cb0c113
commit 11a31ce
Showing
7 changed files
with
219 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
etl/steps/data/garden/emissions/2023-11-06/global_warming_potential_factors.meta.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
35 changes: 35 additions & 0 deletions
35
etl/steps/data/garden/emissions/2023-11-06/global_warming_potential_factors.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
35 changes: 35 additions & 0 deletions
35
etl/steps/data/grapher/emissions/2023-11-06/global_warming_potential_factors.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
32 changes: 32 additions & 0 deletions
32
etl/steps/data/meadow/emissions/2023-11-06/global_warming_potential_factors.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
37 changes: 37 additions & 0 deletions
37
snapshots/emissions/2023-11-06/global_warming_potential_factors.csv.dvc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
37
snapshots/emissions/2023-11-06/global_warming_potential_factors.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |