thegreenwebfoundation / co2.js

An npm module for accessing the green web API, and estimating the carbon emissions from using digital services
Other
389 stars 49 forks source link

Add marginal carbon intensity data from UNFCCC #102

Closed fershad closed 1 year ago

fershad commented 2 years ago

This PR adds country level marginal carbon intensity data from the UNFCCC to CO2.js. Initially (in this PR) we will be including the source data, and introducing scripts to generate JSON and JS exports of the source CSV file.

Todo:

fershad commented 2 years ago

Include EMBER and UNFCCC data in CO2.js

fershad commented 2 years ago

@mrchrisadams This PR is ready for review. It exposes the UNFCCC data in JSON format, just like we have done for Ember in #69. In order to do this, I have:

  1. Added the UNFCCC data as a CSV file in data/IFI_Default_Grid_Factors_2021_v3.1_unfccc.csv
  2. Added a new column in the countries.csv file to allow the UNFCCC country names to also be mapped to country codes (diff)
    • Please note that some countries in the Ember data are not in the UNFCCC data (e.g. Hong Kong), and some in the UNFCCC data are not in Ember (e.g. Tuvalu).
    • I have also added regions from the two datasets, although we don't use them at the moment.
      1. Moved more of the code into common utils functions which should be easier to maintain going forward.
      2. Moved the main generator scripts into a functions folder to keep the main data folder clean.
      3. Added scripts for marginal intensity to the package.json.
fershad commented 2 years ago

I have also added JSDoc style comments to the utility functions, which should help us when we come back to this code later & help others who want to play with it too. I'll try to do this more often as I touch other parts of the CO2.js code base, so that we can gradually have more complete documentation throughout the library.

fershad commented 2 years ago

@mrchrisadams this should be all set now with the changes we discussed yesterday for #104