samuelrince commited on
Commit
b443202
·
1 Parent(s): 4a489ea

refactor: update countries and format functions using electricity mix repository

Browse files
data/electricity_mix.csv DELETED
@@ -1,4 +0,0 @@
1
- name,unit,source,WOR,EEE,ZWE,ZMB,ZAF,YEM,VNM,VEN,UZB,URY,USA,UKR,TZA,TWN,TTO,TUR,TUN,TKM,TJK,THA,TGO,SYR,SLV,SEN,SVK,SVN,SGP,SWE,SDN,SAU,RUS,SCG,ROU,QAT,PRY,PRT,POL,PAK,PHL,PER,PAN,OMN,NZL,NPL,NOR,NLD,NIC,NGA,NAM,MOZ,MYS,MEX,MLT,MNG,MMR,MKD,MDA,MAR,LBY,LVA,LUX,LTU,LKA,LBN,KAZ,KWT,KOR,PRK,KHM,KGZ,KEN,JPN,JOR,JAM,ITA,ISL,IRN,IRQ,IND,ISR,IRL,IDN,HUN,HTI,HRV,HND,HKG,GTM,GRC,GIB,GHA,GEO,GBR,GAB,FRA,FIN,ETH,ESP,ERI,EGY,EST,ECU,DZA,DOM,DNK,DEU,CZE,CYP,CUB,CRI,COL,CHN,CMR,CHL,CIV,CHE,COG,COD,CAN,BLR,BWA,BRA,BOL,BRN,BEN,BHR,BGR,BEL,BGD,BIH,AZE,AUS,AUT,ARG,AGO,ANT,ARM,ALB,ARE
2
- adpe,kg éq. Sb,ADEME Base IMPACTS ®,0.0000000737708,0.0000000642317,0.000000109502,0.000000162193,0.0000000862445,0.0000000163908,0.0000000945573,0.000000112811,0.000000103681,0.000000104586,0.0000000985548,0.0000000647907,0.000000132261,0.0000000578088,0.000000064552,0.0000000749765,0.0000000177021,0.000000131822,0.000000152621,0.0000000569593,0.000000134255,0.0000000268396,0.0000000472135,0.0000000470662,0.0000000606109,0.0000000992283,0.0000000198459,0.0000000777062,0.0000000955701,0.0000000134206,0.0000000960312,0.000000132772,0.0000000981761,0.00000001324,0.000000149181,0.0000000341863,0.000000101946,0.0000000842952,0.0000000595304,0.0000000952688,0.0000000790553,0.0000000374073,0.0000000720474,0.000000238273,0.000000127486,0.0000000329318,0.0000000414983,0.0000000621,0.000000128285,0.000000148382,0.000000044938,0.0000000578358,0.000000049475,0.000000176361,0.000000152699,0.000000119873,0.000000110674,0.0000000641089,0.0000000206592,0.000000153757,0.000000105692,0.0000000294596,0.0000000986932,0.0000000182134,0.000000135386,0.0000000141168,0.0000000518017,0.000000117457,0.0000000319202,0.000000181827,0.0000000958533,0.0000000596578,0.0000000147031,0.0000000196047,0.00000005439,0.0000000781905,0.0000000220304,0.0000000404306,0.000000100099,0.0000000610194,0.0000000219257,0.0000000610451,0.0000000644587,0.0000000937057,0.000000153989,0.0000000649373,0.0000000816213,0.0000000803251,0.0000000691645,0.0000000286211,0.000000156003,0.000000137999,0.0000000370973,0.000000113843,0.0000000485798,0.0000000805114,0.000000174161,0.0000000518326,0.0000000512406,0.000000033925,0.0000000990171,0.000000127168,0.0000000216438,0.0000000429285,0.0000000157411,0.0000000878733,0.0000000817565,0.0000000448771,0.0000000299542,0.0000000863908,0.000000122031,0.0000000851552,0.000000146313,0.000000105851,0.0000000949004,0.000000100467,0.000000265575,0.000000174647,0.0000000993179,0.0000000840478,0.0000000866014,0.00000010962,0.0000000969793,0.0000000185641,0.0000000239702,0.0000000135014,0.0000000823611,0.0000000337201,0.0000000394158,0.000000148007,0.000000092567,0.0000000790846,0.000000141124,0.0000000768612,0.000000124074,0.0000000449103,0.0000000854245,0.000000229556,0.0000000141548
3
- pe,MJ,ADPf / (1-%renewable_energy),9.988,12.873,16.122,1.798,11.732,16.250,11.238,15.163,17.367,107.570,11.358,12.936,9.305,11.439,14.289,16.150,12.902,23.300,19.165,10.414,21.978,16.989,13.012,14.516,11.680,12.146,10.477,11.026,29.629,14.058,13.200,14.242,15.585,11.916,0.020,14.153,13.178,16.175,11.120,8.211,16.364,22.306,24.731,0.396,4.952,8.511,24.696,11.279,468.150,0.206,12.268,11.775,19.374,15.114,14.132,19.120,18.429,11.702,19.116,8.249,10.128,21.043,12.116,12.341,13.260,12.753,10.199,32.793,34.655,15.380,68.996,10.718,13.677,14.799,12.656,0.013,15.022,20.372,20.363,10.023,10.706,11.603,11.784,20.167,18.548,15.762,,14.340,14.487,,10.097,10.425,13.579,28.341,11.289,11.275,36.133,12.090,13.289,10.195,16.334,20.908,16.376,12.412,16.824,16.260,12.517,13.118,17.317,45.996,7.312,14.119,10.807,11.348,14.783,11.782,34.147,0.097,11.987,13.194,19.642,9.031,11.587,15.689,14.337,14.036,14.375,10.776,12.935,21.705,12.831,16.908,11.036,10.049,16.972,,13.380,0.201,19.032
4
- gwp,kg éq. CO2,ADEME Base IMPACTS ®,0.590478,0.509427,0.842811,0.0141304,1.17562,1.06777,0.555572,0.497373,0.81178,0.296953,0.67978,0.646745,0.475635,0.845351,0.933059,0.706988,0.80722,1.38296,0.0426743,0.646174,0.545455,1.08778,0.473128,1.1195,0.309341,0.498523,0.655825,0.0464664,1.12472,0.913677,0.66131,1.07808,0.664245,0.722125,0.241601,0.571172,1.15075,0.748727,0.761317,0.284364,0.53403,1.41292,0.293397,0.0841323,0.023754,0.544803,0.941626,0.693123,0.357253,0.00880732,0.832206,0.739214,1.31149,1.47192,0.48193,1.24074,1.04213,0.933694,1.35361,0.234273,0.490016,0.154229,0.709185,0.883627,1.128,0.885084,0.599585,0.797361,1.41054,0.156039,0.589603,0.540891,0.781372,1.07345,0.621329,0.0194609,0.930385,1.48728,1.58299,0.901842,0.648118,0.875394,0.541558,1.3858,0.535759,0.692837,0.95888,0.645801,1.13127,0.977477,0.540126,0.132046,0.602137,0.732511,0.0813225,0.322068,0.251299,0.467803,1.13153,0.587775,1.51492,0.627714,1.02318,0.909252,0.633534,0.657374,0.799077,0.978041,1.28325,0.224471,0.214014,1.05738,0.456622,0.574415,0.928583,0.0448568,0.904053,0.0613102,0.238191,0.795697,2.12572,0.278647,0.585131,0.997577,1.19128,0.804567,0.827087,0.256537,0.795168,1.56025,0.726126,1.12326,0.245573,0.476811,0.412014,1.13161,0.252002,0.0207635,1.09088
 
 
 
 
 
