Skip to content

Commit 32853e8

Browse files
committed
Flip hydro subplot, Add demand axis on state of charge plots
1 parent d210c48 commit 32853e8

File tree

3 files changed

+71
-30
lines changed

3 files changed

+71
-30
lines changed

papers/Martin_Staadecker_et_al_2022/figure-2-analysis-of-4-factors.py

Lines changed: 31 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,12 @@
4343
# Define tools for hydro set
4444
tools_hydro = GraphTools(
4545
scenarios=[
46-
get_scenario("H25", 0),
47-
get_scenario("H025", 0.25),
46+
get_scenario("H25", 1),
47+
get_scenario("H025", 0.75),
4848
get_scenario("H050", 0.5),
49-
get_scenario("H065", 0.65),
50-
get_scenario("H085", 0.85),
51-
get_scenario("1342", 1),
49+
get_scenario("H065", 0.35),
50+
get_scenario("H085", 0.15),
51+
get_scenario("1342", 0),
5252
], set_style=False
5353
)
5454
tools_hydro.pre_graphing(multi_scenario=True)
@@ -238,21 +238,23 @@ def plot_panel(ax, rax, rrax, rrrax, data, title=""):
238238
plot_panel(ax, None, None, None, data_ws, "Set A: Varying Wind-vs-Solar Share")
239239

240240
ax.set_xticks([0.1, 0.2, 0.3, 0.4, 0.5, 0.6])
241-
ax.set_xticklabels(["90%-10%\nSolar-Wind", "", "70%-30%\nSolar-Wind", "", "50%-50%\nSolar-Wind", ""])
241+
ax.set_xticklabels(["90% Solar\n10% Wind", "", "70% Solar\n30% Wind", "", "50% Solar\n50% Wind", ""])
242+
ax.set_xlabel("Solar-Wind ratio")
242243
ax.axvline(baseline_ws_ratio, linestyle="dotted", color="dimgrey")
243244
ax.text(baseline_ws_ratio - 0.02, 0.1, "Baseline", rotation=90, color="dimgrey")
244245

245246
fig.legend(loc="lower center", ncol=4)
246247

247248
# %% PLOT HYDRO
248-
data_hy = get_data(tools_hydro, normalize_to_baseline=1)
249+
data_hy = get_data(tools_hydro, normalize_to_baseline=0)
249250
ax = ax_tr
250251
# rax = rax_top_right
251252
plot_panel(ax, None, None, None, data_hy, "Set B: Reducing Hydropower Generation")
252253
ax.tick_params(top=False, bottom=True, right=False, left=False, which="both")
253254
ax.set_xticks([0, 0.5, 1])
254255
ax.set_xticks([0.1, 0.2, 0.3, 0.4, 0.6, 0.7, 0.8, 0.9], minor=True)
255-
ax.set_xticklabels(["No\nhydropower", "50%\nhydropower", "Baseline\nHydropower"])
256+
ax.set_xticklabels(["0%\n(Baseline)", "50%", "100%\n(No Hydro)"])
257+
ax.set_xlabel("Hydropower reduction")
256258

257259
# %% PLOT TX
258260
ax = ax_bl
@@ -301,7 +303,7 @@ def plot_panel(ax, rax, rrax, rrrax, data, title=""):
301303
ax.axvline(baseline_energy_cost, linestyle="dotted", color="dimgrey")
302304
ax.text(baseline_energy_cost - 4, 0.1, "Baseline", rotation=90, color="dimgrey")
303305

304-
plt.subplots_adjust(left=0.08, right=0.97, top=0.95, wspace=0.05)
306+
plt.subplots_adjust(left=0.08, right=0.97, top=0.95, wspace=0.05, hspace=0.25)
305307

306308
# %% SAVE FIGURE
307309
save_figure("figure-2-analysis-of-4-factors.png")
@@ -372,3 +374,23 @@ def plot_panel(ax, rax, rrax, rrrax, data, title=""):
372374
total_power = df.groupby("scenario_name").OnlinePowerCapacityMW.sum()
373375
total_energy = df.groupby("scenario_name").OnlineEnergyCapacityMWh.sum()
374376
total_energy / total_power
377+
# %% California only costs
378+
df = tools_cost.get_dataframe("storage_capacity.csv")
379+
df = tools_cost.transform.load_zone(df)
380+
df = df[df.region == "CA"]
381+
df["duration"] = df["OnlineEnergyCapacityMWh"] / df["OnlinePowerCapacityMW"]
382+
print("max duration", df.groupby("scenario_name").duration.max())
383+
print("median duration", df.groupby("scenario_name").duration.median())
384+
print("total capacity", df.groupby("scenario_name").OnlineEnergyCapacityMWh.sum() / 1e6)
385+
386+
cap = tools_cost.get_dataframe("gen_cap.csv")
387+
cap = tools_cost.transform.gen_type(cap)
388+
cap = cap.groupby(["scenario_index", "gen_type"], as_index=False)[
389+
"GenCapacity"
390+
].sum()
391+
cap = cap.pivot(columns="gen_type", index="scenario_index", values="GenCapacity")
392+
cap *= 1e-3 # Convert to GW
393+
cap = cap.rename_axis("Technology", axis=1).rename_axis(None)
394+
cap = cap[["Solar"]]
395+
cap.index = cap.index.map(tools_cost.get_scenario_name)
396+
cap

