Skip to content

Commit 7349e4f

Browse files
committed
Merge branch 'dev' into features/wind_farms_and_clusters
2 parents 1edcb6a + cade8cd commit 7349e4f

File tree

5 files changed

+49
-30
lines changed

5 files changed

+49
-30
lines changed

example/basic_example.ipynb

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -199,13 +199,14 @@
199199
"outputs": [],
200200
"source": [
201201
"# specification of wind turbine where power curve is provided\n",
202-
"# if you want to use the power coefficient curve add\n",
203-
"# {'fetch_curve': 'power_coefficient_curve'} to the dictionary\n",
202+
"# if you want to use the power coefficient curve change the value of\n",
203+
"# 'fetch_curve' to 'power_coefficient_curve'\n",
204204
"enerconE126 = {\n",
205205
" 'turbine_name': 'ENERCON E 126 7500', # turbine name as in register\n",
206206
" 'hub_height': 135, # in m\n",
207-
" 'rotor_diameter': 127 # in m\n",
208-
" }\n",
207+
" 'rotor_diameter': 127, # in m\n",
208+
" 'fetch_curve': 'power_curve' # fetch power curve\n",
209+
"}\n",
209210
"# initialise WindTurbine object\n",
210211
"e126 = WindTurbine(**enerconE126)"
211212
]

example/basic_example.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
except ImportError:
1515
plt = None
1616

17-
from windpowerlib.modelchain import ModelChain
18-
from windpowerlib.wind_turbine import WindTurbine
17+
from windpowerlib import ModelChain
18+
from windpowerlib import WindTurbine
1919

2020
# You can use the logging package to get logging messages from the windpowerlib
2121
# Change the logging level if you want more or less messages
@@ -110,12 +110,13 @@ def initialise_wind_turbines():
110110
my_turbine = WindTurbine(**myTurbine)
111111

112112
# specification of wind turbine where power curve is provided
113-
# if you want to use the power coefficient curve add
114-
# {'fetch_curve': 'power_coefficient_curve'} to the dictionary
113+
# if you want to use the power coefficient curve change the value of
114+
# 'fetch_curve' to 'power_coefficient_curve'
115115
enerconE126 = {
116116
'turbine_name': 'ENERCON E 126 7500', # turbine name as in register
117117
'hub_height': 135, # in m
118-
'rotor_diameter': 127 # in m
118+
'rotor_diameter': 127, # in m
119+
'fetch_curve': 'power_curve' # fetch power curve
119120
}
120121
# initialise WindTurbine object
121122
e126 = WindTurbine(**enerconE126)

tests/test_modelchain.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ class TestModelChain:
1313
def setup_class(self):
1414
self.test_turbine = {'hub_height': 100,
1515
'rotor_diameter': 80,
16-
'object_name': 'ENERCON E 126 7500'}
16+
'object_name': 'ENERCON E 126 7500',
17+
'fetch_curve': 'power_curve'}
1718

1819
def test_temperature_hub(self):
1920
# Test modelchain with temperature_model='linear_gradient'

windpowerlib/__init__.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
11
__copyright__ = "Copyright oemof developer group"
22
__license__ = "GPLv3"
3-
__version__ = '0.0.6'
3+
__version__ = '0.0.6'
4+
5+
from windpowerlib import density
6+
from windpowerlib import modelchain
7+
from windpowerlib import power_output
8+
from windpowerlib import temperature
9+
from windpowerlib import tools
10+
from windpowerlib import wind_speed
11+
from windpowerlib import wind_turbine
12+
13+
from windpowerlib.wind_turbine import WindTurbine
14+
from windpowerlib.modelchain import ModelChain