src/data/electricity_mix.csv DELETED
@@ -1,4 +0,0 @@
1
- name,unit,source,WOR,EEE,ZWE,ZMB,ZAF,YEM,VNM,VEN,UZB,URY,USA,UKR,TZA,TWN,TTO,TUR,TUN,TKM,TJK,THA,TGO,SYR,SLV,SEN,SVK,SVN,SGP,SWE,SDN,SAU,RUS,SCG,ROU,QAT,PRY,PRT,POL,PAK,PHL,PER,PAN,OMN,NZL,NPL,NOR,NLD,NIC,NGA,NAM,MOZ,MYS,MEX,MLT,MNG,MMR,MKD,MDA,MAR,LBY,LVA,LUX,LTU,LKA,LBN,KAZ,KWT,KOR,PRK,KHM,KGZ,KEN,JPN,JOR,JAM,ITA,ISL,IRN,IRQ,IND,ISR,IRL,IDN,HUN,HTI,HRV,HND,HKG,GTM,GRC,GIB,GHA,GEO,GBR,GAB,FRA,FIN,ETH,ESP,ERI,EGY,EST,ECU,DZA,DOM,DNK,DEU,CZE,CYP,CUB,CRI,COL,CHN,CMR,CHL,CIV,CHE,COG,COD,CAN,BLR,BWA,BRA,BOL,BRN,BEN,BHR,BGR,BEL,BGD,BIH,AZE,AUS,AUT,ARG,AGO,ANT,ARM,ALB,ARE
2
- adpe,kg éq. Sb,ADEME Base IMPACTS ®,0.0000000737708,0.0000000642317,0.000000109502,0.000000162193,0.0000000862445,0.0000000163908,0.0000000945573,0.000000112811,0.000000103681,0.000000104586,0.0000000985548,0.0000000647907,0.000000132261,0.0000000578088,0.000000064552,0.0000000749765,0.0000000177021,0.000000131822,0.000000152621,0.0000000569593,0.000000134255,0.0000000268396,0.0000000472135,0.0000000470662,0.0000000606109,0.0000000992283,0.0000000198459,0.0000000777062,0.0000000955701,0.0000000134206,0.0000000960312,0.000000132772,0.0000000981761,0.00000001324,0.000000149181,0.0000000341863,0.000000101946,0.0000000842952,0.0000000595304,0.0000000952688,0.0000000790553,0.0000000374073,0.0000000720474,0.000000238273,0.000000127486,0.0000000329318,0.0000000414983,0.0000000621,0.000000128285,0.000000148382,0.000000044938,0.0000000578358,0.000000049475,0.000000176361,0.000000152699,0.000000119873,0.000000110674,0.0000000641089,0.0000000206592,0.000000153757,0.000000105692,0.0000000294596,0.0000000986932,0.0000000182134,0.000000135386,0.0000000141168,0.0000000518017,0.000000117457,0.0000000319202,0.000000181827,0.0000000958533,0.0000000596578,0.0000000147031,0.0000000196047,0.00000005439,0.0000000781905,0.0000000220304,0.0000000404306,0.000000100099,0.0000000610194,0.0000000219257,0.0000000610451,0.0000000644587,0.0000000937057,0.000000153989,0.0000000649373,0.0000000816213,0.0000000803251,0.0000000691645,0.0000000286211,0.000000156003,0.000000137999,0.0000000370973,0.000000113843,0.0000000485798,0.0000000805114,0.000000174161,0.0000000518326,0.0000000512406,0.000000033925,0.0000000990171,0.000000127168,0.0000000216438,0.0000000429285,0.0000000157411,0.0000000878733,0.0000000817565,0.0000000448771,0.0000000299542,0.0000000863908,0.000000122031,0.0000000851552,0.000000146313,0.000000105851,0.0000000949004,0.000000100467,0.000000265575,0.000000174647,0.0000000993179,0.0000000840478,0.0000000866014,0.00000010962,0.0000000969793,0.0000000185641,0.0000000239702,0.0000000135014,0.0000000823611,0.0000000337201,0.0000000394158,0.000000148007,0.000000092567,0.0000000790846,0.000000141124,0.0000000768612,0.000000124074,0.0000000449103,0.0000000854245,0.000000229556,0.0000000141548
3
- pe,MJ,ADPf / (1-%renewable_energy),9.988,12.873,16.122,1.798,11.732,16.250,11.238,15.163,17.367,107.570,11.358,12.936,9.305,11.439,14.289,16.150,12.902,23.300,19.165,10.414,21.978,16.989,13.012,14.516,11.680,12.146,10.477,11.026,29.629,14.058,13.200,14.242,15.585,11.916,0.020,14.153,13.178,16.175,11.120,8.211,16.364,22.306,24.731,0.396,4.952,8.511,24.696,11.279,468.150,0.206,12.268,11.775,19.374,15.114,14.132,19.120,18.429,11.702,19.116,8.249,10.128,21.043,12.116,12.341,13.260,12.753,10.199,32.793,34.655,15.380,68.996,10.718,13.677,14.799,12.656,0.013,15.022,20.372,20.363,10.023,10.706,11.603,11.784,20.167,18.548,15.762,,14.340,14.487,,10.097,10.425,13.579,28.341,11.289,11.275,36.133,12.090,13.289,10.195,16.334,20.908,16.376,12.412,16.824,16.260,12.517,13.118,17.317,45.996,7.312,14.119,10.807,11.348,14.783,11.782,34.147,0.097,11.987,13.194,19.642,9.031,11.587,15.689,14.337,14.036,14.375,10.776,12.935,21.705,12.831,16.908,11.036,10.049,16.972,,13.380,0.201,19.032
4
- gwp,kg éq. CO2,ADEME Base IMPACTS ®,0.590478,0.509427,0.842811,0.0141304,1.17562,1.06777,0.555572,0.497373,0.81178,0.296953,0.67978,0.646745,0.475635,0.845351,0.933059,0.706988,0.80722,1.38296,0.0426743,0.646174,0.545455,1.08778,0.473128,1.1195,0.309341,0.498523,0.655825,0.0464664,1.12472,0.913677,0.66131,1.07808,0.664245,0.722125,0.241601,0.571172,1.15075,0.748727,0.761317,0.284364,0.53403,1.41292,0.293397,0.0841323,0.023754,0.544803,0.941626,0.693123,0.357253,0.00880732,0.832206,0.739214,1.31149,1.47192,0.48193,1.24074,1.04213,0.933694,1.35361,0.234273,0.490016,0.154229,0.709185,0.883627,1.128,0.885084,0.599585,0.797361,1.41054,0.156039,0.589603,0.540891,0.781372,1.07345,0.621329,0.0194609,0.930385,1.48728,1.58299,0.901842,0.648118,0.875394,0.541558,1.3858,0.535759,0.692837,0.95888,0.645801,1.13127,0.977477,0.540126,0.132046,0.602137,0.732511,0.0813225,0.322068,0.251299,0.467803,1.13153,0.587775,1.51492,0.627714,1.02318,0.909252,0.633534,0.657374,0.799077,0.978041,1.28325,0.224471,0.214014,1.05738,0.456622,0.574415,0.928583,0.0448568,0.904053,0.0613102,0.238191,0.795697,2.12572,0.278647,0.585131,0.997577,1.19128,0.804567,0.827087,0.256537,0.795168,1.56025,0.726126,1.12326,0.245573,0.476811,0.412014,1.13161,0.252002,0.0207635,1.09088
 
 
 
 
 
