-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest_smooth_pc.py
140 lines (130 loc) · 5.55 KB
/
test_smooth_pc.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
from windpowerlib.wind_turbine import WindTurbine
from windpowerlib.wind_farm import WindFarm
from windpowerlib.power_output import summarized_power_curve
from windpowerlib import wind_farm_modelchain
from windpowerlib import power_output, tools
import pandas as pd
import numpy as np
import wind_farm_specifications
from tools import get_weather_data
from matplotlib import pyplot as plt
import os
import pickle
def smooth_pc(plot=True, print_out=False):
# initialise WindTurbine object
turbines = wind_farm_specifications.initialize_turbines(
['enerconE70', 'enerconE66'])
z0 = pd.Series([0.04, 0.04, 0.04])
block_width = 0.5
standard_deviation_method = 'turbulence_intensity'
# standard_deviation_method='Staffell'
# turbulence_intensity = (2.4 * 0.41) / np.log(135/z0.mean()) *
# np.exp(-135/500) # constant boundary layer
for turbine in turbines:
turbulence_intensity = tools.estimate_turbulence_intensity(
turbine.hub_height, z0.mean())
smoothed_power_curve = power_output.smooth_power_curve(
turbine.power_curve.wind_speed, turbine.power_curve['power'],
block_width=block_width,
standard_deviation_method=standard_deviation_method,
turbulence_intensity=turbulence_intensity)
if print_out:
print(turbine.power_curve)
print(smoothed_power_curve)
if plot:
fig = plt.figure()
a, = plt.plot(turbine.power_curve['wind_speed'],
turbine.power_curve['power']/1000, label='original')
b, = plt.plot(smoothed_power_curve['wind_speed'],
smoothed_power_curve['power']/1000, label='smoothed')
plt.ylabel('Power in kW')
plt.xlabel('Wind speed in m/s')
plt.title(turbine.object_name)
plt.legend(handles=[a, b])
fig.savefig(os.path.abspath(os.path.join(
os.path.dirname(__file__), '../Plots/power_curves',
'{0}_{1}_{2}.pdf'.format(turbine.object_name,
standard_deviation_method,
block_width))))
plt.close()
return smoothed_power_curve
# variables = pd.Series(data=np.arange(-15.0, 15.0, 0.5), index=np.arange(-15.0, 15.0, 0.5))
# wind_speed = 12
# # variables = np.arange(-15.0, 15.0, 0.5)
# gauss = tools.gaussian_distribution(variables, standard_deviation=0.15*wind_speed, mean=0)
# gauss.index = gauss.index + wind_speed
# gauss.plot()
# plt.show()
# print(gauss)
def summarized_pc(plot=False):
enerconE70 = {
'object_name': 'ENERCON E 70 2300',
'hub_height': 64,
'rotor_diameter': 71
}
enerconE66 = {
'object_name': 'ENERCON E 66 1800',
'hub_height': 65,
'rotor_diameter': 70
}
vestasV126 = {
'object_name': 'VESTAS V 126 3300',
'hub_height': 117,
'rotor_diameter': 126
}
e70 = WindTurbine(**enerconE70)
e66 = WindTurbine(**enerconE66)
v126 = WindTurbine(**vestasV126)
parameters = {'wind_turbine_fleet': [{'wind_turbine': e70,
'number_of_turbines': 13},
{'wind_turbine': e66,
'number_of_turbines': 4},
{'wind_turbine': v126,
'number_of_turbines': 2}],
'smoothing': True,
'density_correction': False,
'roughness_length': 0.4
}
power_curve_exp = 2
summarized_power_curve_df = summarized_power_curve(**parameters)
if plot:
plt.plot(summarized_power_curve_df['wind_speed'],
summarized_power_curve_df['power'])
plt.show()
plt.close()
return summarized_power_curve_df
def wind_farms_hub_height():
e70, e66 = wind_farm_specifications.initialize_turbines(['enerconE70',
'enerconE66'])
wf_3 = {
'object_name': 'wf_3',
'wind_turbine_fleet': [{'wind_turbine': e70,
'number_of_turbines': 13},
{'wind_turbine': e66,
'number_of_turbines': 4}],
'coordinates': [54.629167, 9.0625]}
wf = WindFarm(**wf_3)
return wf.mean_hub_height
def wind_farm_model_chain():
e70, e66 = wind_farm_specifications.initialize_turbines(['enerconE70',
'enerconE66'])
wf_3 = {
'object_name': 'wf_3',
'wind_turbine_fleet': [{'wind_turbine': e70,
'number_of_turbines': 13},
{'wind_turbine': e66,
'number_of_turbines': 4}],
'coordinates': [54.629167, 9.0625]}
wf = WindFarm(**wf_3)
filename_weather = os.path.join(os.path.dirname(__file__), 'dumps/weather',
'weather_df_MERRA_2015.p')
weather = get_weather_data(
'MERRA', wf.coordinates, pickle_load=True, filename=filename_weather,
year=2015, temperature_heights=[64, 65])
mc = wind_farm_modelchain.WindFarmModelChain(wf).run_model(weather)
return mc.power_output
if __name__ == "__main__":
# print(summarized_pc(plot=False))
# print(wind_farms_hub_height())
# smooth_pc(plot=True, print_out=False)
print(wind_farm_model_chain())