Skip to content

Python tool for generation of global and national energy system charts, using data from the Global Carbon Project, the National Oceanic and Atmospheric Administration, the Energy Institute and the International Energy Agency.

License

Notifications You must be signed in to change notification settings

shanewhi/world-energy-data

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Generates charts of CO2 emissions, fossil fuel production, energy consumption, and electricity trends for the world and specified countries. Charts are displayed at https://www.worldenergydata.org/.

The does package attempt to check that a compatible country name has been input, but it's coarse and some may break at run-time (e.g. Yemen, which the Energy Institue dataset includes, but only for oil production). This may be hardened in the future if time allows.

Requires installation of Python and dependencies listed below. Charts are output in SVG format, so there's no loss of resolution when magnified.

Python files -

  1. world_energy_data.py (main executable)
  2. user_globals.py (global definitions)
  3. collate.py (extracts and arranges country specific data from input dataset)
  4. process.py (calculations)
  5. output.py (chart calls)
  6. chart.py (chart functions)
  7. countries.py (country name translations between datasets)

Dependencies -

  1. Install a Python3 version from https://www.python.org/downloads/, scroll down to "Information about specific ports, and developer info" and select suitable platform.
  2. Install the following Python libraries by entering the following commands in a terminal:
    a) pip3 install openpyxl
    b) pip3 install git+https://github.com/chenyulue/matplotlib-extra/
    c) pip3 install matplotlib
    d) pip3 install pandas
  3. Install font 'Inter'. Delete matplotlib's font cache files to force rebuilding of cache - in a terminal enter rm ~/.matplotlib/fontlist*
  4. The following datasets are required, which are provided but listed below for reference:
    a) Global Carbon Budget in .xlsx format. The version in this repository is required as 2024 GCP projected values have been included, obtained from https://essd.copernicus.org/preprints/essd-2024-519/essd-2024-519.pdf. Original GCB was downloaded from https://globalcarbonbudgetdata.org/latest-data.html
    b) NOAA ESRL CO2 data in CSV format from https://gml.noaa.gov/ccgg/trends/gl_data.html
    c) Energy Institute Statistical Review of World Energy data from -
    https://www.energyinst.org/statistical-review/resources-and-data-downloads
    (Direct link is https://www.energyinst.org/__data/assets/file/0003/1055694/Consolidated-Dataset-Narrow-format.csv)
    d) IEA CO2 Emissions by Sector and Total Final Consumption by source for each relevant country, in CSV format from
    https://www.iea.org/data-and-statistics/data-tools/energy-statistics-data-browser i. Select Country ii. Select Energy Consumption iii. Select Total final consumption (TFC) by source iv. Select Download chart data v. Select Energy transition indicators vi. Select CO₂ emissions by sector vii. Select Download chart data
    e) https://robbieandrew.github.io/GCB2024/CSV/s64_2024_LinearPathways.csv (datafile from slide 64 at https://robbieandrew.github.io/GCB2024/)
    f) World Bank Group Total Population dataset from https://data.worldbank.org/indicator/SP.POP.TOTL, in CSV format.

Instructions -

  1. Choose a country to profile from those listed in the Energy Institute's data listed in 4(c) above.
  2. Edit line 38 of world_energy_data.py to include the country name, as an exact duplicate of the name selected in (1), and followed by a comma in the case of a single country
    (single element tuple must be followed by a comma).
  3. For data not already included in this repository, obtain and move the IEA datafiles from 4(d) above to the
    same folder as this Python code. Add the IEA's country name to countries.translate_country_name() if need be.
  4. Folders will be created named 'charts CO2' for global CO2 charts (generated on each execution), 'charts country_name' for energy charts, and 'charts Major Emitters' for those used in
    https://www.worldenergydata.org/fossil-fuel-production-and-consumption/
  5. Edit flags in user_globals.py to suit user preferences as required.

Written by Shane White, whitesha@protonmail.com, using Python v3.12

About

Python tool for generation of global and national energy system charts, using data from the Global Carbon Project, the National Oceanic and Atmospheric Administration, the Energy Institute and the International Energy Agency.

Topics

Resources

License

Stars

Watchers

Forks

Languages