src/electricity_mix.py CHANGED
@@ -1,153 +1,85 @@
 
 
1
  import pandas as pd
2
 
3
 
4
  PATH = "src/data/electricity_mix.csv"
5
-
6
  COUNTRY_CODES = [
7
- ("🌎 World", "WOR"),
8
- ("🇪🇺 Europe", "EEE"),
9
- ("🇿🇼 Zimbabwe", "ZWE"),
10
- ("🇿🇲 Zambia", "ZMB"),
11
- ("🇿🇦 South Africa", "ZAF"),
12
- ("🇾🇪 Yemen", "YEM"),
13
- ("🇻🇳 Vietnam", "VNM"),
14
- ("🇻🇪 Venezuela", "VEN"),
15
- ("🇺🇿 Uzbekistan", "UZB"),
16
- ("🇺🇾 Uruguay", "URY"),
17
- ("🇺🇸 United States", "USA"),
18
- ("🇺🇦 Ukraine", "UKR"),
19
- ("🇹🇿 Tanzania", "TZA"),
20
- ("🇹🇼 Taiwan", "TWN"),
21
- ("🇹🇹 Trinidad and Tobago", "TTO"),
22
- ("🇹🇷 Turkey", "TUR"),
23
- ("🇹🇳 Tunisia", "TUN"),
24
- ("🇹🇲 Turkmenistan", "TKM"),
25
- ("🇹🇯 Tajikistan", "TJK"),
26
- ("🇹🇭 Thailand", "THA"),
27
- ("🇹🇬 Togo", "TGO"),
28
- ("🇸🇾 Syrian Arab Republic", "SYR"),
29
- ("🇸🇻 El Salvador", "SLV"),
30
- ("🇸🇳 Senegal", "SEN"),
31
- ("🇸🇰 Slovak Republic", "SVK"),
32
- ("🇸🇮 Slovenia", "SVN"),
33
- ("🇸🇬 Singapore", "SGP"),
34
- ("🇸🇪 Sweden", "SWE"),
35
- ("🇸🇩 Sudan", "SDN"),
36
- ("🇸🇦 Saudi Arabia", "SAU"),
37
- ("🇷🇺 Russian Federation", "RUS"),
38
- ("🇷🇸 Serbia and Montenegro", "SCG"),
39
- ("🇷🇴 Romania", "ROU"),
40
- ("🇶🇦 Qatar", "QAT"),
41
- ("🇵🇾 Paraguay", "PRY"),
42
- ("🇵🇹 Portugal", "PRT"),
43
- ("🇵🇱 Poland", "POL"),
44
- ("🇵🇰 Pakistan", "PAK"),
45
- ("🇵🇭 Philippines", "PHL"),
46
- ("🇵🇪 Peru", "PER"),
47
- ("🇵🇦 Panama", "PAN"),
48
- ("🇴🇲 Oman", "OMN"),
49
- ("🇳🇿 New Zealand", "NZL"),
50
- ("🇳🇵 Nepal", "NPL"),
51
- ("🇳🇴 Norway", "NOR"),
52
- ("🇳🇱 Netherlands", "NLD"),
53
- ("🇳🇮 Nicaragua", "NIC"),
54
- ("🇳🇬 Nigeria", "NGA"),
55
- ("🇳🇦 Namibia", "NAM"),
56
- ("🇲🇿 Mozambique", "MOZ"),
57
- ("🇲🇾 Malaysia", "MYS"),
58
- ("🇲🇽 Mexico", "MEX"),
59
- ("🇲🇹 Malta", "MLT"),
60
- ("🇲🇳 Mongolia", "MNG"),
61
- ("🇲🇲 Myanmar", "MMR"),
62
- ("🇲🇰 North Macedonia", "MKD"),
63
- ("🇲🇩 Moldova", "MDA"),
64
- ("🇲🇦 Morocco", "MAR"),
65
- ("🇱🇾 Libya", "LBY"),
66
- ("🇱🇻 Latvia", "LVA"),
67
- ("🇱🇺 Luxembourg", "LUX"),
68
- ("🇱🇹 Lithuania", "LTU"),
69
- ("🇱🇰 Sri Lanka", "LKA"),
70
- ("🇱🇧 Lebanon", "LBN"),
71
- ("🇰🇿 Kazakhstan", "KAZ"),
72
- ("🇰🇼 Kuwait", "KWT"),
73
- ("🇰🇷 South Korea", "KOR"),
74
- ("🇰🇵 North Korea", "PRK"),
75
- ("🇰🇭 Cambodia", "KHM"),
76
- ("🇰🇬 Kyrgyz Republic", "KGZ"),
77
- ("🇰🇪 Kenya", "KEN"),
78
- ("🇯🇵 Japan", "JPN"),
79
- ("🇯🇴 Jordan", "JOR"),
80
- ("🇯🇲 Jamaica", "JAM"),
81
- ("🇮🇹 Italy", "ITA"),
82
- ("🇮🇸 Iceland", "ISL"),
83
- ("🇮🇷 Iran", "IRN"),
84
- ("🇮🇶 Iraq", "IRQ"),
85
- ("🇮🇳 India", "IND"),
86
- ("🇮🇱 Israel", "ISR"),
87
- ("🇮🇪 Ireland", "IRL"),
88
- ("🇮🇩 Indonesia", "IDN"),
89
- ("🇭🇺 Hungary", "HUN"),
90
- ("🇭🇹 Haiti", "HTI"),
91
- ("🇭🇷 Croatia", "HRV"),
92
- ("🇭🇳 Honduras", "HND"),
93
- ("🇭🇰 Hong Kong", "HKG"),
94
- ("🇬🇹 Guatemala", "GTM"),
95
- ("🇬🇷 Greece", "GRC"),
96
- ("🇬🇮 Gibraltar", "GIB"),
97
- ("🇬🇭 Ghana", "GHA"),
98
- ("🇬🇪 Georgia", "GEO"),
99
- ("🇬🇧 United Kingdom", "GBR"),
100
- ("🇬🇦 Gabon", "GAB"),
101
- ("🇫🇷 France", "FRA"),
102
- ("🇫🇮 Finland", "FIN"),
103
- ("🇪🇹 Ethiopia", "ETH"),
104
- ("🇪🇸 Spain", "ESP"),
105
- ("🇪🇷 Eritrea", "ERI"),
106
- ("🇪🇬 Egypt", "EGY"),
107
- ("🇪🇪 Estonia", "EST"),
108
- ("🇪🇨 Ecuador", "ECU"),
109
- ("🇩🇿 Algeria", "DZA"),
110
- ("🇩🇴 Dominican Republic", "DOM"),
111
- ("🇩🇰 Denmark", "DNK"),
112
- ("🇩🇪 Germany", "DEU"),
113
- ("🇨🇿 Czech Republic", "CZE"),
114
- ("🇨🇾 Cyprus", "CYP"),
115
- ("🇨🇺 Cuba", "CUB"),
116
- ("🇨🇷 Costa Rica", "CRI"),
117
- ("🇨🇴 Colombia", "COL"),
118
- ("🇨🇳 China", "CHN"),
119
- ("🇨🇲 Cameroon", "CMR"),
120
- ("🇨🇱 Chile", "CHL"),
121
- ("🇨🇮 Cote d'Ivoire", "CIV"),
122
- ("🇨🇭 Switzerland", "CHE"),
123
- ("🇨🇬 Congo", "COG"),
124
- ("🇨🇩 Democratic Republic of the Congo", "COD"),
125
- ("🇨🇦 Canada", "CAN"),
126
- ("🇧🇾 Belarus", "BLR"),
127
- ("🇧🇼 Botswana", "BWA"),
128
- ("🇧🇷 Brazil", "BRA"),
129
- ("🇧🇴 Bolivia", "BOL"),
130
- ("🇧🇳 Brunei", "BRN"),
131
- ("🇧🇯 Benin", "BEN"),
132
- ("🇧🇭 Bahrain", "BHR"),
133
- ("🇧🇬 Bulgaria", "BGR"),
134
- ("🇧🇪 Belgium", "BEL"),
135
- ("🇧🇩 Bangladesh", "BGD"),
136
- ("🇧🇦 Bosnia and Herzegovina", "BIH"),
137
- ("🇦🇿 Azerbaijan", "AZE"),
138
  ("🇦🇺 Australia", "AUS"),
139
  ("🇦🇹 Austria", "AUT"),
140
  ("🇦🇷 Argentina", "ARG"),
141
- ("🇦🇴 Angola", "AGO"),
142
- ("🇦 Netherlands Antilles", "ANT"),
143
- ("🇦🇲 Armenia", "ARM"),
144
- ("🇦🇱 Albania", "ALB"),
145
- ("🇦🇪 United Arab Emirates", "ARE"),
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
146
  ]
