Skip to content

Commit c706c88

Browse files
committed
Final changes to figures
1 parent 4804d8a commit c706c88

9 files changed

+323
-80
lines changed

papers/Martin_Staadecker_et_al_2022/analysis.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,17 @@
3232
prebuilt = prebuilt[(prebuilt.build_year + prebuilt.gen_max_age) > 2051]
3333
print("prebuilt alive :", len(prebuilt))
3434

35+
print("prebuild by tech")
36+
prebuilt_by_tech = prebuilt.groupby(
37+
["gen_energy_source", "gen_tech"]
38+
).GENERATION_PROJECT.count()
39+
print(prebuilt_by_tech)
40+
3541
prebuilt_by_tech = (
3642
prebuilt.groupby(["gen_energy_source", "gen_tech"]).gen_capacity_limit_mw.sum()
3743
/ 1000
3844
)
45+
print("prebuilt by tech capacity")
3946
print(prebuilt_by_tech.sort_values(ascending=False))
4047
print(prebuilt_by_tech.sum())
4148

papers/Martin_Staadecker_et_al_2022/figure-1-baseline.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,11 +149,11 @@ def rolling_avg(df):
149149
color=colors[columnName],
150150
label=columnName + " (no curtail.)",
151151
)
152-
ax_right.plot(duals, label="Estimated LMP", color="red")
152+
ax_right.plot(duals, label="Marginal Price", color="red")
153153
lines += ax.plot(load, color="orange", label="Demand")
154154
ax.set_title("A. Seasonal Profiles in the Baseline")
155155
ax.set_ylabel("Dispatch (TWh/day)")
156-
ax_right.set_ylabel("Estimated Locational Marginal Price ($/MWh)")
156+
ax_right.set_ylabel("Marginal Price of Electricity ($/MWh)")
157157
locator = mdates.MonthLocator()
158158
ax.xaxis.set_major_formatter(mdates.ConciseDateFormatter(locator))
159159
ax.set_ylim(-0.1, 4.7)
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
"""
2+
Creates a map of the WECC with each load zone labelled with it's SWITCH name.
3+
Useful for figuring out what load zone name matches what physical region.
4+
The map is available in the REAM Google Drive under Research -> Switch documentation.
5+
"""
6+
7+
from matplotlib import pyplot as plt
8+
9+
from papers.Martin_Staadecker_et_al_2022.util import (
10+
get_scenario,
11+
set_style,
12+
save_figure,
13+
)
14+
from switch_model.tools.graph.main import GraphTools
15+
16+
tools = GraphTools([get_scenario("1342")], set_style=False)
17+
tools.pre_graphing(multi_scenario=False)
18+
19+
# %% CREATE PLOT FRAME
20+
set_style()
21+
plt.close()
22+
fig = plt.figure()
23+
fig.set_size_inches(6.850394, 6.850394)
24+
ax = fig.add_subplot(1, 1, 1, projection=tools.maps.get_projection())
25+
26+
tools.maps.draw_base_map(ax)
27+
28+
centers = {}
29+
30+
for _, lz in tools.maps._center_points.iterrows():
31+
center = lz.geometry.centroid
32+
ax.scatter(center.x, center.y, color="k", s=5, alpha=0.5)
33+
ax.text(center.x, center.y, lz.gen_load_zone, fontsize="small")
34+
centers[lz.gen_load_zone] = center
35+
36+
tx = tools.get_dataframe("transmission_lines.csv", from_inputs=True)
37+
tx = tx[["trans_lz1", "trans_lz2"]]
38+
for _, line in tx.iterrows():
39+
from_center = centers[line["trans_lz1"]]
40+
to_center = centers[line["trans_lz2"]]
41+
ax.plot(
42+
[from_center.x, to_center.x],
43+
[from_center.y, to_center.y],
44+
color="k",
45+
linestyle="--",
46+
linewidth=1,
47+
alpha=0.3,
48+
)
49+
50+
for lz, center in centers.items():
51+
ax.text(center.x, center.y, lz, fontsize="small")
52+
53+
plt.tight_layout()
54+
# %%
55+
save_figure("figure-s5-map-of-load-zones.png")

papers/Martin_Staadecker_et_al_2022/figure-s5-duration-cdf-cost-scenarios.py renamed to papers/Martin_Staadecker_et_al_2022/figure-x1-duration-cdf-cost-scenarios.py

Lines changed: 63 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,28 @@
44

