Skip to content

Commit 9c978c4

Browse files
authored
Merge pull request #914 from bnestor/master
Updated (2023) Canadian regional emissions data
2 parents d1600c7 + cb6abeb commit 9c978c4

4 files changed

Lines changed: 177 additions & 3 deletions

File tree

Lines changed: 171 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,171 @@
1+
{
2+
"british columbia": {
3+
"naturalGas": 2.8,
4+
"nuclear": 0.0,
5+
"petroleum": 0.1,
6+
"biomass": 6.7,
7+
"coal": 0.0,
8+
"other": 0.0,
9+
"solar": 0.6,
10+
"tidal": 0.0,
11+
"total": 99.9,
12+
"wind": 2.9,
13+
"hydro": 86.8
14+
},
15+
"newfoundland and labrador": {
16+
"naturalGas": 0.2,
17+
"nuclear": 0.0,
18+
"petroleum": 0.4,
19+
"biomass": 0.0,
20+
"coal": 0.0,
21+
"other": 0.0,
22+
"solar": 0.0,
23+
"tidal": 0.0,
24+
"total": 100.0,
25+
"wind": 0.4,
26+
"hydro": 99.0
27+
},
28+
"saskatchewan": {
29+
"naturalGas": 50.7,
30+
"nuclear": 0.0,
31+
"petroleum": 0.0,
32+
"biomass": 1.2,
33+
"coal": 27.9,
34+
"other": 0.0,
35+
"solar": 0.6,
36+
"tidal": 0.0,
37+
"total": 100.0,
38+
"wind": 3.0,
39+
"hydro": 16.6
40+
},
41+
"prince edward island": {
42+
"naturalGas": 0.0,
43+
"nuclear": 0.0,
44+
"petroleum": 2.2,
45+
"biomass": 0.6,
46+
"coal": 0.0,
47+
"other": 0.0,
48+
"solar": 0.1,
49+
"tidal": 0.0,
50+
"total": 100.2,
51+
"wind": 97.3,
52+
"hydro": 0.0
53+
},
54+
"ontario": {
55+
"naturalGas": 8.6,
56+
"nuclear": 50.1,
57+
"petroleum": 0.1,
58+
"biomass": 1.0,
59+
"coal": 0.0,
60+
"other": 0.0,
61+
"solar": 5.2,
62+
"tidal": 0.0,
63+
"total": 100.1,
64+
"wind": 11.7,
65+
"hydro": 23.4
66+
},
67+
"nova scotia": {
68+
"naturalGas": 13.9,
69+
"nuclear": 0.0,
70+
"petroleum": 0.0,
71+
"biomass": 3.5,
72+
"coal": 47.5,
73+
"other": 0.0,
74+
"solar": 0.02,
75+
"tidal": 0,
76+
"total": 100.02,
77+
"wind": 24.2,
78+
"hydro": 10.9
79+
},
80+
"quebec": {
81+
"naturalGas": 0.2,
82+
"nuclear": 0.0,
83+
"petroleum": 0.3,
84+
"biomass": 0.7,
85+
"coal": 0.0,
86+
"other": 0.0,
87+
"solar": 0.01,
88+
"tidal": 0.0,
89+
"total": 100.01,
90+
"wind": 6.7,
91+
"hydro": 92.1
92+
},
93+
"alberta": {
94+
"naturalGas": 73.5,
95+
"nuclear": 0.0,
96+
"petroleum": 0.02,
97+
"biomass": 2.0,
98+
"coal": 8.0,
99+
"other": 0.0,
100+
"solar": 3.2,
101+
"tidal": 0.0,
102+
"total": 99.82,
103+
"wind": 11.3,
104+
"hydro": 1.8
105+
},
106+
"manitoba": {
107+
"naturalGas": 0.6,
108+
"nuclear": 0.0,
109+
"petroleum": 0.1,
110+
"biomass": 0.2,
111+
"coal": 0.0,
112+
"other": 0.0,
113+
"solar": 0.1,
114+
"tidal": 0.0,
115+
"total": 100.1,
116+
"wind": 1.7,
117+
"hydro": 97.4
118+
},
119+
"northwest territories": {
120+
"naturalGas": 7.3,
121+
"nuclear": 0.0,
122+
"petroleum": 10.5,
123+
"biomass": 0.0,
124+
"coal": 0.0,
125+
"other": 0.0,
126+
"solar": 0.9,
127+
"tidal": 0.0,
128+
"total": 100.0,
129+
"wind": 7.1,
130+
"hydro": 74.2
131+
},
132+
"new brunswick": {
133+
"naturalGas": 16.6,
134+
"nuclear": 39.9,
135+
"petroleum": 0.3,
136+
"biomass": 1.3,
137+
"coal": 12.1,
138+
"other": 0.0,
139+
"solar": 0.0,
140+
"tidal": 0.0,
141+
"total": 99.9,
142+
"wind": 8.7,
143+
"hydro": 21.0
144+
},
145+
"nunavut": {
146+
"naturalGas": 0.0,
147+
"nuclear": 0.0,
148+
"petroleum": 99.8,
149+
"biomass": 0.0,
150+
"coal": 0.0,
151+
"other": 0.0,
152+
"solar": 0.2,
153+
"tidal": 0.0,
154+
"total": 100.0,
155+
"wind": 0.0,
156+
"hydro": 0.0
157+
},
158+
"yukon": {
159+
"naturalGas": 20.2,
160+
"nuclear": 0.0,
161+
"petroleum": 15.0,
162+
"biomass": 0.5,
163+
"coal": 0.0,
164+
"other": 0.0,
165+
"solar": 0.1,
166+
"tidal": 0.0,
167+
"total": 100.1,
168+
"wind": 0.2,
169+
"hydro": 64.1
170+
}
171+
}