147
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
148
 
149
  def dataframe_electricity_mix(countries: list):
150
  df = pd.read_csv("src/data/electricity_mix.csv")
 
 
151
  df["name_unit"] = df["name"] + " (" + df["unit"] + ")"
152
  df = df[["name_unit"] + [x[1] for x in COUNTRY_CODES if x[0] in countries]]
153
 
 
1
+ from __future__ import annotations
2
+
3
  import pandas as pd
4
 
5
 
6
  PATH = "src/data/electricity_mix.csv"
 
7
  COUNTRY_CODES = [
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8
  ("🇦🇺 Australia", "AUS"),
9
  ("🇦🇹 Austria", "AUT"),
10
  ("🇦🇷 Argentina", "ARG"),
11
+ ("🇧🇪 Belgium", "BEL"),
12
+ ("🇧🇬 Bulgaria", "BGR"),
13
+ ("🇧🇷 Brazil", "BRA"),
14
+ ("🇨🇦 Canada", "CAN"),
15
+ ("🇨🇭 Switzerland", "CHE"),
16
+ ("🇨🇱 Chile", "CHL"),
17
+ ("🇨🇳 China", "CHN"),
18
+ ("🇨🇾 Cyprus", "CYP"),
19
+ ("🇨🇿 Czech Republic", "CZE"),
20
+ ("🇩🇪 Germany", "DEU"),
21
+ ("🇩🇰 Denmark", "DNK"),
22
+ ("🇪🇸 Spain", "ESP"),
23
+ ("🇪🇪 Estonia", "EST"),
24
+ ("🇫🇮 Finland", "FIN"),
25
+ ("🇫🇷 France", "FRA"),
26
+ ("🇬🇧 United Kingdom", "GBR"),
27
+ ("🇬🇷 Greece", "GRC"),
28
+ ("🇭🇺 Hungary", "HUN"),
29
+ ("🇮🇩 Indonesia", "IDN"),
30
+ ("🇮🇳 India", "IND"),
31
+ ("🇮🇪 Ireland", "IRL"),
32
+ ("🇮🇸 Iceland", "ISL"),
33
+ ("🇮🇹 Italy", "ITA"),
34
+ ("🇯🇵 Japan", "JPN"),
35
+ ("🇰🇷 South Korea", "KOR"),
36
+ ("🇱🇹 Lithuania", "LTU"),
37
+ ("🇱🇺 Luxembourg", "LUX"),
38
+ ("🇱🇻 Latvia", "LVA"),
39
+ ("🇲🇽 Mexico", "MEX"),
40
+ ("🇲🇹 Malta", "MLT"),
41
+ ("🇲🇾 Malaysia", "MYS"),
42
+ ("🇳🇱 Netherlands", "NLD"),
43
+ ("🇳🇴 Norway", "NOR"),
44
+ ("🇳🇿 New Zealand", "NZL"),
45
+ ("🇵🇱 Poland", "POL"),
46
+ ("🇵🇹 Portugal", "PRT"),
47
+ ("🇷🇴 Romania", "ROU"),
48
+ ("🇷🇺 Russian Federation", "RUS"),
49
+ ("🇸🇰 Slovak Republic", "SVK"),
50
+ ("🇸🇮 Slovenia", "SVN"),
51
+ ("🇸🇪 Sweden", "SWE"),
52
+ ("🇺🇦 Ukraine", "UKR"),
53
+ ("🇹🇭 Thailand", "THA"),
54
+ ("🇹🇷 Turkey", "TUR"),
55
+ ("🇹🇼 Taiwan", "TWN"),
56
+ ("🇺🇸 United States", "USA"),
57
+ ("🌎 World", "WOR"),
58
  ]
