thegreenwebfoundation / co2.js

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

dataCentre grid intensity not applied/returned #197

Closed 5c0tch closed 2 months ago

5c0tch commented 4 months ago

Describe the bug Specifying the dataCentre gridIntensity when calling perVisitTrace returns a response with the dataCentre intensity = 50 (not what is supplied)

To Reproduce Using this: ("9999" used for illustration only)

const options = {
  dataReloadRatio: 0.2,
  firstVisitPercentage: 0.75,
  returnVisitPercentage: 0.25,
  gridIntensity: {
    device: 9999,
    network: 9999,
    dataCenter: 9999,

  },
};

in this call:

const estimatedCO2 = co2Emission.perVisitTrace(bytesSent, greenHost,options);

results in this response:

{
  "co2": 1.0544042663884803,
  "green": true,
  "variables": {
    "description": "Below are the variables used to calculate this CO2 estimate.",
    "bytes": "4347924",
    "gridIntensity": {
      "description": "The grid intensity (grams per kilowatt-hour) used to calculate this CO2 estimate.",
      "network": 9999,
      "dataCenter": 50,
      "production": 442,
      "device": 9999
    },
    "dataReloadRatio": 0.2,
    "firstVisitPercentage": 0.75,
    "returnVisitPercentage": 0.25
  }
}

Expected behavior Expecting to see "dataCenter": 9999 eg.:

{
  "co2": 1.0544042663884803,
  "green": true,
  "variables": {
    "description": "Below are the variables used to calculate this CO2 estimate.",
    "bytes": "4347924",
    "gridIntensity": {
      "description": "The grid intensity (grams per kilowatt-hour) used to calculate this CO2 estimate.",
      "network": 9999,
      "dataCenter": 9999,
      "production": 442,
      "device": 9999
    },
    "dataReloadRatio": 0.2,
    "firstVisitPercentage": 0.75,
    "returnVisitPercentage": 0.25
  }
}

Environment (please complete the following information): Node on macOS (version v21.6.2)

Additional context (if applicable) Add any other context about the problem here.

fershad commented 4 months ago

When the green variable is set to true, the grid intensity used for datacenter is set to 50gCO2e/kWh. This is specified in the Sustainable Web Design model and mentioned in our documentation, however it should be better highlighted.

I will create an issue in the documentation repo to make this change.

5c0tch commented 4 months ago

Thank you. An update to the documentation to show the value is not adjustable and always 50gCO2e/kWh in this situation would help clarify.

On 14 Mar 2024, at 08:31, fershad @.***> wrote:

When the green variable is set to true, the grid intensity used for datacenter is set to 50gCO2e/kWh. This is specified in the Sustainable Web Design model https://sustainablewebdesign.org/calculating-digital-emissions/#:~:text=Carbon%20factor%20(renewable%20energy%20source)%3A%2050%20g/kWh and mentioned in our documentation https://developers.thegreenwebfoundation.org/co2js/tutorials/customise-website-carbon-calculations/#:~:text=The%20global%20average%20grid%20intensity%20is%20used%20for%20all%20segments.%20Green%20hosted%20data%20centers%20use%20a%20grid%20intensity%20of%2050%20g/kWh., however it should be better highlighted.

I will create an issue in the documentation repo to make this change.

— Reply to this email directly, view it on GitHub https://github.com/thegreenwebfoundation/co2.js/issues/197#issuecomment-1996847947, or unsubscribe https://github.com/notifications/unsubscribe-auth/AIDTVMUUZQMRRQNSZLCY55DYYFN43AVCNFSM6AAAAABEUOMIQCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSOJWHA2DOOJUG4. You are receiving this because you authored the thread.

fershad commented 2 months ago

A note has been added to the docs. Sorry it took so long. https://developers.thegreenwebfoundation.org/co2js/tutorials/customise-website-carbon-calculations/