55
from papers.Martin_Staadecker_et_al_2022.util import (
66
set_style,
7-
get_scenario, save_figure
7+
get_scenario,
8+
save_figure,
89
)
910
from switch_model.tools.graph.main import GraphTools
1011

1112
# Prepare graph tools
12-
tools = GraphTools(scenarios=[
13-
get_scenario("C21", 0.5),
14-
get_scenario("C18", 1),
15-
get_scenario("C22", 2),
16-
get_scenario("C23", 5),
17-
get_scenario("C26", 7),
18-
get_scenario("C17", 10),
19-
get_scenario("C24", 15),
20-
get_scenario("1342", 22.43),
21-
get_scenario("C25", 40),
22-
get_scenario("C19", 70),
23-
get_scenario("C20", 102)
24-
], set_style=False)
13+
tools = GraphTools(
14+
scenarios=[
15+
get_scenario("C21", 0.5),
16+
get_scenario("C18", 1),
17+
get_scenario("C22", 2),
18+
get_scenario("C23", 5),
19+
get_scenario("C26", 7),
20+
get_scenario("C17", 10),
21+
get_scenario("C24", 15),
22+
get_scenario("1342", 22.43),
23+
get_scenario("C25", 40),
24+
get_scenario("C19", 70),
25+
get_scenario("C20", 102),
26+
],
27+
set_style=False,
28+
)
2529
tools.pre_graphing(multi_scenario=True)
2630

2731
set_style()
@@ -32,7 +36,7 @@
3236
ax.clear()
3337
duration = tools.get_dataframe("storage_capacity.csv")
3438
duration["duration"] = duration["duration"] = (
35-
duration["OnlineEnergyCapacityMWh"] / duration["OnlinePowerCapacityMW"]
39+
duration["OnlineEnergyCapacityMWh"] / duration["OnlinePowerCapacityMW"]
3640
)
3741

3842
duration = duration.sort_values("duration")
@@ -44,22 +48,60 @@
4448
duration_scenario["cuml_power"] = duration_scenario.OnlinePowerCapacityMW.cumsum()
4549
duration_scenario = duration_scenario.set_index("cuml_power")
4650
duration_scenario = duration_scenario["duration"]
47-
line = ax.plot(duration_scenario.index, duration_scenario, drawstyle="steps", label=scenario_name)
51+
line = ax.plot(
52+
duration_scenario.index,
53+
duration_scenario,
54+
drawstyle="steps",
55+
label=scenario_name,
56+
)
4857
if float(int(scenario_name)) == scenario_name:
4958
label = str(int(scenario_name))
5059
else:
5160
label = str(scenario_name)
52-
labellines.labelLine(line[0], duration_scenario.index.max(), outline_width=2, label=label + "$/KWh", align=False,
53-
fontsize="small")
61+
labellines.labelLine(
62+
line[0],
63+
duration_scenario.index.max(),
64+
outline_width=2,
65+
label=label + "$/KWh",
66+
align=False,
67+
fontsize="small",
68+
)
5469

5570
ax.set_yscale("log")
5671
ax.set_xlabel("Storage Power Capacity (GW)")
5772
ax.set_ylabel("Storage Duration (h)")
5873
ax.set_yticks([10, 100, 1000])
59-
ax.set_yticks([2, 3, 4, 5, 6, 7, 8, 9, 20, 30, 40, 50, 60, 70, 80, 90, 200, 300, 400, 500, 600, 700, 800, 900],
60-
minor=True)
74+
ax.set_yticks(
75+
[
76+
2,
77+
3,
78+
4,
79+
5,
80+
6,
81+
7,
82+
8,
83+
9,
84+
20,
85+
30,
86+
40,
87+
50,
88+
60,
89+
70,
90+
80,
91+
90,
92+
200,
93+
300,
94+
400,
95+
500,
96+
600,
97+
700,
98+
800,
99+
900,
100+
],
101+
minor=True,
102+
)
61103
ax.set_yticklabels(["10", "100", "1000"])
62104
plt.tight_layout()
63105

64106
# %%
65-
save_figure("figure-s5-duration-cdf-cost-scenarios.png")
107+
save_figure("figure-s5-duration-cdf-cost-scenarios.png")

papers/Martin_Staadecker_et_al_2022/figure-s6-duration-cdf-cost-scenarios-ca-only.py renamed to papers/Martin_Staadecker_et_al_2022/figure-x2-duration-cdf-cost-scenarios-ca-only.py

Lines changed: 63 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,28 @@
44