59
 
60
+ CRITERIA = {
61
+ "gwp": "GHG Emission (kg CO2 eq)",
62
+ "adpe": "Abiotic Resources (kg Sb eq)",
63
+ "pe": "Primary Energy (MJ)",
64
+ "wue": "Water Usage Effectiveness (L/kWh)"
65
+ }
66
+
67
+
68
+ def format_country_name(code: str) -> str | None:
69
+ for country_name, country_code in COUNTRY_CODES:
70
+ if country_code == code:
71
+ return country_name
72
+ return None
73
+
74
+
75
+ def format_electricity_mix_criterion(criterion: str) -> str | None:
76
+ return CRITERIA.get(criterion)
77
+
78
 
79
  def dataframe_electricity_mix(countries: list):
80
  df = pd.read_csv("src/data/electricity_mix.csv")
81
+
82
+
83
  df["name_unit"] = df["name"] + " (" + df["unit"] + ")"
84
  df = df[["name_unit"] + [x[1] for x in COUNTRY_CODES if x[0] in countries]]
85
 
src/expert.py CHANGED
@@ -1,27 +1,23 @@
 
1
  import streamlit as st
2
  from ecologits.electricity_mix_repository import electricity_mixes
3
  from ecologits.impacts.llm import compute_llm_impacts
