6 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
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.7"
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": 561.14,
"AF": 120.48,
"AG": 657.14,
"AL": 23.44,
"AM": 280.06,
"AO": 212.42,
"AR": 399.5,
"AS": 687.5,
"AT": 141.79,
"AU": 570.35,
"AW": 591.4,
"AZ": 719.39,
"BA": 670.09,
"BB": 644.86,
"BD": 719.78,
"BE": 139.79,
"BF": 611.43,
"BG": 476.9,
"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": 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": 961.54,
"BO": 497.78,
"BR": 114.48,
"BS": 698.11,
"BT": 24.44,
"BW": 867.58,
"BY": 465.34,
"BZ": 484.38,
"CA": 163.01,
"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": 36.14,
"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": 555.13,
"CZ": 488.3,
"DE": 420.06,
"DJ": 666.67,
"DK": 201.78,
"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": 592.49,
"DZ": 672.64,
"EC": 192.39,
"EE": 489.89,
"EG": 612.16,
"ER": 688.89,
"ES": 217.77,
"ET": 25.19,
"FI": 130.42,
"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": 78.81,
"GA": 397.38,
"GB": 255.85,
"GD": 714.29,
"GE": 176.97,
"GF": 254.72,
"GH": 498.81,
"GL": 133.33,
"GM": 700.0,
"GN": 208.63,
"GP": 647.06,
"GQ": 492.96,
"GR": 378.18,
"GT": 331.72,
"GU": 670.33,
"GW": 750.0,
"GY": 642.28,
"HK": 733.05,
"HN": 378.97,
"HR": 242.28,
"HT": 606.06,
"HU": 228.75,
"ID": 675.93,
"IE": 333.23,
"IL": 641.17,
"IN": 705.13,
"IQ": 708.1,
"IR": 665.15,
"IS": 28.56,
"IT": 378.45,
"JM": 588.51,
"JO": 572.74,
"JP": 512.81,
"KE": 101.13,
"KG": 124.48,
"KH": 436.13,
"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": 124.57,
"KR": 470.4,
"KW": 691.31,
"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": 177.18,
"LU": 144.07,
"LV": 136.27,
"LY": 861.69,
"MA": 705.67,
"MD": 871.66,
"ME": 483.38,
"MG": 497.61,
"MK": 639.86,
"ML": 463.13,
"MM": 575.77,
"MN": 852.82,
"MO": 627.12,
"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": 500.0,
"MU": 631.94,
"MV": 651.52,
"MW": 133.8,
"MX": 515.62,
"MY": 605.83,
"MZ": 150.25,
"NA": 70.06,
"NC": 610.12,
"NE": 622.22,
"NG": 513.24,
"NI": 352.05,
"NL": 324.99,
"NO": 26.5,
"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": 117.46,
"OM": 598.27,
"PA": 175.0,
"PE": 312.59,
"PF": 471.43,
"PG": 526.75,
"PH": 641.96,
"PK": 435.89,
"PL": 733.18,
"PM": 800.0,
"PR": 719.85,
"PS": 511.63,
"PT": 225.19,
"PY": 25.49,
"QA": 642.01,
"RE": 519.03,
"RO": 297.94,
"RS": 695.69,
"RU": 451.95,
"RW": 294.12,
"SA": 706.79,
"SB": 727.27,
"SC": 615.39,
"SD": 288.13,
"SE": 41.07,
"SG": 505.22,
"SI": 257.49,
"SK": 142.59,
"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": 599.02,
"TJ": 99.34,
"TM": 1389.72,
"TN": 592.21,
"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": 453.01,
"TT": 723.94,
"TW": 678.87,
"TZ": 374.08,
"UA": 271.41,
"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,
"XK": 945.01,
"YE": 613.64,
"ZA": 762.46,
"ZM": 86.39,
"ZW": 433.38
"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}