Skip to content

Commit 145a808

Browse files
authored
Merge pull request #33 from wind-python/restructure_turbine_data_reading
Restructure turbine data reading
2 parents 35eaeda + e35bcc9 commit 145a808

14 files changed

+203
-162
lines changed

README.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ If you have a working Python 3 environment, use pypi to install the latest windp
3333
The windpowerlib is designed for Python 3 and tested on Python >= 3.5.
3434
Please see the `installation page <http://oemof.readthedocs.io/en/stable/installation_and_setup.html>`_ of the oemof documentation for complete instructions on how to install python and a virtual environment on your operating system.
3535

36+
For retrieving power (coefficient) curves from the Open Energy Database (oedb) the python package requests will be installed with your windpowerlib installation. The windpowerlib was tested with requests version 2.20.1 but might work with lower versions.
37+
3638
Optional Packages
3739
~~~~~~~~~~~~~~~~~
3840

doc/getting_started.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ If you have a working Python 3 environment, use pypi to install the latest windp
3232
The windpowerlib is designed for Python 3 and tested on Python >= 3.5.
3333
Please see the `installation page <http://oemof.readthedocs.io/en/stable/installation_and_setup.html>`_ of the oemof documentation for complete instructions on how to install python and a virtual environment on your operating system.
3434

35+
For retrieving power (coefficient) curves from the Open Energy Database (oedb) the python package requests will be installed with your windpowerlib installation. The windpowerlib was tested with requests version 2.20.1 but might work with lower versions.
36+
3537
Optional Packages
3638
~~~~~~~~~~~~~~~~~
3739

doc/modelchain_example_notebook.ipynb

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,8 @@
188188
"12 Enercon E-82/2350 True True\n",
189189
"13 Enercon E-82/3000 True True\n",
190190
"14 Enercon E-92/2350 True True\n",
191-
"15 Enercon E48/800 True True\n"
191+
"15 Enercon E/126/7500 True False\n",
192+
"16 Enercon E48/800 True True\n"
192193
]
193194
}
194195
],
@@ -256,7 +257,7 @@
256257
"DEBUG:urllib3.connectionpool:Starting new HTTP connection (1): oep.iks.cs.ovgu.de:80\n",
257258
"DEBUG:urllib3.connectionpool:http://oep.iks.cs.ovgu.de:80 \"GET //api/v0/schema/model_draft/tables/openfred_windpower_powercurve/rows/ HTTP/1.1\" 301 438\n",
258259
"DEBUG:urllib3.connectionpool:Starting new HTTP connection (1): openenergy-platform.org:80\n",
259-
"DEBUG:urllib3.connectionpool:http://openenergy-platform.org:80 \"GET /api/v0/schema/model_draft/tables/openfred_windpower_powercurve/rows/ HTTP/1.1\" 200 149329\n",
260+
"DEBUG:urllib3.connectionpool:http://openenergy-platform.org:80 \"GET /api/v0/schema/model_draft/tables/openfred_windpower_powercurve/rows/ HTTP/1.1\" 200 150623\n",
260261
"INFO:root:Data base connection successful.\n"
261262
]
262263
}
@@ -284,12 +285,13 @@
284285
"source": [
285286
"# specification of wind turbine where power coefficient curve is provided\n",
286287
"# by a csv file\n",
288+
"source = 'data/example_power_coefficient_curves.csv'\n",
287289
"dummy_turbine = {\n",
288290
" 'name': 'DUMMY 1', # turbine type as in file #\n",
289291
" 'hub_height': 100, # in m\n",
290292
" 'rotor_diameter': 70, # in m\n",
291293
" 'fetch_curve': 'power_coefficient_curve', # fetch cp curve #\n",
292-
" 'data_source': 'example_power_coefficient_curves.csv' # data source\n",
294+
" 'data_source': source # data source\n",
293295
"}\n",
294296
"# initialize WindTurbine object\n",
295297
"dummy_turbine = WindTurbine(**dummy_turbine)"

doc/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ sphinx>=1.4
22
ipykernel
33
nbsphinx
44
pandas
5-
numpy
5+
requests

doc/whatsnew/v0-1-0.txt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
1-
v0.1.0 (January 16, 2019)
1+
v0.1.0 (January 17, 2019)
22
++++++++++++++++++++++++++++++++++
33

4+
ATTENTION: From v0.1.0 on power (coefficient) curves are provided by the Open Energy Database (oedb) instead of in csv files (v0.6.0 and lower) due to legal reasons.
5+
Use :py:func:`~wind_turbine.get_turbine_types` to check whether the turbine types you need are included in the database.
6+
If your turbine type is not included you can either add it to the `database <https://openenergy-platform.org/dataedit/view/model_draft/openfred_windpower_powercurve>`_
7+
(see `API tutorial <https://oep-data-interface.readthedocs.io/en/latest/api/how_to.html>`_) or use your own csv file.
8+
49
New classes
510
###########
611

example/modelchain_example.ipynb

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,8 @@
188188
"12 Enercon E-82/2350 True True\n",
189189
"13 Enercon E-82/3000 True True\n",
190190
"14 Enercon E-92/2350 True True\n",
191-
"15 Enercon E48/800 True True\n"
191+
"15 Enercon E/126/7500 True False\n",
192+
"16 Enercon E48/800 True True\n"
192193
]
193194
}
194195
],
@@ -256,7 +257,7 @@
256257
"DEBUG:urllib3.connectionpool:Starting new HTTP connection (1): oep.iks.cs.ovgu.de:80\n",
257258
"DEBUG:urllib3.connectionpool:http://oep.iks.cs.ovgu.de:80 \"GET //api/v0/schema/model_draft/tables/openfred_windpower_powercurve/rows/ HTTP/1.1\" 301 438\n",
258259
"DEBUG:urllib3.connectionpool:Starting new HTTP connection (1): openenergy-platform.org:80\n",
259-
"DEBUG:urllib3.connectionpool:http://openenergy-platform.org:80 \"GET /api/v0/schema/model_draft/tables/openfred_windpower_powercurve/rows/ HTTP/1.1\" 200 149329\n",
260+
"DEBUG:urllib3.connectionpool:http://openenergy-platform.org:80 \"GET /api/v0/schema/model_draft/tables/openfred_windpower_powercurve/rows/ HTTP/1.1\" 200 150623\n",
260261
"INFO:root:Data base connection successful.\n"
261262
]
262263
}
@@ -284,13 +285,13 @@
284285
"source": [
285286
"# specification of wind turbine where power coefficient curve is provided\n",
286287
"# by a csv file\n",
287-
"csv_file = '../example/data/example_power_coefficient_curves.csv'\n",
288+
"source = 'data/example_power_coefficient_curves.csv'\n",
288289
"dummy_turbine = {\n",
289290
" 'name': 'DUMMY 1', # turbine type as in file #\n",
290291
" 'hub_height': 100, # in m\n",
291292
" 'rotor_diameter': 70, # in m\n",
292293
" 'fetch_curve': 'power_coefficient_curve', # fetch cp curve #\n",
293-
" 'data_source': csv_file # data source\n",
294+
" 'data_source': source # data source\n",
294295
"}\n",
295296
"# initialize WindTurbine object\n",
296297
"dummy_turbine = WindTurbine(**dummy_turbine)"

example/modelchain_example.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,6 @@ def initialize_wind_turbines():
135135
# by a csv file
136136
csv_file = os.path.join(os.path.dirname(__file__), 'data',
137137
'example_power_coefficient_curves.csv')
138-
# todo adapt in jupyter notebook!!!
139138
dummy_turbine = {
140139
'name': 'DUMMY 1', # turbine type as in file #
141140
'hub_height': 100, # in m

setup.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,5 @@ def read(fname):
1616
'windpowerlib': [os.path.join('data', '*.csv')]},
1717
long_description=read('README.rst'),
1818
zip_safe=False,
19-
install_requires=['numpy >= 1.7.0',
20-
'pandas >= 0.13.1',
19+
install_requires=['pandas >= 0.19.1',
2120
'requests'])

tests/test_wind_turbine.py

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
1-
import pandas as pd
2-
from pandas.util.testing import assert_series_equal
31
import pytest
2+
import os
43

5-
from windpowerlib.wind_turbine import read_turbine_data, WindTurbine
4+
from windpowerlib.wind_turbine import (get_turbine_data_from_file, WindTurbine,
5+
get_turbine_types)
66

77
class TestWindTurbine:
88

99
def test_error_raising(self):
10+
source = os.path.join(os.path.dirname(__file__), '../example/data',
11+
'example_power_curves.csv')
1012
self.test_turbine_data = {'hub_height': 100,
1113
'rotor_diameter': 80,
1214
'name': 'turbine_not_in_file',
1315
'fetch_curve': 'power_curve',
14-
'data_source': 'example_power_curves.csv'}
15-
# Raise system exit
16+
'data_source': source}
17+
# Raise system exit due to turbine type not in file
1618
with pytest.raises(SystemExit):
1719
test_turbine = WindTurbine(**self.test_turbine_data)
1820