4
 
5
  from src.utils import format_impacts, average_range_impacts
6
  from src.impacts import display_impacts
7
- from src.electricity_mix import (
8
- COUNTRY_CODES,
9
- dataframe_electricity_mix,
10
- )
11
  from src.models import load_models
12
  from src.constants import PROMPTS
13
 
14
  import plotly.express as px
15
 
16
 
17
- def reset_model():
18
- model = "CUSTOM"
19
-
20
-
21
  def expert_mode():
22
  st.markdown("### 🤓 Expert mode")
23
 
24
  with st.container(border=True):
 
 
25
  ########## Model info ##########
26
 
27
  col1, col2, col3 = st.columns(3)
@@ -48,11 +44,6 @@ def expert_mode():
48
  key=2,
49
  )
50
 
51
- with col3:
52
- output_tokens_exp = st.selectbox(
53
- label="Example prompt", options=[x[0] for x in PROMPTS], key=3
54
- )
55
-
56
  df_filtered = df[
57
  (df["provider_clean"] == provider_exp) & (df["name_clean"] == model_exp)
58
  ]
@@ -93,17 +84,27 @@ def expert_mode():
93
  "Total parameters (B)", 0, None, total_params
94
  )
95
 
96
- with col33:
 
 
 
 
 
 
 
 
 
 
 
