Skip to content

Commit b2687f6

Browse files
committed
Storage levels in dispatch plot filtered by s units instead of s + th, possible to plot th only as well
1 parent 80ee01e commit b2687f6

File tree

3 files changed

+55
-10
lines changed

3 files changed

+55
-10
lines changed

dispaset/common.py

+11-3
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@
2020
# DispaSET fuels:
2121
commons['Fuels'] = ['BIO', 'GAS', 'HRD', 'LIG', 'NUC', 'OIL', 'PEA', 'SUN', 'WAT', 'WIN', 'WST', 'OTH', 'GEO']
2222
# Ordered list of fuels for plotting (the first ones are negative):
23-
commons['MeritOrder'] = ['Storage','FlowOut','GEO','NUC', 'LIG', 'HRD', 'BIO', 'GAS', 'OIL', 'PEA', 'WST', 'OTH', 'SUN', 'WIN', 'FlowIn', 'WAT']
23+
# commons['MeritOrder'] = ['Storage','FlowOut','GEO','NUC', 'LIG', 'HRD', 'BIO', 'GAS', 'OIL', 'PEA', 'WST', 'OTH', 'SUN', 'WIN', 'FlowIn', 'WAT']
24+
commons['MeritOrder'] = ['THMS','BATS','BEVS','HDAM','HPHS','FlowOut','GEO','NUC', 'LIG', 'HRD', 'BIO', 'GAS', 'OIL', 'PEA', 'WST', 'OTH', 'SUN', 'WIN', 'FlowIn', 'WAT']
25+
2426
# Colors associated with each fuel:
2527
commons['colors'] = {'LIG': '#af4b9180', 'PEA': '#af4b9199', 'HRD': '#af4b91b2', 'OIL': '#af4b91ff',
2628
'GAS': '#d7642dff',
@@ -30,7 +32,12 @@
3032
'WAT': '#00a0e1ff',
3133
'BIO': '#7daf4bff', 'GEO': '#7daf4bbf',
3234
'Storage': '#b93c46ff', 'FlowIn': '#b93c46b2', 'FlowOut': '#b93c4666',
33-
'OTH': '#b9c33799', 'WST': '#b9c337ff'}
35+
'OTH': '#b9c33799', 'WST': '#b9c337ff',
36+
'HDAM': '#78C7C7',
37+
'HPHS': '#3090C7ff',
38+
'THMS': '#C04000ff',
39+
'BATS': '#41A317ff',
40+
'BEVS': '#4863A0ff'}
3441
commons['colors']['curtailment'] = 'red'
3542
# Hatches associated with each fuel:
3643
commons['hatches'] = {'LIG': '', 'PEA': '', 'HRD': '', 'OIL': '',
@@ -41,7 +48,8 @@
4148
'WAT': '',
4249
'BIO': '', 'GEO': '',
4350
'Storage': '', 'FlowIn': '/', 'FlowOut': '\\',
44-
'WST': '', 'OTH': ''
51+
'WST': '', 'OTH': '',
52+
'HDAM': '','HPHS': '','THMS': '','BATS': '','BEVS': ''
4553
}
4654

4755
commons['logfile'] = str(datetime.datetime.now()).replace(':','-').replace(' ','_') + '.dispa.log'

dispaset/postprocessing/plot.py

+7-6
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from ..misc.str_handler import clean_strings
99
from ..common import commons
1010

11-
from .postprocessing import get_imports, get_plot_data, filter_by_zone
11+
from .postprocessing import get_imports, get_plot_data, filter_by_zone, filter_by_tech, filter_by_storage
1212

1313

