fix: use dataReloadRatio as multiplier instead of its complement in SWD v4#257
Conversation
…WD v4 Summary In the original formula of the SWD v4 model the data cache ratio is used and the emissions per byte are multiplied with (1 - data cache ratio). The CO2js implementation uses the data reload ratio = (1 - data cache ratio). But this is not reflected in the computation, which still multiplies by (1 - data reload ratio). This PR fixes that.
7457cea to
f5463ea
Compare
|
This addresses #248 in a way - however it keeps the "data reload ratio" value rather than aligning with the "data cache ratio" used in the Sustainable Web Design methodology. There's a question here about whether we stick to the SWD methodology, or do we stray from it slightly in implementation. For reference, currently, the docs refer to @mrchrisadams do you have any thoughts about this? |
|
@fershad Interesting, I wasn't aware of that. For me personally I don't mind if the variables in this implementation do not correspond to the ones from the SWD docs, as long as the underlying formula and the results are the same. But if you are considering a bigger make over, I would also rename |
commit 791a4ce Author: fershad <[email protected]> Date: Tue May 6 11:42:36 2025 +0800 update test constants commit 6628f83 Merge: 8b750d8 d0ff0c1 Author: fershad <[email protected]> Date: Sun May 4 09:14:46 2025 +0800 [AUTOMATED] Update average annual grid intensities commit d0ff0c1 Author: fershad <[email protected]> Date: Sat May 3 10:10:30 2025 +0000 Update average annual grid intensities commit 8b750d8 Author: fershad <[email protected]> Date: Fri Apr 18 16:55:33 2025 +0800 0.16.7 commit 2372c63 Author: fershad <[email protected]> Date: Fri Apr 18 16:55:22 2025 +0800 update changelog commit 55a5388 Author: fershad <[email protected]> Date: Fri Apr 18 16:51:11 2025 +0800 0.16.7 commit 60f16e2 Author: fershad <[email protected]> Date: Fri Apr 18 16:50:42 2025 +0800 0.16.7 commit f8545d0 Author: fershad <[email protected]> Date: Fri Apr 18 16:49:48 2025 +0800 update test constants commit 2b39c43 Merge: dbfb9de 920275b Author: fershad <[email protected]> Date: Fri Apr 4 16:46:27 2025 +0800 [AUTOMATED] Update average annual grid intensities commit 920275b Author: fershad <[email protected]> Date: Thu Apr 3 10:11:47 2025 +0000 Update average annual grid intensities commit dbfb9de Merge: b52c95c 1b02c3c Author: fershad <[email protected]> Date: Wed Mar 5 16:00:48 2025 +0800 [AUTOMATED] Update average annual grid intensities commit b52c95c Merge: 28cef1e 5fa0b7a Author: fershad <[email protected]> Date: Mon Mar 3 21:05:50 2025 +0800 Bump esbuild from 0.14.54 to 0.25.0 commit 1b02c3c Author: fershad <[email protected]> Date: Mon Mar 3 10:11:54 2025 +0000 Update average annual grid intensities commit 5fa0b7a Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed Feb 12 15:31:05 2025 +0000 Bump esbuild from 0.14.54 to 0.25.0 Bumps [esbuild](https://github.com/evanw/esbuild) from 0.14.54 to 0.25.0. - [Release notes](https://github.com/evanw/esbuild/releases) - [Changelog](https://github.com/evanw/esbuild/blob/main/CHANGELOG-2022.md) - [Commits](evanw/esbuild@v0.14.54...v0.25.0) --- updated-dependencies: - dependency-name: esbuild dependency-type: direct:development ... Signed-off-by: dependabot[bot] <[email protected]> commit 28cef1e Author: fershad <[email protected]> Date: Mon Feb 10 14:01:03 2025 +0800 0.16.6 commit 6a1cffe Author: fershad <[email protected]> Date: Mon Feb 10 14:00:35 2025 +0800 update data commit 5bf7cc4 Author: fershad <[email protected]> Date: Mon Feb 10 13:58:33 2025 +0800 adjust test constants commit 5696f86 Merge: 33af86d bae0e07 Author: fershad <[email protected]> Date: Mon Feb 10 13:51:04 2025 +0800 [AUTOMATED] Update average annual grid intensities commit bae0e07 Author: fershad <[email protected]> Date: Mon Feb 3 10:10:52 2025 +0000 Update average annual grid intensities commit 33af86d Author: Thibaud Colas <[email protected]> Date: Tue Jan 21 13:47:48 2025 +0000 Update carbon intensity comment to note the correct year It might also be better longer-term to remove this comment :) commit 9491855 Author: fershad <[email protected]> Date: Mon Jan 20 10:11:07 2025 +0800 0.16.5 commit 91c768f Author: fershad <[email protected]> Date: Mon Jan 20 10:10:30 2025 +0800 0.16.5 commit 174d6b9 Author: fershad <[email protected]> Date: Mon Jan 20 10:10:08 2025 +0800 update test values commit 22c8955 Author: fershad <[email protected]> Date: Mon Jan 20 10:08:53 2025 +0800 0.16.4 commit 96995f3 Merge: 3352742 d824b52 Author: fershad <[email protected]> Date: Mon Jan 20 10:07:21 2025 +0800 [AUTOMATED] Update average annual grid intensities commit d824b52 Author: fershad <[email protected]> Date: Fri Jan 3 10:10:27 2025 +0000 Update average annual grid intensities commit 3352742 Author: fershad <[email protected]> Date: Tue Dec 10 11:12:38 2024 +0800 0.16.4 commit 70b431a Author: fershad <[email protected]> Date: Tue Dec 10 11:12:01 2024 +0800 update test constants commit f9081c8 Merge: 669ea58 686128c Author: fershad <[email protected]> Date: Tue Dec 10 11:10:16 2024 +0800 Merge branch 'main' of https://github.com/thegreenwebfoundation/co2.js commit 686128c Merge: 10e990e 5285f94 Author: fershad <[email protected]> Date: Tue Dec 10 11:03:54 2024 +0800 [AUTOMATED] Update average annual grid intensities commit 5285f94 Author: fershad <[email protected]> Date: Tue Dec 3 10:12:13 2024 +0000 Update average annual grid intensities commit 669ea58 Author: fershad <[email protected]> Date: Sun Dec 1 20:33:13 2024 +0800 replace skypack with esm.sh commit 5361809 Author: fershad <[email protected]> Date: Sat Nov 30 17:13:18 2024 +0800 update changelog commit 10e990e Author: fershad <[email protected]> Date: Sat Nov 30 17:08:05 2024 +0800 update contributors commit 2a6369a Merge: 38b7849 4897ca2 Author: fershad <[email protected]> Date: Sat Nov 30 17:04:54 2024 +0800 Separate options parsing for perByteTrace and perVisitTrace functions commit 4897ca2 Author: fershad <[email protected]> Date: Sat Nov 30 16:55:47 2024 +0800 Squashed commit of the following: commit 38b7849 Author: fershad <[email protected]> Date: Sat Nov 30 16:49:38 2024 +0800 update iife commit 473454b Author: fershad <[email protected]> Date: Sat Nov 30 16:44:08 2024 +0800 0.16.3 commit e85b674 Author: fershad <[email protected]> Date: Sat Nov 30 16:43:29 2024 +0800 update contributors commit 6041435 Author: fershad <[email protected]> Date: Sat Nov 30 16:43:18 2024 +0800 update contributors commit 20c879d Author: fershad <[email protected]> Date: Sat Nov 30 16:37:45 2024 +0800 update contributors commit 432bc0e Merge: 431492d e58125e Author: fershad <[email protected]> Date: Sat Nov 30 16:32:10 2024 +0800 Include all gridIntensity values in adjustments when only some are overridden commit e58125e Author: fershad <[email protected]> Date: Sat Nov 30 16:21:44 2024 +0800 Squashed commit of the following: commit 431492d Author: samuelIkoli <[email protected]> Date: Thu Nov 14 11:18:57 2024 +0100 spelling typo corrected commit d4731ba Author: Chris Adams <[email protected]> Date: Fri Nov 15 07:45:38 2024 +0000 Update changelog to include new PR commit 4146166 Author: Chris Adams <[email protected]> Date: Fri Nov 15 07:40:58 2024 +0000 Update supported versions of nodejs in tests commit 32047da Author: fershad <[email protected]> Date: Tue Nov 12 12:23:08 2024 +0800 update contributors commit 13bb452 Author: fershad <[email protected]> Date: Tue Nov 12 12:20:21 2024 +0800 update to 0.16.2 commit 95c2d00 Author: fershad <[email protected]> Date: Tue Nov 12 12:17:28 2024 +0800 0.16.2 commit 5680b23 Merge: 81633d7 978a92d Author: fershad <[email protected]> Date: Tue Nov 12 11:52:33 2024 +0800 Bump url2green version commit 978a92d Author: fershad <[email protected]> Date: Tue Nov 12 11:51:31 2024 +0800 bump url2green 0.4.1 commit 8eb0630 Author: fershad <[email protected]> Date: Thu Oct 24 12:56:34 2024 +0800 update iife commit 431492d Author: samuelIkoli <[email protected]> Date: Thu Nov 14 11:18:57 2024 +0100 spelling typo corrected commit d4731ba Author: Chris Adams <[email protected]> Date: Fri Nov 15 07:45:38 2024 +0000 Update changelog to include new PR commit 4146166 Author: Chris Adams <[email protected]> Date: Fri Nov 15 07:40:58 2024 +0000 Update supported versions of nodejs in tests commit 32047da Author: fershad <[email protected]> Date: Tue Nov 12 12:23:08 2024 +0800 update contributors commit 13bb452 Author: fershad <[email protected]> Date: Tue Nov 12 12:20:21 2024 +0800 update to 0.16.2 commit 95c2d00 Author: fershad <[email protected]> Date: Tue Nov 12 12:17:28 2024 +0800 0.16.2 commit 5680b23 Merge: 81633d7 978a92d Author: fershad <[email protected]> Date: Tue Nov 12 11:52:33 2024 +0800 Bump url2green version commit 978a92d Author: fershad <[email protected]> Date: Tue Nov 12 11:51:31 2024 +0800 bump url2green 0.4.1 commit afea798 Author: Ash Johns <[email protected]> Date: Thu Nov 7 15:39:36 2024 -0500 address linter errors commit 4c1b8cb Author: Ash Johns <[email protected]> Date: Thu Nov 7 15:28:48 2024 -0500 reduce repeated code and ensure default gridIntensity is returned commit 8eb0630 Author: fershad <[email protected]> Date: Thu Oct 24 12:56:34 2024 +0800 update iife commit 81633d7 Author: fershad <[email protected]> Date: Wed Oct 23 17:06:52 2024 +0800 update test constants commit cd94a29 Merge: e6847e5 9202d20 Author: fershad <[email protected]> Date: Wed Oct 23 11:06:11 2024 +0200 [AUTOMATED] Update average annual grid intensities commit 9202d20 Merge: a44f105 e6847e5 Author: fershad <[email protected]> Date: Wed Oct 23 10:59:19 2024 +0200 Merge branch 'main' into average-intensities/11160031721 commit a44f105 Author: fershad <[email protected]> Date: Wed Oct 23 16:58:25 2024 +0800 update grid average grid intensity data commit 3e3fc3e Author: fershad <[email protected]> Date: Wed Oct 23 16:56:52 2024 +0800 Merged updates to generator scripts from main. commit e6847e5 Merge: 668d8e4 7891414 Author: fershad <[email protected]> Date: Wed Oct 23 10:52:10 2024 +0200 Added basic error handling to data fetch in emissions script commit 7891414 Merge: e535f1b 668d8e4 Author: fershad <[email protected]> Date: Wed Oct 23 10:50:18 2024 +0200 Merge branch 'main' into feature/add-error-handling commit e535f1b Author: fershad <[email protected]> Date: Wed Oct 23 16:41:14 2024 +0800 Squashed commit of the following: commit 668d8e4 Merge: 33c66d7 21a1a25 Author: fershad <[email protected]> Date: Wed Oct 23 10:15:46 2024 +0200 Add JSDoc comments to data generation scripts and output files commit 21a1a25 Author: fershad <[email protected]> Date: Wed Oct 23 16:11:01 2024 +0800 add comments to output of generators commit cab18cf Author: fershad <[email protected]> Date: Wed Oct 23 16:05:24 2024 +0800 add comments about constants in source files commit 33c66d7 Author: fershad <[email protected]> Date: Mon Oct 14 15:46:00 2024 +0800 add note about commenting commit 5e58971 Author: Malay Kumar <[email protected]> Date: Sat Oct 12 19:01:39 2024 +0530 Add JsDoc comments to marginal-intensities-2021 commit 6b000a0 Author: Malay Kumar <[email protected]> Date: Sat Oct 12 19:01:19 2024 +0530 Add JsDoc comments to average-intensities commit 29b6755 Author: Malay Kumar <[email protected]> Date: Sat Oct 12 18:59:08 2024 +0530 Add JsDoc comments to generate_marginal_co2 commit eb4e9ff Author: Malay Kumar <[email protected]> Date: Sat Oct 12 18:58:53 2024 +0530 Add JsDoc comments to generate_average_co2 commit c238d96 Author: fershad <[email protected]> Date: Wed Sep 11 10:30:41 2024 +0800 v0.16.1 commit d5d3156 Author: fershad <[email protected]> Date: Tue Sep 10 15:44:34 2024 +0800 0.16.1 commit 4b10930 Author: fershad <[email protected]> Date: Tue Sep 10 15:43:51 2024 +0800 v0.16.1 commit 8339284 Author: fershad <[email protected]> Date: Tue Sep 10 15:38:33 2024 +0800 update jsr export commit 6c0f991 Merge: 8f9097c ed2d8ab Author: fershad <[email protected]> Date: Tue Sep 10 15:35:05 2024 +0800 Add basic JSR support commit ed2d8ab Author: fershad <[email protected]> Date: Tue Sep 10 15:20:27 2024 +0800 update average grid intensities commit 8f9097c Author: fershad <[email protected]> Date: Tue Sep 10 15:17:29 2024 +0800 update test constants commit ce1ada5 Author: fershad <[email protected]> Date: Tue Sep 10 15:11:41 2024 +0800 update version commit 2962ca1 Author: fershad <[email protected]> Date: Tue Sep 10 15:06:52 2024 +0800 create hosting module commit 2dd34ec Author: fershad <[email protected]> Date: Tue Sep 10 15:03:33 2024 +0800 add mod.ts for jsr commit 870e621 Merge: 7adac52 87d0e62 Author: fershad <[email protected]> Date: Fri Sep 6 14:35:09 2024 +0800 [AUTOMATED] Update average annual grid intensities commit 87d0e62 Author: fershad <[email protected]> Date: Tue Sep 3 10:10:55 2024 +0000 Update average annual grid intensities commit 7adac52 Author: fershad <[email protected]> Date: Wed Aug 21 12:55:39 2024 +0800 update test constant commit 344a513 Merge: 4541319 d080a36 Author: fershad <[email protected]> Date: Wed Aug 14 21:36:04 2024 +0200 [AUTOMATED] Update average annual grid intensities commit d080a36 Author: fershad <[email protected]> Date: Sat Aug 3 10:09:23 2024 +0000 Update average annual grid intensities commit 4541319 Merge: 8f95399 c19da59 Author: fershad <[email protected]> Date: Wed Jul 31 22:38:58 2024 +0200 Export classes inside of the individual models commit c19da59 Author: fershad <[email protected]> Date: Thu Jul 11 22:02:57 2024 +0100 export classes inside of the CO2 class commit 668d8e4 Merge: 33c66d7 21a1a25 Author: fershad <[email protected]> Date: Wed Oct 23 10:15:46 2024 +0200 Add JSDoc comments to data generation scripts and output files commit 21a1a25 Author: fershad <[email protected]> Date: Wed Oct 23 16:11:01 2024 +0800 add comments to output of generators commit cab18cf Author: fershad <[email protected]> Date: Wed Oct 23 16:05:24 2024 +0800 add comments about constants in source files commit 33c66d7 Author: fershad <[email protected]> Date: Mon Oct 14 15:46:00 2024 +0800 add note about commenting commit 5e58971 Author: Malay Kumar <[email protected]> Date: Sat Oct 12 19:01:39 2024 +0530 Add JsDoc comments to marginal-intensities-2021 commit 6b000a0 Author: Malay Kumar <[email protected]> Date: Sat Oct 12 19:01:19 2024 +0530 Add JsDoc comments to average-intensities commit 29b6755 Author: Malay Kumar <[email protected]> Date: Sat Oct 12 18:59:08 2024 +0530 Add JsDoc comments to generate_marginal_co2 commit eb4e9ff Author: Malay Kumar <[email protected]> Date: Sat Oct 12 18:58:53 2024 +0530 Add JsDoc comments to generate_average_co2 commit 065b410 Author: fershad <[email protected]> Date: Thu Oct 3 10:11:13 2024 +0000 Update average annual grid intensities commit c238d96 Author: fershad <[email protected]> Date: Wed Sep 11 10:30:41 2024 +0800 v0.16.1 commit d5d3156 Author: fershad <[email protected]> Date: Tue Sep 10 15:44:34 2024 +0800 0.16.1 commit 4b10930 Author: fershad <[email protected]> Date: Tue Sep 10 15:43:51 2024 +0800 v0.16.1 commit 8339284 Author: fershad <[email protected]> Date: Tue Sep 10 15:38:33 2024 +0800 update jsr export commit 6c0f991 Merge: 8f9097c ed2d8ab Author: fershad <[email protected]> Date: Tue Sep 10 15:35:05 2024 +0800 Add basic JSR support commit ed2d8ab Author: fershad <[email protected]> Date: Tue Sep 10 15:20:27 2024 +0800 update average grid intensities commit 8f9097c Author: fershad <[email protected]> Date: Tue Sep 10 15:17:29 2024 +0800 update test constants commit ce1ada5 Author: fershad <[email protected]> Date: Tue Sep 10 15:11:41 2024 +0800 update version commit 2962ca1 Author: fershad <[email protected]> Date: Tue Sep 10 15:06:52 2024 +0800 create hosting module commit 2dd34ec Author: fershad <[email protected]> Date: Tue Sep 10 15:03:33 2024 +0800 add mod.ts for jsr commit 2474b1c Author: Danielle Subject <[email protected]> Date: Fri Jul 19 11:06:23 2024 -0400 Added basic error handling to data fetch in emissions script commit 38b7849 Author: fershad <[email protected]> Date: Sat Nov 30 16:49:38 2024 +0800 update iife commit 473454b Author: fershad <[email protected]> Date: Sat Nov 30 16:44:08 2024 +0800 0.16.3 commit e85b674 Author: fershad <[email protected]> Date: Sat Nov 30 16:43:29 2024 +0800 update contributors commit 6041435 Author: fershad <[email protected]> Date: Sat Nov 30 16:43:18 2024 +0800 update contributors commit 20c879d Author: fershad <[email protected]> Date: Sat Nov 30 16:37:45 2024 +0800 update contributors commit 432bc0e Merge: 431492d e58125e Author: fershad <[email protected]> Date: Sat Nov 30 16:32:10 2024 +0800 Include all gridIntensity values in adjustments when only some are overridden commit e58125e Author: fershad <[email protected]> Date: Sat Nov 30 16:21:44 2024 +0800 Squashed commit of the following: commit 431492d Author: samuelIkoli <[email protected]> Date: Thu Nov 14 11:18:57 2024 +0100 spelling typo corrected commit d4731ba Author: Chris Adams <[email protected]> Date: Fri Nov 15 07:45:38 2024 +0000 Update changelog to include new PR commit 4146166 Author: Chris Adams <[email protected]> Date: Fri Nov 15 07:40:58 2024 +0000 Update supported versions of nodejs in tests commit 32047da Author: fershad <[email protected]> Date: Tue Nov 12 12:23:08 2024 +0800 update contributors commit 13bb452 Author: fershad <[email protected]> Date: Tue Nov 12 12:20:21 2024 +0800 update to 0.16.2 commit 95c2d00 Author: fershad <[email protected]> Date: Tue Nov 12 12:17:28 2024 +0800 0.16.2 commit 5680b23 Merge: 81633d7 978a92d Author: fershad <[email protected]> Date: Tue Nov 12 11:52:33 2024 +0800 Bump url2green version commit 978a92d Author: fershad <[email protected]> Date: Tue Nov 12 11:51:31 2024 +0800 bump url2green 0.4.1 commit 8eb0630 Author: fershad <[email protected]> Date: Thu Oct 24 12:56:34 2024 +0800 update iife commit 431492d Author: samuelIkoli <[email protected]> Date: Thu Nov 14 11:18:57 2024 +0100 spelling typo corrected commit d4731ba Author: Chris Adams <[email protected]> Date: Fri Nov 15 07:45:38 2024 +0000 Update changelog to include new PR commit 4146166 Author: Chris Adams <[email protected]> Date: Fri Nov 15 07:40:58 2024 +0000 Update supported versions of nodejs in tests commit 32047da Author: fershad <[email protected]> Date: Tue Nov 12 12:23:08 2024 +0800 update contributors commit 13bb452 Author: fershad <[email protected]> Date: Tue Nov 12 12:20:21 2024 +0800 update to 0.16.2 commit 95c2d00 Author: fershad <[email protected]> Date: Tue Nov 12 12:17:28 2024 +0800 0.16.2 commit 5680b23 Merge: 81633d7 978a92d Author: fershad <[email protected]> Date: Tue Nov 12 11:52:33 2024 +0800 Bump url2green version commit 978a92d Author: fershad <[email protected]> Date: Tue Nov 12 11:51:31 2024 +0800 bump url2green 0.4.1 commit afea798 Author: Ash Johns <[email protected]> Date: Thu Nov 7 15:39:36 2024 -0500 address linter errors commit 4c1b8cb Author: Ash Johns <[email protected]> Date: Thu Nov 7 15:28:48 2024 -0500 reduce repeated code and ensure default gridIntensity is returned commit 8eb0630 Author: fershad <[email protected]> Date: Thu Oct 24 12:56:34 2024 +0800 update iife commit 3d4fec7 Author: alexzurbonsen <[email protected]> Date: Sat Sep 7 14:48:05 2024 +0200 separate options parsing for byteTrace and visitTrace functions Signed-off-by: alexzurbonsen <[email protected]>
|
Updated test results and merged in the latest changes from Expecting to merge this PR back into |
|
Thanks a lot @fershad |
|
One thing to do before submitting is to add some notes into the code (comments) that explain what dataReloadRatio is and how it compares to |
Summary
In the original formula of the SWD v4 model the data cache ratio is used and the emissions per byte are multiplied with (1 - data cache ratio). The CO2js implementation uses the data reload ratio = (1 - data cache ratio). But this is not reflected in the computation, which still multiplies by (1 - data reload ratio).
This PR fixes that.
Triage
Type of change
Please select any of the below items that are appropriate.
This pull request:
Related issue/s
Please list below any issues this pull request is related to.
Docs changes required
Do any changes made in this pull request require parts of the CO2.js documentation to be updated?
If you answered "Yes", please create an corresponding issue in our Developer Documentation repository.
Describe the changes made in this pull request
As clearly as possible, describe the changes made in the pull request. You should at least detail "what changes have been made" and "what the results of these changes will be".