97
  output_tokens = st.number_input(
98
  label="Output completion tokens",
99
  min_value=0,
100
  value=[x[1] for x in PROMPTS if x[0] == output_tokens_exp][0],
101
  )
102
 
103
- ########## Electricity mix ##########
104
 
105
  with st.container(border=True):
106
- st.markdown("##### Electricity mix")
107
 
108
  location = st.selectbox("Location", [x[0] for x in COUNTRY_CODES])
109
 
@@ -224,24 +225,25 @@ def expert_mode():
224
 
225
  countries_to_compare = st.multiselect(
226
  label="Countries to compare",
227
- options=[x[0] for x in COUNTRY_CODES],
228
- default=["🇫🇷 France", "🇺🇸 United States", "🇨🇳 China"],
 
229
  )
230
 
231
  try:
232
- df_comp = dataframe_electricity_mix(countries_to_compare)
233
-
234
  impact_type = st.selectbox(
235
  label="Select an impact type to compare",
236
- options=[x for x in df_comp.columns if x != "country"],
237
- index=1,
 
238
  )
239
 
240
- df_comp.sort_values(by=impact_type, inplace=True)
 
241
 
242
  fig_2 = px.bar(
243
  df_comp,
244
- x=df_comp.index,
245
  y=impact_type,
246
  text=impact_type,
247
  color=impact_type,
 
1
+ import pandas as pd
2
  import streamlit as st
3
  from ecologits.electricity_mix_repository import electricity_mixes
4
  from ecologits.impacts.llm import compute_llm_impacts
5
 
6
  from src.utils import format_impacts, average_range_impacts
7
  from src.impacts import display_impacts
8
+ from src.electricity_mix import COUNTRY_CODES, format_electricity_mix_criterion, format_country_name
 
 
 
9
  from src.models import load_models
10
  from src.constants import PROMPTS
11
 
12
  import plotly.express as px
13
 
14
 
 
 
 
 
15
  def expert_mode():
16
  st.markdown("### 🤓 Expert mode")
17
 
18
  with st.container(border=True):
19
+ st.markdown("###### Configure the model")
20
+
21
  ########## Model info ##########
22
 
23
  col1, col2, col3 = st.columns(3)
 
44
  key=2,
45
  )