1414
def plot_dispatch(demand, plotdata, level=None, curtailment=None, shedload=None, rng=None,
@@ -140,16 +140,16 @@ def plot_dispatch(demand, plotdata, level=None, curtailment=None, shedload=None,
140140
# plt.legend(handles=[line_demand] + patches[::-1], loc=4)
141141

142142
if shedload is None and level is None:
143-
plt.legend(handles=[line_demand] + patches[::-1], loc=4, bbox_to_anchor=(1.2, 1.3))
143+
plt.legend(handles=[line_demand] + patches[::-1], loc=4, bbox_to_anchor=(1.2, 0.5))
144144
if shedload is None:
145-
plt.legend(handles=[line_demand] + [line_SOC] + patches[::-1], loc=4, bbox_to_anchor=(1.2, 1.3))
145+
plt.legend(handles=[line_demand] + [line_SOC] + patches[::-1], loc=4, bbox_to_anchor=(1.2, 0.5))
146146
elif level is None:
147-
plt.legend(handles=[line_demand] + [line_shedload] + patches[::-1], loc=4, bbox_to_anchor=(1.2, 1.3))
147+
plt.legend(handles=[line_demand] + [line_shedload] + patches[::-1], loc=4, bbox_to_anchor=(1.2, 0.5))
148148
axes[0].fill_between(demand.index, demand, reduced_demand, facecolor="none", hatch="X", edgecolor="k",
149149
linestyle='dashed')
150150
else:
151151
plt.legend(title='Dispatch for ' + demand.name[1], handles=[line_demand] + [line_shedload] + [line_SOC] +
152-
patches[::-1], loc=4, bbox_to_anchor=(1.2, 1.3))
152+
patches[::-1], loc=4, bbox_to_anchor=(1.2, 0.5))
153153
axes[0].fill_between(demand.index, demand, reduced_demand, facecolor="none", hatch="X", edgecolor="k",
154154
linestyle='dashed')
155155

@@ -327,7 +327,8 @@ def plot_zone(inputs, results, z='', rng=None, rug_plot=True):
327327
plotdata = get_plot_data(inputs, results, z) / 1000 # GW
328328

329329
if 'OutputStorageLevel' in results:
330-
level = filter_by_zone(results['OutputStorageLevel'], inputs, z) / 1E6 # TWh
330+
levels = filter_by_zone(results['OutputStorageLevel'], inputs, z) / 1E6 # TWh
331+
level = filter_by_storage(levels, inputs, StorageSubset='s')
331332
level = level.sum(axis=1)
332333
else:
333334
level = pd.Series(0, index=results['OutputPower'].index)

dispaset/postprocessing/postprocessing.py

+37-1
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,34 @@ def filter_by_zone(PowerOutput, inputs, z):
9797
return Power
9898

9999

100+
def filter_by_tech(PowerOutput, inputs, t):
101+
"""
102+
This function filters the dispaset power output dataframe by technology
103+
104+
:param PowerOutput: Dataframe of power generation with units as columns and time as index
105+
:param inputs: Dispaset inputs version 2.1.1
106+
:param t: Selected tech (e.g. 'HDAM')
107+
:returns Power:
108+
"""
109+
loc = inputs['units']['Technology']
110+
Power = PowerOutput.loc[:, [u for u in PowerOutput.columns if loc[u] == t]]
111+
return Power
112+
113+
114+
def filter_by_storage(PowerOutput, Inputs, StorageSubset=None):
115+
"""
116+
This function filters the power generation curves of the different storage units by storage type
117+
118+
:param PowerOutput: Dataframe of power generationwith units as columns and time as index
119+
:param Inputs: Dispaset inputs version 2.1.1
120+
:param SpecifySubset: If not all EES storages should be considered, list containing the relevant ones
121+
:returns PowerByFuel: Dataframe with power generation by fuel
122+
"""
123+
storages = Inputs['sets'][StorageSubset]
124+
Power = PowerOutput.loc[:, PowerOutput.columns.isin(storages)]
125+
return Power
126+
127+
100128
def get_plot_data(inputs, results, z):
101129
"""
102130
Function that reads the results dataframe of a DispaSET simulation and extract the dispatch data spedific to one zone
@@ -112,7 +140,15 @@ def get_plot_data(inputs, results, z):
112140
#onnly take the columns that correspond to storage units (StorageInput is also used for CHP plants):
113141
cols = [col for col in results['OutputStorageInput'] if inputs['units'].loc[col,'Technology'] in commons['tech_storage']]
114142
tmp = filter_by_zone(results['OutputStorageInput'][cols], inputs, z)
115-
plotdata['Storage'] = -tmp.sum(axis=1)
143+
bb = pd.DataFrame()
144+
for tech in commons['tech_storage']:
145+
aa = filter_by_tech(tmp, inputs, tech)
146+
aa = aa.sum(axis=1)
147+
aa = pd.DataFrame(aa,columns=[tech])
148+
bb = pd.concat([bb,aa],axis=1)
149+
bb = -bb
150+
plotdata = pd.concat([plotdata,bb], axis=1)
151+
# plotdata['Storage'] = -tmp.sum(axis=1)
116152
else:
117153
plotdata['Storage'] = 0
118154
plotdata.fillna(value=0, inplace=True)

0 commit comments

Comments
 (0)