-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplots.py
232 lines (190 loc) · 10.5 KB
/
plots.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from windrose import WindroseAxes
from scipy.stats import weibull_min
def plot_all(data_tech_path, save_path_powerdata, p_req, nr_of_top):
'''
Dieses Modul beinhaltet die Funktionen für den Plot einer Windrose und der Weibullverteilung
und Kostenvergleich.
'''
#Filtern von Anlagen kleiner als bedarf im Jahr
data_wind_red = pd.read_excel(save_path_powerdata)
Turbines_bigger_45kWh = data_wind_red.iloc[:, 8:].cumsum(axis=0).columns[(data_wind_red.iloc[:, 8:].cumsum(axis=0).iloc[-1, :] >= p_req)].tolist()
#Erstellen von sortierten dfs für die plots
cost_data_raw = pd.read_excel(data_tech_path).set_index('Turbine')
cost_data_45kW_raw = cost_data_raw.copy()
cost_data = cost_data_raw.copy()
cost_data_45kW = cost_data_45kW_raw.copy().loc[Turbines_bigger_45kWh]
lcoe_data = cost_data_raw.copy().sort_values('LCOE').head(nr_of_top)
lcoe_data_45kW = cost_data_45kW_raw.copy().loc[Turbines_bigger_45kWh].sort_values('LCOE').head(nr_of_top)
turbine_names = lcoe_data.index
turbine_names_45kW = lcoe_data_45kW.index
lcoe_values = lcoe_data['LCOE']
lcoe_values_45kW = lcoe_data_45kW['LCOE']
#plot der LCOE
plt.figure(figsize=(10, 6))
plt.bar(turbine_names, lcoe_values)
plt.xlabel('Kleinwindenergieanlagenmodell')
plt.ylabel('LCOE in €/kWh')
plt.title('LCOE')
plt.xticks(rotation=90)
plt.tight_layout()
plt.savefig('data/LCOE.png')
plt.figure(figsize=(10, 6))
plt.bar(turbine_names_45kW, lcoe_values_45kW)
plt.xlabel('Kleinwindenergieanlagenmodell')
plt.ylabel('LCOE in €/kWh')
plt.title('LCOE für Turbinen größer '+ str(round(p_req)) + " kWh")
plt.xticks(rotation=90)
plt.tight_layout()
plt.savefig('data/LCOE45.png')
#Erstellung dfs für Gesamt- und Nebenkosten
cost_data['Rückbaukosten'] = 6548
cost_data['Investitionskosten'] = cost_data['Gesamtinvestitionskosten'] - 6548 # Abzug des Rückbaus, weil sonst doppelt im Plot
cost_data['Stacked Costs'] = cost_data['Investitionskosten'] + \
cost_data['Betriebskosten'] + cost_data['battery cost'] + \
cost_data['Rückbaukosten']
cost_data_Neb=(cost_data['Stacked Costs']-cost_data['Investitionskosten']).sort_values().head(nr_of_top).index
cost_data_Ges=cost_data.sort_values('Stacked Costs').head(nr_of_top).index
cost_data_45kW['Rückbaukosten'] = 6548
cost_data_45kW['Investitionskosten'] = cost_data_45kW['Gesamtinvestitionskosten'] - 6548 # Abzug des Rückbaus, weil sonst doppelt im Plot
cost_data_45kW['Stacked Costs'] = cost_data_45kW['Investitionskosten'] + \
cost_data_45kW['Betriebskosten'] + cost_data_45kW['battery cost'] + \
cost_data_45kW['Rückbaukosten']
cost_data_45kW_Neb=(cost_data_45kW['Stacked Costs']-cost_data_45kW['Investitionskosten']).sort_values().head(nr_of_top).index
cost_data_45kW_Ges=cost_data_45kW.sort_values('Stacked Costs').head(nr_of_top).index
# Plot für die gestapelten Kosten der KWEA
plt.figure(figsize=(15, 10))
plt.bar(cost_data_Ges, cost_data.loc[cost_data_Ges]['Investitionskosten'], label='Investitionskosten')
plt.bar(cost_data_Ges, cost_data.loc[cost_data_Ges]['Betriebskosten'], bottom=cost_data.loc[cost_data_Ges]['Investitionskosten'], label='Betriebskosten')
plt.bar(cost_data_Ges, cost_data.loc[cost_data_Ges]['battery cost'], bottom=cost_data.loc[cost_data_Ges]['Investitionskosten'] + cost_data.loc[cost_data_Ges]['Betriebskosten'], label='Batteriekosten')
plt.bar(cost_data_Ges, cost_data.loc[cost_data_Ges]['Rückbaukosten'], bottom=cost_data.loc[cost_data_Ges]['Stacked Costs'] - cost_data.loc[cost_data_Ges]['Rückbaukosten'], label='Rückbau')
plt.xlabel('Kleinwindenergieanlagenmodell')
plt.ylabel('Gesamtkosten in €')
plt.ylim(0, (cost_data['Investitionskosten']+cost_data['Betriebskosten']+cost_data['battery cost']+cost_data['Rückbaukosten']).max().max())
plt.title('Gesamtkostenvergleich der Kleinwindenergieanlagen')
plt.legend()
plt.xticks(rotation=90)
plt.tight_layout()
plt.savefig('data/Gesamtinvestitionskosten.png')
# Plot für die gestapelten Kosten der KWEA
plt.figure(figsize=(15, 10))
plt.bar(cost_data_45kW_Ges, cost_data_45kW.loc[cost_data_45kW_Ges]['Investitionskosten'], label='Investitionskosten')
plt.bar(cost_data_45kW_Ges, cost_data_45kW.loc[cost_data_45kW_Ges]['Betriebskosten'], bottom=cost_data_45kW.loc[cost_data_45kW_Ges]['Investitionskosten'], label='Betriebskosten')
plt.bar(cost_data_45kW_Ges, cost_data_45kW.loc[cost_data_45kW_Ges]['battery cost'], bottom=cost_data_45kW.loc[cost_data_45kW_Ges]['Investitionskosten'] + cost_data_45kW.loc[cost_data_45kW_Ges]['Betriebskosten'], label='Batteriekosten')
plt.bar(cost_data_45kW_Ges, cost_data_45kW.loc[cost_data_45kW_Ges]['Rückbaukosten'], bottom=cost_data_45kW.loc[cost_data_45kW_Ges]['Stacked Costs'] - cost_data_45kW.loc[cost_data_45kW_Ges]['Rückbaukosten'], label='Rückbau')
plt.xlabel('Kleinwindenergieanlagenmodell')
plt.ylabel('Gesamtkosten in €')
plt.title('Gesamtkostenvergleich der Kleinwindenergieanlagen größer ' + str(round(p_req)) + " kWh")
plt.legend()
plt.xticks(rotation=90)
plt.tight_layout()
plt.savefig('data/Gesamtinvestitionskosten45.png')
# Plot für die Nebenkosten und Rückbau einer KWEA.
plt.figure(figsize=(15, 10))
plt.bar(cost_data_Neb, cost_data.loc[cost_data_Neb]['Betriebskosten'], label='Betriebskosten', color='green')
plt.bar(cost_data_Neb, cost_data.loc[cost_data_Neb]['battery cost'], bottom=cost_data.loc[cost_data_Neb]['Betriebskosten'], label='Batteriekosten', color='orange')
plt.bar(cost_data_Neb, cost_data.loc[cost_data_Neb]['Rückbaukosten'], bottom=cost_data.loc[cost_data_Neb]['Betriebskosten'] + cost_data.loc[cost_data_Neb]['battery cost'], label='Rückbaukosten', color='red')
plt.xlabel('Kleinwindenergieanlagenmodell')
plt.ylabel('Nebenkosten in €')
plt.ylim(0, (cost_data['Betriebskosten']+cost_data['battery cost']+cost_data['Rückbaukosten']).max().max())
plt.title('Nebenkostenvergleich der Kleinwindenergieanlagen')
plt.legend()
plt.xticks(rotation=90)
plt.tight_layout()
plt.savefig('data/Nebenkosten.png')
# Plot für die Nebenkosten und Rückbau einer KWEA.
plt.figure(figsize=(15, 10))
plt.bar(cost_data_45kW_Neb, cost_data_45kW.loc[cost_data_45kW_Neb]['Betriebskosten'], label='Betriebskosten', color='green')
plt.bar(cost_data_45kW_Neb, cost_data_45kW.loc[cost_data_45kW_Neb]['battery cost'], bottom=cost_data_45kW.loc[cost_data_45kW_Neb]['Betriebskosten'], label='Batteriekosten', color='orange')
plt.bar(cost_data_45kW_Neb, cost_data_45kW.loc[cost_data_45kW_Neb]['Rückbaukosten'], bottom=cost_data_45kW.loc[cost_data_45kW_Neb]['Betriebskosten'] + cost_data_45kW.loc[cost_data_45kW_Neb]['battery cost'], label='Rückbaukosten', color='red')
plt.xlabel('Kleinwindenergieanlagenmodell')
plt.ylabel('Nebenkosten in €')
plt.title('Nebenkostenvergleich der Kleinwindenergieanlagen größer ' + str(round(p_req)) + " kWh")
plt.legend()
plt.xticks(rotation=90)
plt.tight_layout()
plt.savefig('data/Nebenkosten45.png')
# Plot der LCOE über die Nabenhöhe der KWEA. Macht nur dann Sinn wenn wir von einer KWEA unterschiedliche Nabenhöhen haben
data_hub_sorted = cost_data.sort_values('Hub height:')
plt.figure(figsize=(10, 6))
plt.plot(data_hub_sorted['Hub height:'], data_hub_sorted['LCOE'], marker='o', linestyle='', color='orange')
plt.xlabel('Nabenhöhe in m')
plt.ylabel('LCOE in €/kWh')
plt.title('LCOE über die Nabenhöhe von KWEA')
plt.grid(True)
# Winddaten einlesen
data_wind = pd.read_csv(r'weatherdata/Wetterdaten_Wanna_Szenario_1.txt', delimiter=';')
data_wind['MESS_DATUM'] = pd.to_datetime(data_wind['MESS_DATUM'], format='%Y%m%d%H')
data_wind = data_wind.rename(columns={"STATIONS_ID": "StationID", " F": "F", " D": "D"})
# data_wind aus DataFrame lesen
data = data_wind.copy()
# Windrichtungen und Geschwindigkeiten definieren
directions = data['D']
speeds = data['F']
# Werte unter 0 auf NaN setzen
speeds = speeds.copy()
directions = directions.copy()
speeds.loc[speeds < 0] = np.nan
directions.loc[directions < 0] = np.nan
# Windrose plotten
ax = WindroseAxes.from_ax()
ax.bar(directions, speeds, normed=True, opening=0.8, edgecolor='white')
ax.set_legend(title='Häufigkeit (%)')
plt.show()
ax.bar(directions, speeds, normed=True, nsector=16)
table = ax._info["table"]
wd_freq = np.sum(table, axis=0)
direction = ax._info["dir"]
wd_freq = np.sum(table, axis=0)
plt.bar(np.arange(16), wd_freq, align="center")
xlabels = (
"N", "",
"N-E", "",
"E", "",
"S-E", "",
"S", "",
"S-O", "",
"O", "",
"N-O", "",
)
xticks = np.arange(16)
plt.gca().set_xticks(xticks)
plt.gca().set_xticklabels(xlabels)
plt.show()
# Weibull Verteilung plotten:
# data_wind aus DataFrame lesen
data = data_wind.copy()
# Windgeschwindigkeiten auslesen
wind_speeds = np.array(data['F'])
# Faktoren für Weibull-Verteilung berechnen
shape, loc, scale = weibull_min.fit(wind_speeds, loc=0)
# Weibull-Verteilung generieren
x = np.linspace(0, wind_speeds.max(), 100)
pdf = weibull_min.pdf(x, shape, loc=loc, scale=scale)
# Histogramm der Windgeschwindigkeiten plotten
plt.hist(wind_speeds, bins=20, density=True, alpha=0.7, label='Windgeschwindigkeiten')
# Weibull-Verteilung plotten
plt.plot(x, pdf, 'r-', lw=2, label='Weibull-Verteilung')
# Diagramm beschriften
plt.xlabel('Windgeschwindigkeit (m/s)')
plt.ylabel('Häufigkeit')
plt.title('Weibull-Verteilung der Windgeschwindigkeiten')
plt.legend()
plt.show()
lcoe_data = cost_data.sort_values('LCOE')
lcoe_data = lcoe_data.head(nr_of_top)
turbine_names = lcoe_data.index
lcoe_values = lcoe_data['LCOE']
plt.figure(figsize=(10, 6))
plt.bar(turbine_names, lcoe_values)
plt.xlabel('Kleinwindenergieanlagenmodell')
plt.ylabel('LCOE in €/kWh')
plt.xticks(rotation=90)
plt.tight_layout()
plt.savefig('data/LCOE.png')
print('Weibull-Verteilungsfaktoren:')
print('Formfaktor (Shape):', shape)
print('Lagefaktor (Location):',(loc))
print('Skalenfaktor (Scale):', scale)