@@ -22,8 +24,17 @@ def test_error_raising(self):
2224
with pytest.raises(ValueError):
2325
test_turbine = WindTurbine(**self.test_turbine_data)
2426

25-
def test_read_turbine_data(self):
27+
# Raise KeyError due to turbine type not in oedb
28+
self.test_turbine_data['fetch_curve'] = 'power_curve'
29+
self.test_turbine_data['data_source'] = 'oedb'
30+
with pytest.raises(KeyError):
31+
test_turbine = WindTurbine(**self.test_turbine_data)
32+
33+
34+
def test_get_turbine_data_from_file(self):
2635
# Raise FileNotFoundError due to missing
2736
with pytest.raises(FileNotFoundError):
28-
read_turbine_data(filename='not_existent')
37+
get_turbine_data_from_file(turbine_type='...', file_='not_existent')
2938

39+
def test_get_turbine_types(self):
40+
get_turbine_types(print_out=False)

windpowerlib/modelchain.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ def wind_speed_hub(self, weather_df):
318318

319319
def calculate_power_output(self, wind_speed_hub, density_hub):
320320
r"""
321-
Calculates the power output of the wind turbine. # todo power plant output????
321+
Calculates the power output of the wind power plant.
322322
323323
The method specified by the parameter `power_output_model` is used.
324324
@@ -358,7 +358,7 @@ def calculate_power_output(self, wind_speed_hub, density_hub):
358358
self.power_plant.power_coefficient_curve[
359359
'wind_speed'],
360360
self.power_plant.power_coefficient_curve[
361-
'power coefficient'],
361+
'power_coefficient'],
362362
self.power_plant.rotor_diameter, density_hub))
363363
else:
364364
raise ValueError("'{0}' is an invalid value. ".format(

0 commit comments

Comments
 (0)