codecarbon/input.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def __init__(self):
2424
"geo_js_url": "https://get.geojs.io/v1/ip/geo.json",
2525
"cloud_emissions_path": "data/cloud/impact.csv",
2626
"usa_emissions_data_path": "data/private_infra/2016/usa_emissions.json",
27-
"can_energy_mix_data_path": "data/private_infra/2016/canada_energy_mix.json", # noqa: E501
27+
"can_energy_mix_data_path": "data/private_infra/2023/canada_energy_mix.json", # noqa: E501
2828
"global_energy_mix_data_path": "data/private_infra/global_energy_mix.json", # noqa: E501
2929
"carbon_intensity_per_source_path": "data/private_infra/carbon_intensity_per_source.json",
3030
"cpu_power_path": "data/hardware/cpu_power.csv",

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ codecarbon = [
6161
"data/private_infra/global_energy_mix.json",
6262
"data/private_infra/carbon_intensity_per_source.json",
6363
"data/private_infra/2016/usa_emissions.json",
64-
"data/private_infra/2016/canada_energy_mix.json",
64+
"data/private_infra/2023/canada_energy_mix.json",
6565
]
6666

6767
[project.urls]

tests/test_emissions.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,10 +154,13 @@ def test_get_emissions_PRIVATE_INFRA_CANADA_WITH_REGION(self):
154154
country_iso_code="CAN", country_name="Canada", region="ontario"
155155
),
156156
)
157+
manually_computed_emissions = (
158+
3 * (0.995725971 * 0.0 + 0.8166885263 * 0.1 + 0.7438415916 * 8.6) / 100.1
159+
)
157160

158161
# THEN
159162
assert isinstance(emissions, float)
160-
self.assertAlmostEqual(emissions, 0.12, places=2)
163+
self.assertAlmostEqual(emissions, manually_computed_emissions, places=2)
161164

162165
def test_get_emissions_PRIVATE_INFRA_unknown_country(self):
163166
"""

0 commit comments

Comments
 (0)