This PR is a small update the recent adjustable constants in SWD PR #126.
In this PR there is one additional output, and one logic correction.
Additional Output
The bytes variable will also be returned as part of the perVisitTrace or perByteTrace results. This closes the loop, ensuring that all the inputs into the SWD formula are accounted for in the results.
{
"co2": 0.00027030509999999996,
"green": false,
"variables": {
"description": "Below are the variables used to calculate this CO2 estimate.",
"bytes": 1000,
"gridIntensity": {
"description": "The grid intensity (grams per kilowatt-hour) used to calculate this CO2 estimate.",
"network": 442,
"dataCenter": 442,
"production": 442,
"device": 442
},
"dataReloadRatio": 0.02,
"firstVisitPercentage": 0.75,
"returnVisitPercentage": 0.25
}
}
Logic correction
Now, when using perVisitTrace or perByteTrace, if the user sets the value for green as true then the calculation will us the renewable energy constant of 50 g/kWh in the calculation. This is regardless of if the user has also passed in a value for the dataCenter grid intensity separately.
For example:
perVisitTrace(1000, true, { gridIntensity: { dataCenter: 200 } }) would use the renewable grid intensity value of 50 g/kWh, and not the value of 200 g/kWh set by the user.
perVisitTrace(1000, false, { gridIntensity: { dataCenter: 200 } }) would use the value of 200 g/kWh set by the user.
This PR is a small update the recent adjustable constants in SWD PR #126.
In this PR there is one additional output, and one logic correction.
Additional Output
The
bytes
variable will also be returned as part of theperVisitTrace
orperByteTrace
results. This closes the loop, ensuring that all the inputs into the SWD formula are accounted for in the results.Logic correction
Now, when using
perVisitTrace
orperByteTrace
, if the user sets the value forgreen
astrue
then the calculation will us the renewable energy constant of 50 g/kWh in the calculation. This is regardless of if the user has also passed in a value for thedataCenter
grid intensity separately.For example:
perVisitTrace(1000, true, { gridIntensity: { dataCenter: 200 } })
would use the renewable grid intensity value of 50 g/kWh, and not the value of 200 g/kWh set by the user.perVisitTrace(1000, false, { gridIntensity: { dataCenter: 200 } })
would use the value of 200 g/kWh set by the user.