46
 
 
 
 
 
 
47
  df_filtered = df[
48
  (df["provider_clean"] == provider_exp) & (df["name_clean"] == model_exp)
49
  ]
 
84
  "Total parameters (B)", 0, None, total_params
85
  )
86
 
87
+
88
+ with st.container(border=True):
89
+ st.markdown("###### Configure the prompt")
90
+
91
+ col1, col2 = st.columns(2)
92
+
93
+ with col1:
94
+ output_tokens_exp = st.selectbox(
95
+ label="Example prompt", options=[x[0] for x in PROMPTS], key=3
96
+ )
97
+
98
+ with col2:
99
  output_tokens = st.number_input(
100
  label="Output completion tokens",
101
  min_value=0,
102
  value=[x[1] for x in PROMPTS if x[0] == output_tokens_exp][0],
103
  )
104
 
 
105
 
106
  with st.container(border=True):
107
+ st.markdown("###### Configure the electricity mix of the data center")
108
 
109
  location = st.selectbox("Location", [x[0] for x in COUNTRY_CODES])
110
 
 
225
 
226
  countries_to_compare = st.multiselect(
227
  label="Countries to compare",
228
+ options=[c[1] for c in COUNTRY_CODES],
229
+ format_func=format_country_name,
230
+ default=["FRA", "USA", "CHN"],
231
  )
232
 
233
  try:
 
 
234
  impact_type = st.selectbox(
235
  label="Select an impact type to compare",
236
+ options=["gwp", "adpe", "pe", "wue"],
237
+ format_func=format_electricity_mix_criterion,
238
+ index=0,
239
  )
240
 
241
+ df_comp = pd.DataFrame([em for em in electricity_mixes.list_electricity_mixes() if em.zone in countries_to_compare])
242
+ df_comp = df_comp.sort_values(by=impact_type, ascending=True)
243
 
244
  fig_2 = px.bar(
245
  df_comp,
246
+ x=df_comp.zone.apply(format_country_name),
247
  y=impact_type,
248
  text=impact_type,
249
  color=impact_type,