8 Commits

Author SHA1 Message Date
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
fauno ebbae56efa v0.5.8 2024-03-21 12:03:16 -03:00
fauno 8e7053d756 fix: update average intensity data to match co2.js v0.14.4 2024-03-21 12:00:09 -03:00
fauno ec2f1eb4b5 v0.5.7 2024-02-21 10:30:48 -03:00
fauno d751f6da0e fix: update average intensity data to match co2.js v0.14.3 2024-02-21 10:30:14 -03:00
5 changed files with 223 additions and 202 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.6"
version: "0.5.9"
authors:
- "f <f@sutty.nl>"
targets:
+1 -1
View File
@@ -11,7 +11,7 @@ require "./models/access_log"
require "./models/crawler"
require "./swd"
VERSION = "0.5.6"
VERSION = "0.5.8"
Log.setup_from_env
+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
+199 -199
View File
@@ -2,215 +2,215 @@ class SWD
module IntensityData
# @see {co2.js/data/output/average-intensities.json}
AVERAGE_INTENSITY_BY_ISO_CODE = {
"AE": 407.98,
"AF": 120.48,
"AG": 657.14,
"AL": 23.44,
"AM": 222.68,
"AO": 195.98,
"AR": 344.31,
"AS": 687.5,
"AT": 158.22,
"AU": 501.7,
"AW": 591.4,
"AZ": 469.58,
"BA": 553.47,
"BB": 644.86,
"BD": 574.28,
"BE": 167.11,
"BF": 611.43,
"BG": 399.72,
"BH": 494.02,
"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": 110.78,
"AU": 556.3,
"AW": 561.22,
"AZ": 671.39,
"BA": 600.94,
"BB": 605.51,
"BD": 691.41,
"BE": 138.11,
"BF": 467.53,
"BG": 335.33,
"BH": 904.62,
"BI": 250.0,
"BJ": 666.67,
"BN": 493.59,
"BO": 335.4,
"BR": 102.04,
"BS": 698.11,
"BT": 24.44,
"BW": 794.52,
"BY": 425.9,
"BZ": 484.38,
"CA": 125.84,
"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": 395.52,
"CH": 41.28,
"CI": 410.75,
"CK": 400.0,
"CL": 332.61,
"CM": 278.26,
"CN": 533.98,
"CO": 163.99,
"CR": 37.21,
"CU": 654.68,
"CV": 600.0,
"CY": 589.35,
"CZ": 414.8,
"DE": 385.39,
"DJ": 666.67,
"DK": 180.42,
"CG": 700.0,
"CH": 34.7,
"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": 526.02,
"CZ": 449.72,
"DE": 381.41,
"DJ": 692.31,
"DK": 151.65,
"DM": 529.41,
"DO": 549.8,
"DZ": 485.49,
"EC": 183.63,
"EE": 460.26,
"EG": 469.63,
"ER": 688.89,
"ES": 217.42,
"ET": 25.19,
"FI": 131.71,
"FJ": 289.47,
"DO": 580.78,
"DZ": 634.61,
"EC": 166.91,
"EE": 416.67,
"EG": 574.04,
"ER": 631.58,
"ES": 174.05,
"ET": 24.64,
"FI": 79.12,
"FJ": 288.46,
"FK": 500.0,
"FO": 428.57,
"FR": 84.88,
"GA": 397.38,
"GB": 261.16,
"GD": 714.29,
"GE": 134.83,
"GF": 254.72,
"GH": 361.2,
"GL": 133.33,
"GM": 700.0,
"GN": 208.63,
"GP": 623.53,
"GQ": 492.96,
"GR": 344.41,
"GT": 304.71,
"GU": 670.33,
"GW": 750.0,
"GY": 642.28,
"HK": 609.93,
"HN": 373.96,
"HR": 246.29,
"HT": 606.06,
"HU": 222.1,
"ID": 619.03,
"IE": 346.43,
"IL": 537.57,
"IN": 633.4,
"IQ": 531.36,
"IR": 487.86,
"IS": 28.56,
"IT": 372.63,
"JM": 537.93,
"JO": 391.13,
"JP": 494.86,
"KE": 101.13,
"KG": 104.43,
"KH": 400.46,
"FO": 404.76,
"FR": 56.02,
"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": 336.57,
"GT": 328.27,
"GU": 622.86,
"GW": 625.0,
"GY": 640.35,
"HK": 699.5,
"HN": 282.27,
"HR": 204.96,
"HT": 567.31,
"HU": 204.01,
"ID": 682.43,
"IE": 282.98,
"IL": 582.93,
"IN": 713.01,
"IQ": 688.81,
"IR": 641.73,
"IS": 27.68,
"IT": 330.72,
"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": 102.42,
"KR": 437.6,
"KW": 574.56,
"KY": 684.93,
"KZ": 635.57,
"LA": 242.18,
"LB": 663.1,
"LC": 685.71,
"LK": 501.53,
"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": 195.7,
"LU": 162.6,
"LV": 183.43,
"LY": 558.85,
"MA": 630.75,
"MD": 666.67,
"ME": 392.75,
"MG": 483.25,
"MK": 543.71,
"ML": 463.13,
"MM": 330.8,
"MN": 749.66,
"MO": 491.53,
"MQ": 698.63,
"MR": 526.6,
"LT": 160.07,
"LU": 105.26,
"LV": 123.99,
"LY": 818.69,
"MA": 624.45,
"MD": 643.46,
"ME": 418.09,
"MG": 436.44,
"MK": 539.55,
"ML": 408.0,
"MM": 436.92,
"MN": 775.31,
"MO": 448.98,
"MQ": 523.18,
"MR": 464.71,
"MS": 1000.0,
"MT": 433.48,
"MU": 611.11,
"MV": 651.52,
"MW": 133.8,
"MX": 423.81,
"MY": 543.87,
"MZ": 126.63,
"NA": 63.69,
"NC": 610.12,
"NE": 622.22,
"NG": 368.11,
"NI": 354.21,
"NL": 354.31,
"NO": 28.93,
"NP": 24.51,
"MT": 444.03,
"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.48,
"NO": 30.05,
"NP": 24.44,
"NR": 750.0,
"NZ": 105.22,
"OM": 488.27,
"PA": 152.68,
"PE": 256.51,
"PF": 471.43,
"PG": 526.75,
"PH": 594.45,
"PK": 344.16,
"PL": 633.23,
"PM": 800.0,
"PR": 612.39,
"PS": 465.12,
"PT": 234.61,
"PY": 25.49,
"QA": 490.28,
"RE": 519.03,
"RO": 264.24,
"RS": 582.13,
"RU": 363.68,
"RW": 294.12,
"SA": 557.78,
"SB": 727.27,
"SC": 615.39,
"SD": 288.13,
"SE": 45.12,
"SG": 488.78,
"SI": 237.38,
"SK": 140.14,
"SL": 47.62,
"SN": 523.13,
"SO": 634.15,
"SR": 356.44,
"SS": 684.21,
"ST": 600.0,
"SV": 194.23,
"SY": 541.17,
"SZ": 189.19,
"TC": 703.7,
"TD": 677.42,
"TG": 460.32,
"TH": 501.57,
"TJ": 83.63,
"TM": 490.19,
"TN": 469.43,
"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": 661.93,
"PM": 600.0,
"PR": 677.96,
"PS": 516.13,
"PT": 165.55,
"PY": 24.31,
"QA": 602.5,
"RE": 572.82,
"RO": 240.58,
"RS": 648.2,
"RU": 445.02,
"RW": 316.33,
"SA": 696.31,
"SB": 700.0,
"SC": 564.52,
"SD": 263.16,
"SE": 40.7,
"SG": 470.78,
"SI": 231.28,
"SK": 116.77,
"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": 413.6,
"TT": 491.41,
"TW": 560.98,
"TZ": 366.75,
"UA": 232.74,
"UG": 52.27,
"US": 368.1,
"UY": 150.13,
"UZ": 505.41,
"VC": 500.0,
"VE": 212.48,
"VG": 714.29,
"VI": 685.71,
"VN": 386.49,
"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,
"XK": 767.0,
"YE": 559.66,
"ZA": 708.21,
"ZM": 84.7,
"ZW": 392.28
"WS": 473.68,
"XK": 894.65,
"YE": 566.1,
"ZA": 709.69,
"ZM": 111.97,
"ZW": 297.87
}
# @see {co2.js/data/output/marginal-intensities-2021.json}