Skip to content

Commit 843a420

Browse files
carbon intensity great tables example
1 parent fa39504 commit 843a420

File tree

2 files changed

+133
-0
lines changed

2 files changed

+133
-0
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
Zone,CO2 Intensity,Hydro,Nuclear,Wind,Solar,Geothermal,Biomass,Gas,Coal,Oil,Unknown,Hydro Discharge,Battery Discharge
2+
Sweden,23.46128501,0.435312552,0.29174058,0.213598205,0.00905231,0,0.001934943,0.001616901,0.002284037,1.20E-04,0.044001931,3.37E-04,0
3+
Iceland,27.64152966,0.724137376,0,0,0,0.27586402,0,0,0,1.79E-06,0,0,0
4+
Quebec,30.56990899,0.914572876,0.009331108,0.047134419,9.71E-05,1.84E-06,0.025015002,0.003836545,1.07E-05,1.29E-05,7.95E-05,0,4.37E-08
5+
France,52.73432801,0.105179703,0.642433753,0.104647836,0.048092258,3.52E-06,0.014088511,0.065820679,0.004738863,0.003454775,6.81E-04,0.010860181,0
6+
Ontario,72.60078255,0.260361881,0.518587118,0.080440676,0.004531646,0,0.002384341,0.133519187,1.55E-04,2.82E-07,2.41E-05,0,0
7+
Finland,87.22831754,0.246151138,0.408646271,0.186382412,0.007824817,0,0.066174243,0.022113252,0.052003005,1.00E-04,0.010583202,1.92E-05,0
8+
Tasmania,92.1890272,0.663216796,0,0.192216671,0.057843914,0,0,0.005585102,0.080626115,0,0,0,1.33E-04
9+
New Zealand,94.50564468,0.627582681,5.62E-06,0.073994174,2.49E-05,0.181548723,0,0.061119138,0.035516963,2.77E-05,0.020244562,0,0
10+
Belgium,139.5605448,0.013668479,0.419910244,0.197723307,0.098437281,7.21E-07,0.032965683,0.186617324,0.014573294,0.001045043,0.020571735,0.014476877,0
11+
West Denmark,143.1380408,0.181489083,0.041429642,0.467775664,0.080510333,7.10E-06,0.07464462,0.059221754,0.081830912,0.004474977,0.005634762,0.003076031,0
12+
East Denmark,147.6286591,0.131248475,0.104716335,0.406830141,0.065438189,0,0.143553717,0.042023638,0.071743624,0.011683996,0.022128678,9.22E-04,0
13+
Spain,154.0142537,0.09969906,0.227273313,0.237562165,0.150134943,2.39E-07,0.021247062,0.217965679,0.015788692,0.001904201,0.003163999,0.025265191,0
14+
South Australia,185.7627912,0.010199114,0,0.449961993,0.24542457,0,0,0.218230503,0.069856191,9.57E-04,0,0,0.005213381
15+
Great Britain,199.8104792,0.045834272,0.181239034,0.301926186,0.059607545,4.57E-08,0.050829232,0.332149815,0.012325292,3.44E-04,0.009736427,0.005980374,0
16+
California,257.678732,0.123989435,0.100042977,0.096419088,0.17055086,0.031164503,0.017478187,0.41970878,0.012129465,1.02E-04,0.008942203,2.83E-04,0.019191918
17+
Netherlands,272.809179,0.030186796,0.048566848,0.315753767,0.167656374,1.34E-05,0.050021331,0.276795769,0.090373246,0.008306204,0.010581683,0.001761264,0
18+
New York ISO,279.992946,0.22594502,0.226559596,0.039417192,7.15E-04,0,0.001091576,0.482745941,0.005538419,1.23E-04,0.017781202,3.47E-06,7.12E-06
19+
Italy (North),307.2558542,0.244615333,0.119192177,0.029255242,0.069372174,0.003271406,0.021624102,0.370342992,0.025889108,0.001570806,0.086539443,0.028325907,1.25E-07
20+
Texas,383.1867568,8.28E-04,0.090769558,0.251576503,0.071636563,0,5.82E-07,0.44437107,0.138211735,3.56E-06,0.002600341,0,0
21+
Germany,396.7870709,0.059246857,0.043122592,0.290545677,0.117499352,3.77E-04,0.096291651,0.113309627,0.244769882,0.00481437,0.007452162,0.022569385,0
22+
Western Australia,433.2945402,0,0,0.155240714,0.191426117,0,0.004275849,0.350975922,0.29709105,3.16E-04,0,0,6.64E-04
23+
Alberta,438.9442161,0.029249945,4.04E-04,0.113897357,0.02666683,0,0.026402135,0.675430038,0.081166555,3.29E-04,0.04643415,1.55E-07,0
24+
Victoria,506.4048193,0.062479748,0,0.205928815,0.127014842,0,1.00E-05,0.014187332,0.587999674,4.05E-06,0,2.11E-08,0.002494507
25+
New South Wales,556.312457,0.048672531,0,0.092353062,0.195594575,0,0.001073667,0.021792087,0.639717569,5.83E-05,0,1.17E-06,6.62E-04
26+
India (North),558.2410211,0.212228393,0.02176545,0.015378776,0.077375285,9.83E-08,5.50E-07,0.018729681,0.642839452,9.36E-07,0.011682019,0,0
27+
Queensland,607.0348918,0.020918137,0,0.040105111,0.197967484,0,0.002442345,0.067024275,0.67051114,3.14E-04,0,1.44E-06,7.89E-04
28+
South Africa,700.9980742,0.009413239,0.042068349,0.057471213,0.03199641,0,0,7.87E-05,0.809385111,0.025579845,0.001312838,0.022695992,0
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
---
2+
title: "Untitled"
3+
format: typst
4+
execute:
5+
echo: false
6+
keep-md: true
7+
keep-typ: true
8+
---
9+
10+
```{=typst}
11+
#set page(flipped: true, margin: 0.5cm)
12+
#set par(justify: false)
13+
#show table: set text(size: 10pt)
14+
#show figure: set block(breakable: true)
15+
```
16+
17+
```{python}
18+
from great_tables import GT, md, html, system_fonts
19+
import pandas as pd
20+
21+
power_cie_prepared_tbl = pd.read_csv("2023_cie_power_cons.csv")
22+
23+
# Create a Great Tables object
24+
ciep_gt_tbl = GT(data=power_cie_prepared_tbl)
25+
26+
# Apply wider color ranges & formatting
27+
gt_tbl = ciep_gt_tbl \
28+
.fmt_percent(columns=['Hydro', 'Nuclear', 'Wind', 'Solar', 'Geothermal', 'Biomass', 'Gas',
29+
'Coal', 'Oil', 'Unknown', 'Hydro Discharge', 'Battery Discharge'],
30+
decimals=1) \
31+
.fmt_number(columns=['CO2 Intensity'],
32+
decimals=0) \
33+
.data_color(
34+
columns=['CO2 Intensity'],
35+
palette=[
36+
"#00A600", "#E6E600", "#E8C32E", "#D69C4E", "#Dc863B", "sienna", "sienna4", "tomato4", "brown"],
37+
domain=[0, 900]
38+
) \
39+
.data_color(
40+
columns=['Hydro', 'Nuclear', 'Wind', 'Solar','Geothermal'],
41+
palette=["#00A600", "chartreuse3", "chartreuse4", "snow"][::-1],
42+
domain=[0, 1]
43+
) \
44+
.data_color(
45+
columns=['Hydro', 'Geothermal'],
46+
palette=["#00A600", "chartreuse3", "chartreuse4", "snow"][::-1],
47+
domain=[0, 1]
48+
) \
49+
.data_color(
50+
columns=['Biomass'],
51+
palette=["snow", "#EEC900", "#E8C32E", "#D69C4E"],
52+
domain=[0, 0.3]
53+
) \
54+
.data_color(
55+
columns=['Gas', 'Coal', 'Oil'],
56+
palette=["tomato4", "sienna4", "#D69C4E", "#Dc863B", "snow"][::-1],
57+
domain=[0, 1]
58+
) \
59+
.data_color(
60+
columns=['Zone','Unknown', 'Hydro Discharge', 'Battery Discharge'],
61+
palette=["snow", "snow", "snow", 'snow']
62+
) \
63+
.cols_width(
64+
{'Zone': '106px', 'CO2 Intensity': '58px','Hydro': '58px', 'Nuclear': '58px', 'Wind': '58px', 'Solar': '58px',
65+
'Geothermal': '58px', 'Biomass': '58px', 'Gas': '58px', 'Coal': '58px',
66+
'Oil': '58px', 'Unknown': '58px', 'Hydro Discharge': '58px',
67+
'Battery Discharge': '58px'}
68+
) \
69+
.tab_header(
70+
title=md("2023 Mean **Carbon Intensity** (gCO2eq/kWh) and **Power Consumption** Breakdown (%)")
71+
) \
72+
.tab_source_note(
73+
md(
74+
'<br><div style="text-align: left;">'
75+
"**Source**: api.electricitymap.org"
76+
" | **Methodology**: https://www.electricitymaps.com/methodology."
77+
" Some emissions factors are based on IPCC 2014 defaults, while some are based on more accurate regional factors."
78+
" <br>All zones are publicly available on the *Carbon intensity and emission factors* tab via Google docs link<br>"
79+
"</div>"
80+
"<br>"
81+
)
82+
) \
83+
.tab_options(
84+
source_notes_font_size='x-small',
85+
source_notes_padding=3,
86+
table_font_names=system_fonts("humanist"),
87+
data_row_padding='1px',
88+
heading_background_color='antiquewhite',
89+
source_notes_background_color='antiquewhite',
90+
column_labels_background_color='antiquewhite',
91+
table_background_color='snow',
92+
data_row_padding_horizontal=3,
93+
column_labels_padding_horizontal=58
94+
) \
95+
.cols_align(
96+
align='center'
97+
) \
98+
.cols_align(
99+
align='left',
100+
columns=['Zone']
101+
)
102+
103+
gt_tbl
104+
105+
```

0 commit comments

Comments
 (0)