Skip to content

Commit 2a34fc9

Browse files
Birgit SchachlerBirgit Schachler
authored andcommitted
Merge branch 'dev' into features/revise_example
Conflicts: example/basic_example.py example/weather.csv
2 parents 0fc4757 + 3c98e44 commit 2a34fc9

File tree

12 files changed

+162
-160
lines changed

12 files changed

+162
-160
lines changed

doc/conf.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414

1515
import sys
1616
import os
17+
import sphinx
18+
from sphinx.errors import VersionRequirementError
1719

1820
# If extensions (or modules to document with autodoc) are in another directory,
1921
# add these directories to sys.path here. If the directory is relative to the
@@ -23,7 +25,10 @@
2325
# -- General configuration ------------------------------------------------
2426

2527
# If your documentation needs a minimal Sphinx version, state it here.
26-
#needs_sphinx = '1.0'
28+
needs_sphinx = '1.4.3'
29+
if needs_sphinx > sphinx.__display_version__:
30+
message = 'This project needs at least Sphinx v%s' % needs_sphinx
31+
raise VersionRequirementError(message)
2732

2833
# Add any Sphinx extension module names here, as strings. They can be
2934
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom

example/basic_example.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
logging.getLogger().setLevel(logging.DEBUG)
2525

2626

27-
def read_weather_data(filename, datetime_column='Unnamed: 0',
27+
def read_weather_data(filename, datetime_column='time_index',
2828
**kwargs):
2929
r"""
3030
Fetches weather data from a file.
@@ -61,7 +61,6 @@ def read_weather_data(filename, datetime_column='Unnamed: 0',
6161

6262
# Read weather data from csv
6363
weather = read_weather_data('weather.csv')
64-
#weather.index.name = ''
6564

6665
# Specification of the weather data set CoastDat2 (example data)
6766
data_height = {
@@ -75,14 +74,14 @@ def read_weather_data(filename, datetime_column='Unnamed: 0',
7574
enerconE126 = {
7675
'hub_height': 135,
7776
'd_rotor': 127,
78-
'fetch_curve': 'P', # 'P' for p-curve and 'cp' for cp-curve
77+
'fetch_curve': 'p', # 'p' for p-curve and 'cp' for cp-curve
7978
'turbine_name': 'ENERCON E 126 7500'} # Turbine name as in register. Use
8079
# wind_turbine.get_turbine_types()
8180
# for a full list.
8281
vestasV90 = {
8382
'hub_height': 105,
8483
'd_rotor': 90,
85-
'fetch_curve': 'P',
84+
'fetch_curve': 'p',
8685
'turbine_name': 'VESTAS V 90 3000'}
8786

8887
# Initialize WindTurbine objects

example/weather.csv

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
,pressure,temp_air,v_wind,z0,temp_air_2,v_wind_2
1+
time_index,pressure,temp_air,v_wind,z0,temp_air_2,v_wind_2
22
2010-01-01 00:00:00+01:00,98405.7,267.6,5.32697,0.15,267.57,7.80697
33
2010-01-01 01:00:00+01:00,98382.7,267.6,5.46199,0.15,267.55,7.86199
44
2010-01-01 02:00:00+01:00,98362.9,267.61,5.67899,0.15,267.54,8.59899

windpowerlib/data/cp_curves.csv

Lines changed: 91 additions & 91 deletions
Large diffs are not rendered by default.

windpowerlib/density.py

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,9 @@ def temperature_gradient(temp_air, temp_height, hub_height):
4242
with:
4343
T: temperature [K], h: height [m]
4444
45-
:math:`h_{T,data}` is the height in which the temperature is measured.
45+
:math:`h_{T,data}` is the height in which the temperature :math:`T_{air}`
46+
is measured and :math:`T_{hub}` is the temperature at hub height
47+
:math:`h_{hub}` of the wind turbine.
4648
4749
Assumptions:
4850
@@ -62,7 +64,7 @@ def temperature_interpol(temp_air_1, temp_air_2,
6264
r"""
6365
Calculates the temperature at hub height by inter- or extrapolation.
6466
65-
This fuction is carried out when the parameter `temperature_model` of an
67+
This function is carried out when the parameter `temperature_model` of an
6668
instance of the :class:`~.modelchain.ModelChain` class
6769
is 'interpolation'.
6870
@@ -109,19 +111,19 @@ def rho_barometric(pressure, pressure_height, hub_height, temp_hub):
109111
Calculates the density of air at hub height using the barometric height
110112
equation.
111113
112-
This fuction is carried out when the parameter `rho_model` of an instance
114+
This function is carried out when the parameter `rho_model` of an instance
113115
of the :class:`~.modelchain.ModelChain` class is 'barometric'.
114116
115117
Parameters
116118
----------
117119
pressure : pandas.Series or array
118-
Pressure in Pa.
120+
Air pressure in Pa.
119121
pressure_height : float
120122
Height in m for which the parameter `pressure` applies.
121123
hub_height : float
122124
Hub height of wind turbine in m.
123125
temp_hub : pandas.Series or array
124-
Temperature at hub height in K.
126+
Air temperature at hub height in K.
125127
126128
Returns
127129
-------
@@ -143,7 +145,7 @@ def rho_barometric(pressure, pressure_height, hub_height, temp_hub):
143145
:math:`h_{p,data}` is the height of the measurement or model data for
144146
pressure, :math:`p_0` the ambient air pressure, :math:`\rho_0` the ambient
145147
density of air, :math:`T_0` the ambient temperature and :math:`T_{hub}` the
146-
temperature at hub height.
148+
temperature at hub height :math:`h_{hub}`.
147149
148150
Assumptions:
149151
@@ -165,19 +167,19 @@ def rho_ideal_gas(pressure, pressure_height, hub_height, temp_hub):
165167
r"""
166168
Calculates the density of air at hub height using the ideal gas equation.
167169
168-
This fuction is carried out when the parameter `rho_model` of an instance
170+
This function is carried out when the parameter `rho_model` of an instance
169171
of the :class:`~.modelchain.ModelChain` class is 'ideal_gas'.
170172
171173
Parameters
172174
----------
173175
pressure : pandas.Series or array
174-
Pressure in Pa.
176+
Air pressure in Pa.
175177
pressure_height : float
176178
Height in m for which the parameter `pressure` applies.
177179
hub_height : float
178180
Hub height of wind turbine in m.
179181
temp_hub : pandas.Series or array
180-
Temperature at hub height in K.
182+
Air temperature at hub height in K.
181183
182184
Returns
183185
-------
@@ -198,8 +200,10 @@ def rho_ideal_gas(pressure, pressure_height, hub_height, temp_hub):
198200
with:
199201
T: temperature [K], :math:`\rho`: density [kg/m³], p: pressure [Pa]
200202
201-
:math:`R_s` is the specific gas constant of dry air (287.058 J/(kg*K)) and
202-
:math:`p_{hub}` is the pressure at hub height.
203+
:math:`h_{p,data}` is the height of the measurement or model data for
204+
pressure, :math:`R_s` is the specific gas constant of dry air
205+
(287.058 J/(kg*K)) and :math:`p_{hub}` is the pressure at hub height
206+
:math:`h_{hub}`.
203207
204208
References
205209
----------

windpowerlib/modelchain.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,8 @@ def run_model(self, weather, data_height):
345345
346346
"""
347347
v_wind = self.v_wind_hub(weather, data_height)
348-
rho_hub = self.rho_hub(weather, data_height)
348+
rho_hub = None if (self.power_output_model=='p_values' and
349+
self.density_corr==False) \
350+
else self.rho_hub(weather, data_height)
349351
self.power_output = self.turbine_power_output(v_wind, rho_hub)
350352
return self

windpowerlib/power_output.py

Lines changed: 18 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,6 @@ def cp_curve(v_wind, rho_hub, d_rotor, cp_values):
6060
6161
"""
6262
# cp time series
63-
# TODO introduce new parameter v_cutout to allow for power output above
64-
# maximum wind speed from power coefficient curve (maximum power output
65-
# must be limited)
6663
cp_series = np.interp(v_wind, cp_values.index, cp_values.cp,
6764
left=0, right=0)
6865
power_output = (1 / 8 * rho_hub * d_rotor ** 2 * np.pi
@@ -72,9 +69,8 @@ def cp_curve(v_wind, rho_hub, d_rotor, cp_values):
7269
series_index = v_wind.index
7370
except AttributeError:
7471
series_index = range(1, len(power_output)+1)
75-
power_output = pd.Series(data=power_output, index=series_index,
76-
name='feedin_wind_turbine')
77-
return power_output
72+
return pd.Series(data=power_output, index=series_index,
73+
name='feedin_wind_turbine')
7874

7975

8076
def cp_curve_density_corr(v_wind, rho_hub, d_rotor, cp_values):
@@ -116,7 +112,7 @@ def cp_curve_density_corr(v_wind, rho_hub, d_rotor, cp_values):
116112
p_values = (1 / 8 * 1.225 * d_rotor ** 2 * np.pi *
117113
np.power(cp_values.index, 3) * cp_values.cp)
118114
p_values = pd.DataFrame(data=np.array(p_values), index=cp_values.index,
119-
columns=['P'])
115+
columns=['p'])
120116
return p_curve_density_corr(v_wind, rho_hub, p_values)
121117

122118

@@ -133,33 +129,30 @@ def p_curve(p_values, v_wind):
133129
p_values : pandas.DataFrame
134130
Power curve of the wind turbine.
135131
Indices are the wind speeds of the power curve in m/s, the
136-
corresponding power values in W are in the column 'P'.
132+
corresponding power values in W are in the column 'p'.
137133
v_wind : pandas.Series or array
138134
Wind speed at hub height in m/s.
139135
140136
Returns
141137
-------
142138
power_output : pandas.Series
143-
Electrical power output of the wind turbine in W.
139+
Electrical power output of the wind turbine in the unit of `p_values`.
144140
145141
Notes
146142
-------
147143
It is assumed that the power output for wind speeds above the maximum
148144
wind speed given in the power curve is zero.
149145
150146
"""
151-
# TODO introduce new parameter v_cutout to allow for power output above
152-
# maximum wind speed from power curve
153-
power_output = np.interp(v_wind, p_values.index, p_values.P,
147+
power_output = np.interp(v_wind, p_values.index, p_values.p,
154148
left=0, right=0)
155149
# Set index for time series
156150
try:
157151
series_index = v_wind.index
158152
except AttributeError:
159153
series_index = range(1, len(power_output)+1)
160-
power_output = pd.Series(data=power_output, index=series_index,
161-
name='feedin_wind_turbine')
162-
return power_output
154+
return pd.Series(data=power_output, index=series_index,
155+
name='feedin_wind_turbine')
163156

164157

165158
def p_curve_density_corr(v_wind, rho_hub, p_values):
@@ -178,13 +171,13 @@ def p_curve_density_corr(v_wind, rho_hub, p_values):
178171
Density of air at hub height in kg/m³.
179172
p_values : pandas.DataFrame
180173
Power curve of the wind turbine.
181-
The indices are the corresponding wind speeds of the power curve, the
182-
power values containing column is called 'P'.
174+
Indices are the wind speeds of the power curve in m/s, the
175+
corresponding power values in W are in the column 'p'.
183176
184177
Returns
185178
-------
186179
power_output : pandas.Series
187-
Electrical power output of the wind turbine in W.
180+
Electrical power output of the wind turbine in the unit of `p_values`.
188181
189182
Notes
190183
-----
@@ -204,9 +197,11 @@ def p_curve_density_corr(v_wind, rho_hub, p_values):
204197
v: wind speed [m/s], :math:`\rho`: density [kg/m³]
205198
206199
:math:`v_{std}` is the standard wind speed in the power curve
207-
(:math:`v_{std}`, :math:`P_{std}`).
200+
(:math:`v_{std}`, :math:`P_{std}`),
208201
:math:`v_{site}` is the density corrected wind speed for the power curve
209-
(:math:`v_{site}`, :math:`P_{std}`).
202+
(:math:`v_{site}`, :math:`P_{std}`),
203+
:math:`\rho_0` is the ambient density (1.225 kg/m³)
204+
and :math:`\rho_{site}` the density at site conditions (and hub height).
210205
211206
It is assumed that the power output for wind speeds above the maximum
212207
wind speed given in the power curve is zero.
@@ -224,20 +219,17 @@ def p_curve_density_corr(v_wind, rho_hub, p_values):
224219
at Reiner Lemoine Institute, 2014, p. 13
225220
226221
"""
227-
# TODO introduce new parameter v_cutout to allow for power output above
228-
# maximum wind speed from power curve
229222
power_output = [(np.interp(v_wind[i],
230223
p_values.index * (1.225 / rho_hub[i])**(
231224
np.interp(p_values.index,
232225
[7.5, 12.5], [1/3, 2/3])),
233-
p_values.P, left=0, right=0))
226+
p_values.p, left=0, right=0))
234227
for i in range(len(v_wind))]
235228

236229
# Set index for time series
237230
try:
238231
series_index = v_wind.index
239232
except AttributeError:
240233
series_index = range(1, len(power_output)+1)
241-
power_output = pd.Series(data=power_output, index=series_index,
242-
name='feedin_wind_turbine')
243-
return power_output
234+
return pd.Series(data=power_output, index=series_index,
235+
name='feedin_wind_turbine')

windpowerlib/tests/modelchain_tests.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def setUpClass(self):
2929
self.test_turbine = {'hub_height': 100,
3030
'd_rotor': 80,
3131
'turbine_name': 'ENERCON E 126 7500',
32-
'fetch_curve': 'P'}
32+
'fetch_curve': 'p'}
3333
self.test_wt = wt.WindTurbine(**self.test_turbine)
3434
self.test_modelchain = {'wind_model': 'hellman',
3535
'rho_model': 'barometric',
@@ -91,14 +91,14 @@ def test_rho_hub(self):
9191

9292
def test_run_model(self):
9393
# Test with default parameters of modelchain (power curve)
94-
power_output_exp = pd.Series(data=[1731887.39768, 3820152.27489])
94+
power_output_exp = pd.Series(data=[1731.8874, 3820.15227])
9595
test_mc = mc.ModelChain(self.test_wt)
9696
test_mc.run_model(self.weather, self.data_height)
9797
assert_series_equal(test_mc.power_output, power_output_exp)
9898

9999
def test_different_models(self):
100100
# Test with density corrected power curve
101-
power_output_exp = pd.Series(data=[1430312.76771, 3746075.21279])
101+
power_output_exp = pd.Series(data=[1430.31277, 3746.07521])
102102
self.test_modelchain['density_corr'] = True
103103
test_wt = wt.WindTurbine(**self.test_turbine)
104104
test_mc = mc.ModelChain(test_wt, **self.test_modelchain)

windpowerlib/tests/power_output_tests.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def setUpClass(self):
1515
self.d_rotor = 80
1616
self.cp_values = pd.DataFrame(data={'cp': [0.3, 0.4, 0.5]},
1717
index=[4.0, 5.0, 6.0])
18-
self.p_values = pd.DataFrame(data={'P': [300, 400, 500]},
18+
self.p_values = pd.DataFrame(data={'p': [300, 400, 500]},
1919
index=[4.0, 5.0, 6.0])
2020

2121
def test_cp_curve(self):

0 commit comments

Comments
 (0)