55
from papers.Martin_Staadecker_et_al_2022.util import (
66
set_style,
7-
get_scenario, save_figure
7+
get_scenario,
8+
save_figure,
89
)
910
from switch_model.tools.graph.main import GraphTools
1011

1112
# Prepare graph tools
12-
tools = GraphTools(scenarios=[
13-
get_scenario("C21", 0.5),
14-
get_scenario("C18", 1),
15-
get_scenario("C22", 2),
16-
get_scenario("C23", 5),
17-
get_scenario("C26", 7),
18-
get_scenario("C17", 10),
19-
get_scenario("C24", 15),
20-
get_scenario("1342", 22.43),
21-
get_scenario("C25", 40),
22-
get_scenario("C19", 70),
23-
get_scenario("C20", 102)
24-
], set_style=False)
13+
tools = GraphTools(
14+
scenarios=[
15+
get_scenario("C21", 0.5),
16+
get_scenario("C18", 1),
17+
get_scenario("C22", 2),
18+
get_scenario("C23", 5),
19+
get_scenario("C26", 7),
20+
get_scenario("C17", 10),
21+
get_scenario("C24", 15),
22+
get_scenario("1342", 22.43),
23+
get_scenario("C25", 40),
24+
get_scenario("C19", 70),
25+
get_scenario("C20", 102),
26+
],
27+
set_style=False,
28+
)
2529
tools.pre_graphing(multi_scenario=True)
2630

2731
set_style()
@@ -34,7 +38,7 @@
3438
duration = tools.transform.load_zone(duration)
3539
duration = duration[duration.region == "CA"]
3640
duration["duration"] = duration["duration"] = (
37-
duration["OnlineEnergyCapacityMWh"] / duration["OnlinePowerCapacityMW"]
41+
duration["OnlineEnergyCapacityMWh"] / duration["OnlinePowerCapacityMW"]
3842
)
3943

4044
duration = duration.sort_values("duration")
@@ -46,22 +50,60 @@
4650
duration_scenario["cuml_power"] = duration_scenario.OnlinePowerCapacityMW.cumsum()
4751
duration_scenario = duration_scenario.set_index("cuml_power")
4852
duration_scenario = duration_scenario["duration"]
49-
line = ax.plot(duration_scenario.index, duration_scenario, drawstyle="steps", label=scenario_name)
53+
line = ax.plot(
54+
duration_scenario.index,
55+
duration_scenario,
56+
drawstyle="steps",
57+
label=scenario_name,
58+
)
5059
if float(int(scenario_name)) == scenario_name:
5160
label = str(int(scenario_name))
5261
else:
5362
label = str(scenario_name)
54-
labellines.labelLine(line[0], duration_scenario.index.max(), outline_width=2, label=label + "$/KWh", align=False,
55-
fontsize="small")
63+
labellines.labelLine(
64+
line[0],
65+
duration_scenario.index.max(),
66+
outline_width=2,
67+
label=label + "$/KWh",
68+
align=False,
69+
fontsize="small",
70+
)
5671

5772
ax.set_yscale("log")
5873
ax.set_xlabel("Storage Power Capacity (GW)")
5974
ax.set_ylabel("Storage Duration (h)")
6075
ax.set_yticks([10, 100, 1000])
61-
ax.set_yticks([2, 3, 4, 5, 6, 7, 8, 9, 20, 30, 40, 50, 60, 70, 80, 90, 200, 300, 400, 500, 600, 700, 800, 900],
62-
minor=True)
76+
ax.set_yticks(
77+
[
78+
2,
79+
3,
80+
4,
81+
5,
82+
6,
83+
7,
84+
8,
85+
9,
86+
20,
87+
30,
88+
40,
89+
50,
90+
60,
91+
70,
92+
80,
93+
90,
94+
200,
95+
300,
96+
400,
97+
500,
98+
600,
99+
700,
100+
800,
101+
900,
102+
],
103+
minor=True,
104+
)
63105
ax.set_yticklabels(["10", "100", "1000"])
64106
plt.tight_layout()
65107

66108
# %%
67-
save_figure("figure-s6-duration-cdf-cost-scenarios-ca-only.png")
109+
save_figure("figure-s6-duration-cdf-cost-scenarios-ca-only.png")

papers/Martin_Staadecker_et_al_2022/reference-map-of-load-zones-with-names.py

Lines changed: 0 additions & 36 deletions
This file was deleted.

0 commit comments

Comments
 (0)