8 Commits

Author SHA1 Message Date
fauno 11cb80cf7c v0.5.11 2025-01-20 10:02:05 -03:00
fauno f984f6d47c feat: upgrade average intensity to 0.16.5 2025-01-20 10:01:24 -03:00
fauno d2f4907fcd v0.5.10 2024-12-10 10:19:17 -03:00
fauno c1ec450c33 feat: upgrade intensity data to v0.16.4 2024-12-10 10:18:42 -03:00
fauno 85dd3a58fd v0.5.9 2024-11-12 09:44:28 -03:00
fauno 83b3357e7b feat: 0.16.2 intensity data 2024-11-12 09:44:08 -03:00
fauno 6cc63614ea fix: don't fail if the intensity is integer 2024-11-12 09:43:09 -03:00
fauno befa954635 doc: how to update the data 2024-11-12 09:42:59 -03:00
4 changed files with 221 additions and 200 deletions
+16
View File
@@ -43,6 +43,22 @@ most countries.
`access_log` uses marginal data by default.
### Update the data
1. Go to the `data/output` directory on [co2.js
repository](https://github.com/thegreenwebfoundation/co2.js/tree/v0.16.2/data/output)
for the latest version released (in this example 0.16.2)
2. Download the `average-intensities.json` file.
3. Run `src/average_intensities_by_country.cr` with this file as stdin.
```
crystal run src/average_intensities_by_country.cr < average-intensities.json >> src/swd/average_intensity.cr
```
4. Modify `src/swd/average_intensity.cr` to fix the data.
## Create database
```bash
+1 -1
View File
@@ -1,5 +1,5 @@
name: "access_log"
version: "0.5.8"
version: "0.5.11"
authors:
- "f <f@sutty.nl>"
targets:
+6 -1
View File
@@ -23,7 +23,12 @@ JSON.parse(ARGF.gets_to_end).as_h.each do |country, data|
STDERR.puts "ok - #{country}"
average_intensities[countries[data["country_code"].as_s]] = data["emissions_intensity_gco2_per_kwh"].as_f
average_intensities[countries[data["country_code"].as_s]] =
begin
data["emissions_intensity_gco2_per_kwh"].as_f
rescue TypeCastError
data["emissions_intensity_gco2_per_kwh"].as_i.to_f
end
end
puts average_intensities.to_json
+198 -198
View File
@@ -2,215 +2,215 @@ class SWD
module IntensityData
# @see {co2.js/data/output/average-intensities.json}
AVERAGE_INTENSITY_BY_ISO_CODE = {
"AE": 561.14,
"AF": 120.48,
"AG": 657.14,
"AL": 23.44,
"AM": 280.06,
"AO": 212.42,
"AR": 394.62,
"AS": 687.5,
"AT": 110.48,
"AU": 570.35,
"AW": 591.4,
"AZ": 719.39,
"BA": 600.0,
"BB": 644.86,
"BD": 677.38,
"BE": 137.68,
"BF": 611.43,
"BG": 335.42,
"BH": 956.55,
"AE": 492.7,
"AF": 132.53,
"AG": 611.11,
"AL": 24.29,
"AM": 264.54,
"AO": 174.73,
"AR": 353.96,
"AS": 611.11,
"AT": 112.07,
"AU": 556.3,
"AW": 561.22,
"AZ": 671.39,
"BA": 600.94,
"BB": 605.51,
"BD": 691.41,
"BE": 135.11,
"BF": 467.53,
"BG": 338.58,
"BH": 904.62,
"BI": 250.0,
"BJ": 666.67,
"BN": 961.54,
"BO": 481.83,
"BR": 105.51,
"BS": 698.11,
"BT": 24.44,
"BW": 867.58,
"BY": 465.34,
"BZ": 484.38,
"CA": 161.43,
"CD": 25.36,
"BJ": 584.07,
"BN": 893.91,
"BO": 531.69,
"BR": 96.4,
"BS": 660.1,
"BT": 23.33,
"BW": 847.91,
"BY": 441.74,
"BZ": 225.81,
"CA": 165.15,
"CD": 24.46,
"CF": 0.0,
"CG": 723.88,
"CH": 34.85,
"CI": 453.55,
"CK": 400.0,
"CL": 353.52,
"CM": 278.26,
"CN": 585.82,
"CO": 198.53,
"CR": 37.21,
"CU": 677.47,
"CV": 600.0,
"CY": 535.19,
"CZ": 449.65,
"DE": 380.95,
"DJ": 666.67,
"DK": 151.65,
"CG": 700.0,
"CH": 29.56,
"CI": 393.89,
"CK": 250.0,
"CL": 291.11,
"CM": 305.42,
"CN": 583.61,
"CO": 259.51,
"CR": 53.38,
"CU": 637.61,
"CV": 558.14,
"CY": 533.84,
"CZ": 442.5,
"DE": 371.43,
"DJ": 692.31,
"DK": 150.25,
"DM": 529.41,
"DO": 592.49,
"DZ": 633.73,
"EC": 192.39,
"EE": 416.03,
"EG": 570.13,
"ER": 688.89,
"ES": 174.04,
"ET": 25.19,
"FI": 79.16,
"FJ": 289.47,
"DO": 578.41,
"DZ": 634.61,
"EC": 166.91,
"EE": 390.03,
"EG": 574.04,
"ER": 631.58,
"ES": 169.77,
"ET": 24.64,
"FI": 82.01,
"FJ": 288.46,
"FK": 500.0,
"FO": 428.57,
"FR": 56.04,
"GA": 397.38,
"GB": 237.74,
"GD": 714.29,
"GE": 176.97,
"GF": 237.62,
"GH": 498.81,
"GL": 133.33,
"GM": 700.0,
"GN": 208.63,
"GP": 536.15,
"GQ": 492.96,
"GR": 336.71,
"GT": 331.72,
"GU": 670.33,
"GW": 750.0,
"GY": 642.28,
"HK": 733.05,
"HN": 378.97,
"HR": 204.96,
"HT": 606.06,
"HU": 204.3,
"ID": 675.93,
"IE": 290.81,
"IL": 641.17,
"IN": 705.13,
"IQ": 708.1,
"IR": 665.15,
"IS": 28.56,
"IT": 331.02,
"JM": 588.51,
"JO": 572.74,
"JP": 512.81,
"KE": 101.13,
"KG": 124.48,
"KH": 436.13,
"FO": 404.76,
"FR": 55.24,
"GA": 491.6,
"GB": 228.25,
"GD": 640.0,
"GE": 167.59,
"GF": 217.82,
"GH": 484.0,
"GL": 178.57,
"GM": 666.67,
"GN": 236.84,
"GP": 500.0,
"GQ": 591.84,
"GR": 337.16,
"GT": 328.27,
"GU": 622.86,
"GW": 625.0,
"GY": 640.35,
"HK": 699.5,
"HN": 282.27,
"HR": 196.55,
"HT": 567.31,
"HU": 196.23,
"ID": 682.43,
"IE": 284.89,
"IL": 582.93,
"IN": 713.01,
"IQ": 688.81,
"IR": 641.73,
"IS": 27.68,
"IT": 323.71,
"JM": 555.56,
"JO": 540.92,
"JP": 493.59,
"KE": 71.2,
"KG": 147.29,
"KH": 417.71,
"KI": 666.67,
"KM": 714.29,
"KN": 681.82,
"KP": 182.01,
"KR": 441.65,
"KW": 648.72,
"KY": 684.93,
"KZ": 830.41,
"LA": 284.21,
"LB": 663.1,
"LC": 685.71,
"LK": 543.12,
"LR": 304.35,
"KM": 642.86,
"KN": 636.36,
"KP": 389.59,
"KR": 432.11,
"KW": 649.16,
"KY": 642.86,
"KZ": 821.9,
"LA": 265.51,
"LB": 599.01,
"LC": 666.67,
"LK": 509.78,
"LR": 227.85,
"LS": 20.0,
"LT": 160.07,
"LU": 104.35,
"LV": 123.4,
"LY": 861.69,
"MA": 705.67,
"MD": 871.66,
"ME": 417.07,
"MG": 497.61,
"MK": 590.43,
"ML": 463.13,
"MM": 575.77,
"MN": 852.82,
"MO": 627.12,
"MQ": 556.29,
"MR": 526.6,
"LT": 119.09,
"LU": 122.3,
"LV": 119.31,
"LY": 818.69,
"MA": 624.01,
"MD": 643.46,
"ME": 418.09,
"MG": 436.44,
"MK": 539.55,
"ML": 408.0,
"MM": 440.37,
"MN": 775.31,
"MO": 448.98,
"MQ": 523.18,
"MR": 464.71,
"MS": 1000.0,
"MT": 459.14,
"MU": 631.94,
"MV": 651.52,
"MW": 133.8,
"MX": 475.36,
"MY": 605.83,
"MZ": 150.25,
"NA": 70.06,
"NC": 610.12,
"NE": 622.22,
"NG": 483.29,
"NI": 276.6,
"NL": 267.89,
"NO": 30.08,
"NP": 23.43,
"MT": 493.62,
"MU": 632.48,
"MV": 611.77,
"MW": 66.67,
"MX": 492.34,
"MY": 607.88,
"MZ": 135.65,
"NA": 59.26,
"NC": 660.58,
"NE": 670.89,
"NG": 523.25,
"NI": 265.12,
"NL": 268.68,
"NO": 30.05,
"NP": 24.44,
"NR": 750.0,
"NZ": 113.27,
"OM": 556.0,
"PA": 175.0,
"PE": 301.25,
"PF": 471.43,
"PG": 526.75,
"PH": 641.96,
"PK": 435.89,
"PL": 661.93,
"PM": 800.0,
"PR": 719.85,
"PS": 511.63,
"PT": 165.55,
"PY": 25.39,
"QA": 602.39,
"RE": 608.41,
"RO": 240.45,
"RS": 634.0,
"RU": 436.28,
"RW": 294.12,
"SA": 706.79,
"SB": 727.27,
"SC": 615.39,
"SD": 288.13,
"SE": 40.7,
"SG": 515.28,
"SI": 231.28,
"SK": 116.77,
"SL": 47.62,
"SN": 685.05,
"SO": 634.15,
"SR": 356.44,
"SS": 684.21,
"ST": 600.0,
"SV": 211.29,
"SY": 758.35,
"SZ": 189.19,
"TC": 703.7,
"TD": 677.42,
"TG": 492.06,
"TH": 560.74,
"TJ": 99.34,
"TM": 1306.36,
"TN": 567.62,
"NZ": 112.76,
"OM": 564.55,
"PA": 161.68,
"PE": 266.48,
"PF": 442.86,
"PG": 507.25,
"PH": 610.74,
"PK": 440.61,
"PL": 655.47,
"PM": 600.0,
"PR": 677.96,
"PS": 516.13,
"PT": 158.16,
"PY": 24.31,
"QA": 602.5,
"RE": 572.82,
"RO": 243.32,
"RS": 648.2,
"RU": 445.02,
"RW": 316.33,
"SA": 696.31,
"SB": 700.0,
"SC": 564.52,
"SD": 263.16,
"SE": 38.44,
"SG": 470.87,
"SI": 225.08,
"SK": 115.14,
"SL": 50.0,
"SN": 511.6,
"SO": 578.95,
"SR": 349.28,
"SS": 629.03,
"ST": 642.86,
"SV": 224.76,
"SY": 701.66,
"SZ": 172.41,
"TC": 653.85,
"TD": 628.57,
"TG": 443.18,
"TH": 549.85,
"TJ": 116.86,
"TM": 1306.03,
"TN": 563.96,
"TO": 625.0,
"TR": 458.38,
"TT": 724.14,
"TW": 639.53,
"TZ": 313.68,
"UA": 194.4,
"UG": 52.27,
"US": 410.37,
"UY": 149.49,
"UZ": 1176.69,
"VC": 500.0,
"VE": 298.5,
"VG": 714.29,
"VI": 685.71,
"VN": 409.8,
"TR": 464.59,
"TT": 681.53,
"TW": 644.36,
"TZ": 339.25,
"UA": 256.21,
"UG": 44.53,
"US": 369.53,
"UY": 128.79,
"UZ": 1167.6,
"VC": 529.41,
"VE": 185.8,
"VG": 647.06,
"VI": 632.35,
"VN": 472.47,
"VU": 571.43,
"WS": 470.59,
"WS": 473.68,
"XK": 894.65,
"YE": 613.64,
"ZA": 741.63,
"ZM": 86.39,
"ZW": 433.38
"YE": 566.1,
"ZA": 709.69,
"ZM": 111.97,
"ZW": 297.87
}
# @see {co2.js/data/output/marginal-intensities-2021.json}