windpowerlib/wind_turbine.py

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -31,18 +31,18 @@ class WindTurbine(object):
3131
Diameter of the rotor in m.
3232
power_coefficient_curve : None, pandas.DataFrame or dictionary
3333
Power coefficient curve of the wind turbine. DataFrame/dictionary must
34-
have 'wind_speed' and 'power coefficient' columns/keys with wind
35-
speeds in m/s and the corresponding power coefficients. Default: None.
34+
have 'wind_speed' and 'values' columns/keys with wind speeds in m/s
35+
and the corresponding power coefficients. Default: None.
3636
power_curve : None, pandas.DataFrame or dictionary
3737
Power curve of the wind turbine. DataFrame/dictionary must have
38-
'wind_speed' and 'power' columns/keys with wind speeds in m/s and the
38+
'wind_speed' and 'values' columns/keys with wind speeds in m/s and the
3939
corresponding power curve value in W. Default: None.
4040
nominal_power : None or float
4141
The nominal output of the wind turbine in W.
4242
fetch_curve : string
43-
Parameter to specify whether the power or power coefficient curve
43+
Parameter to specify whether a power or power coefficient curve
4444
should be retrieved from the provided turbine data. Valid options are
45-
'power_curve' and 'power_coefficient_curve'. Default: 'power_curve'.
45+
'power_curve' and 'power_coefficient_curve'. Default: None.
4646
4747
Attributes
4848
----------
@@ -56,37 +56,45 @@ class WindTurbine(object):
5656
Diameter of the rotor in m.
5757
power_coefficient_curve : None, pandas.DataFrame or dictionary
5858
Power coefficient curve of the wind turbine. DataFrame/dictionary must
59-
have 'wind_speed' and 'power coefficient' columns/keys with wind speeds
60-
in m/s and the corresponding power coefficients. Default: None.
59+
have 'wind_speed' and 'values' columns/keys with wind speeds in m/s
60+
and the corresponding power coefficients. Default: None.
6161
power_curve : None, pandas.DataFrame or dictionary
6262
Power curve of the wind turbine. DataFrame/dictionary must have
63-
'wind_speed' and 'power' columns/keys with wind speeds in m/s and the
63+
'wind_speed' and 'values' columns/keys with wind speeds in m/s and the
6464
corresponding power curve value in W. Default: None.
6565
nominal_power : None or float
6666
The nominal output of the wind turbine in W.
6767
fetch_curve : string
68-
Parameter to specify whether the power or power coefficient curve
68+
Parameter to specify whether a power or power coefficient curve
6969
should be retrieved from the provided turbine data. Valid options are
70-
'power_curve' and 'power_coefficient_curve'. Default: 'power_curve'.
70+
'power_curve' and 'power_coefficient_curve'. Default: None.
7171
power_output : pandas.Series
7272
The calculated power output of the wind turbine.
7373
74+
Notes
75+
------
76+
Your wind turbine object should have a power coefficient or power curve.
77+
You can set the `fetch_curve` parameter if you don't want to provide one
78+
yourself but want to automatically fetch a curve from the data set
79+
provided along with the windpowerlib.
80+
7481
Examples
7582
--------
7683
>>> from windpowerlib import wind_turbine
7784
>>> enerconE126 = {
7885
... 'hub_height': 135,
7986
... 'rotor_diameter': 127,
80-
... 'object_name': 'ENERCON E 126 7500'}
87+
... 'object_name': 'ENERCON E 126 7500',
88+
... 'fetch_curve': 'power_curve'}
8189
>>> e126 = wind_turbine.WindTurbine(**enerconE126)
8290
>>> print(e126.nominal_power)
8391
7500000
8492
8593
"""
8694

87-
def __init__(self, object_name, hub_height, rotor_diameter=None,
95+
def __init__(self, turbine_name, hub_height, rotor_diameter=None,
8896
power_coefficient_curve=None, power_curve=None,
89-
nominal_power=None, fetch_curve='power_curve'):
97+
nominal_power=None, fetch_curve=None):
9098

9199
self.object_name = object_name
92100
self.hub_height = hub_height
@@ -101,6 +109,7 @@ def __init__(self, object_name, hub_height, rotor_diameter=None,
101109
if self.power_coefficient_curve is None and self.power_curve is None:
102110
self.fetch_turbine_data()
103111

112+
# ToDo: Have fetch_curve as an input to this function.
104113
def fetch_turbine_data(self):
105114
r"""
106115
Fetches data of the requested wind turbine.
@@ -126,7 +135,7 @@ def fetch_turbine_data(self):
126135
... 'object_name': 'ENERCON E 126 7500',
127136
... 'fetch_curve': 'power_coefficient_curve'}
128137
>>> e126 = wind_turbine.WindTurbine(**enerconE126)
129-
>>> print(e126.power_coefficient_curve['power coefficient'][5])
138+
>>> print(e126.power_coefficient_curve['values'][5])
130139
0.423
131140
>>> print(e126.nominal_power)
132141
7500000
@@ -170,11 +179,7 @@ def restructure_data():
170179
data = np.vstack((data, np.array(
171180
[float(col), float(wpp_df[col])])))
172181
data = np.delete(data, 0, 0)
173-
if self.fetch_curve == 'power_curve':
174-
df = pd.DataFrame(data, columns=['wind_speed', 'power'])
175-
if self.fetch_curve == 'power_coefficient_curve':
176-
df = pd.DataFrame(data, columns=['wind_speed',
177-
'power coefficient'])
182+
df = pd.DataFrame(data, columns=['wind_speed', 'values'])
178183
nominal_power = wpp_df['p_nom'].iloc[0]
179184
return df, nominal_power
180185
if self.fetch_curve == 'power_curve':

0 commit comments

Comments
 (0)