papers/Martin_Staadecker_et_al_2022/figure-5-impact-of-ldes-on-grid.py

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,8 @@
137137
# %% State of charge
138138
ax = ax3
139139
ax.clear()
140+
axr = ax.twinx()
141+
axr.grid(False)
140142

141143
freq = "1D"
142144

@@ -164,8 +166,8 @@
164166
demand = demand.set_index("datetime")["value"]
165167
demand *= 4 * 1e-6 # Each timestep is 4 hours, converting to TWh
166168
total_demand = demand.sum()
167-
demand = demand.resample(freq).mean()
168-
demand = demand * 60 / demand.max()
169+
print(total_demand)
170+
demand = demand.resample(freq).sum()
169171

170172
state_of_charge.plot(
171173
ax=ax,
@@ -174,12 +176,7 @@
174176
xlabel="Time of year",
175177
legend=False,
176178
)
177-
plt.colorbar(
178-
cm.ScalarMappable(norm=Normalize(1.94, 64), cmap="viridis"),
179-
ax=ax,
180-
label="Storage Capacity (TWh)",
181-
fraction=0.1,
182-
)
179+
183180

184181
lines = ax.get_lines()
185182
x_label = {
@@ -197,12 +194,26 @@
197194
continue
198195
labellines.labelLine(line, state_of_charge.index[x_label[label]], linespacing=1, outline_width=1, label=str(int(label))+"TWh", align=False, color='k', fontsize="small")
199196

200-
demand_lines = ax.plot(demand, c="dimgray", linestyle="--", alpha=0.5)
201-
ax.legend(demand_lines, [f"Demand ({total_demand:.0f} TWh/year)"])
197+
demand = demand.iloc[1:-1]
198+
demand_lines = axr.plot(demand, c="dimgray", linestyle="--", alpha=0.5)
199+
axr.legend(demand_lines, [f"Demand ({total_demand:.0f} TWh/year)"])
200+
201+
ax.set_ylim(0, 65)
202+
axr.set_ylim(0, 65 / 10)
203+
axr.set_ylabel("Demand (TWh/day)")
202204

203205
ax.set_title("C. State of charge throughout the year")
204-
# %% SAVE FIGURE
206+
205207
plt.tight_layout()
208+
209+
plt.colorbar(
210+
cm.ScalarMappable(norm=Normalize(1.94, 64), cmap="viridis"),
211+
ax=ax,
212+
label="Storage Capacity (TWh)",
213+
fraction=0.1,
214+
pad=0.1
215+
)
216+
# %% SAVE FIGURE
206217
save_figure("figure-5-impact-of-ldes-on-grid.png")
207218

208219
# %% CALCULATIONS

papers/Martin_Staadecker_et_al_2022/figure-s3-state-of-charge-under-different-costs.py

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@
3131
fig = plt.figure()
3232
# fig.set_size_inches(12, 6)
3333
ax = fig.gca()
34+
axr = ax.twinx()
35+
axr.grid(False)
3436

3537
freq = "1D"
3638

@@ -58,8 +60,8 @@
5860
demand = demand.set_index("datetime")["value"]
5961
demand *= 4 * 1e-6 # Each timestep is 4 hours, converting to TWh
6062
total_demand = demand.sum()
61-
demand = demand.resample(freq).mean()
62-
demand = demand * 35 / demand.max()
63+
demand = demand.resample(freq).sum()
64+
demand = demand.iloc[1:-1]
6365

6466
state_of_charge.plot(
6567
ax=ax,
@@ -68,12 +70,6 @@
6870
xlabel="Time of year",
6971
legend=False,
7072
)
71-
plt.colorbar(
72-
cm.ScalarMappable(norm=Normalize(0.5, 102), cmap="viridis"),
73-
ax=ax,
74-
label="Energy Storage Capacity Costs ($/KWh)",
75-
fraction=0.1,
76-
)
7773

7874
lines = ax.get_lines()
7975
x_label = {
@@ -88,10 +84,22 @@
8884
continue
8985
labellines.labelLine(line, state_of_charge.index[x_label[label]], linespacing=1, outline_width=1, label=str(label)+"$/KWh", align=False, color='k', fontsize="small")
9086

91-
demand_lines = ax.plot(demand, c="dimgray", linestyle="--", alpha=0.5)
92-
ax.legend(demand_lines, [f"Demand ({total_demand:.0f} TWh/year)"])
87+
demand_lines = axr.plot(demand, c="dimgray", linestyle="--", alpha=0.5)
88+
axr.legend(demand_lines, [f"Demand ({total_demand:.0f} TWh/year)"])
89+
axr.set_ylabel("Demand (TWh/day)")
90+
91+
ax.set_ylim(0, 36)
92+
axr.set_ylim(0, 36 / 5)
9393

9494
plt.tight_layout()
95+
96+
plt.colorbar(
97+
cm.ScalarMappable(norm=Normalize(0.5, 102), cmap="viridis"),
98+
ax=ax,
99+
label="Energy Storage Capacity Costs ($/KWh)",
100+
pad=0.08,
101+
fraction=0.05,
102+
)
95103
# %% SAVE FIGURE
96104
save_figure("figure-s3-state-of-charge-under-different-costs.png")
97105

0 commit comments

Comments
 (0)