Skip to content

Commit

Permalink
Merge c9a44ef into 35eaeda
Browse files Browse the repository at this point in the history
  • Loading branch information
SabineHaas committed Jan 17, 2019
2 parents 35eaeda + c9a44ef commit c52f3f6
Show file tree
Hide file tree
Showing 6 changed files with 144 additions and 112 deletions.
8 changes: 5 additions & 3 deletions doc/modelchain_example_notebook.ipynb
Expand Up @@ -188,7 +188,8 @@
"12 Enercon E-82/2350 True True\n",
"13 Enercon E-82/3000 True True\n",
"14 Enercon E-92/2350 True True\n",
"15 Enercon E48/800 True True\n"
"15 Enercon E/126/7500 True False\n",
"16 Enercon E48/800 True True\n"
]
}
],
Expand Down Expand Up @@ -256,7 +257,7 @@
"DEBUG:urllib3.connectionpool:Starting new HTTP connection (1): oep.iks.cs.ovgu.de:80\n",
"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",
"DEBUG:urllib3.connectionpool:Starting new HTTP connection (1): openenergy-platform.org:80\n",
"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",
"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",
"INFO:root:Data base connection successful.\n"
]
}
Expand Down Expand Up @@ -284,12 +285,13 @@
"source": [
"# specification of wind turbine where power coefficient curve is provided\n",
"# by a csv file\n",
"source = 'data/example_power_coefficient_curves.csv'\n",
"dummy_turbine = {\n",
" 'name': 'DUMMY 1', # turbine type as in file #\n",
" 'hub_height': 100, # in m\n",
" 'rotor_diameter': 70, # in m\n",
" 'fetch_curve': 'power_coefficient_curve', # fetch cp curve #\n",
" 'data_source': 'example_power_coefficient_curves.csv' # data source\n",
" 'data_source': source # data source\n",
"}\n",
"# initialize WindTurbine object\n",
"dummy_turbine = WindTurbine(**dummy_turbine)"
Expand Down
9 changes: 5 additions & 4 deletions example/modelchain_example.ipynb
Expand Up @@ -188,7 +188,8 @@
"12 Enercon E-82/2350 True True\n",
"13 Enercon E-82/3000 True True\n",
"14 Enercon E-92/2350 True True\n",
"15 Enercon E48/800 True True\n"
"15 Enercon E/126/7500 True False\n",
"16 Enercon E48/800 True True\n"
]
}
],
Expand Down Expand Up @@ -256,7 +257,7 @@
"DEBUG:urllib3.connectionpool:Starting new HTTP connection (1): oep.iks.cs.ovgu.de:80\n",
"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",
"DEBUG:urllib3.connectionpool:Starting new HTTP connection (1): openenergy-platform.org:80\n",
"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",
"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",
"INFO:root:Data base connection successful.\n"
]
}
Expand Down Expand Up @@ -284,13 +285,13 @@
"source": [
"# specification of wind turbine where power coefficient curve is provided\n",
"# by a csv file\n",
"csv_file = '../example/data/example_power_coefficient_curves.csv'\n",
"source = 'data/example_power_coefficient_curves.csv'\n",
"dummy_turbine = {\n",
" 'name': 'DUMMY 1', # turbine type as in file #\n",
" 'hub_height': 100, # in m\n",
" 'rotor_diameter': 70, # in m\n",
" 'fetch_curve': 'power_coefficient_curve', # fetch cp curve #\n",
" 'data_source': csv_file # data source\n",
" 'data_source': source # data source\n",
"}\n",
"# initialize WindTurbine object\n",
"dummy_turbine = WindTurbine(**dummy_turbine)"
Expand Down
1 change: 0 additions & 1 deletion example/modelchain_example.py
Expand Up @@ -135,7 +135,6 @@ def initialize_wind_turbines():
# by a csv file
csv_file = os.path.join(os.path.dirname(__file__), 'data',
'example_power_coefficient_curves.csv')
# todo adapt in jupyter notebook!!!
dummy_turbine = {
'name': 'DUMMY 1', # turbine type as in file #
'hub_height': 100, # in m
Expand Down
25 changes: 18 additions & 7 deletions tests/test_wind_turbine.py
@@ -1,18 +1,20 @@
import pandas as pd
from pandas.util.testing import assert_series_equal
import pytest
import os

from windpowerlib.wind_turbine import read_turbine_data, WindTurbine
from windpowerlib.wind_turbine import (get_turbine_data_from_file, WindTurbine,
get_turbine_types)

class TestWindTurbine:

def test_error_raising(self):
source = os.path.join(os.path.dirname(__file__), '../example/data',
'example_power_curves.csv')
self.test_turbine_data = {'hub_height': 100,
'rotor_diameter': 80,
'name': 'turbine_not_in_file',
'fetch_curve': 'power_curve',
'data_source': 'example_power_curves.csv'}
# Raise system exit
'data_source': source}
# Raise system exit due to turbine type not in file
with pytest.raises(SystemExit):
test_turbine = WindTurbine(**self.test_turbine_data)

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

def test_read_turbine_data(self):
# Raise KeyError due to turbine type not in oedb
self.test_turbine_data['fetch_curve'] = 'power_curve'
self.test_turbine_data['data_source'] = 'oedb'
with pytest.raises(KeyError):
test_turbine = WindTurbine(**self.test_turbine_data)


def test_get_turbine_data_from_file(self):
# Raise FileNotFoundError due to missing
with pytest.raises(FileNotFoundError):
read_turbine_data(filename='not_existent')
get_turbine_data_from_file(turbine_type='...', file_='not_existent')

def test_get_turbine_types(self):
get_turbine_types(print_out=False)
2 changes: 1 addition & 1 deletion windpowerlib/modelchain.py
Expand Up @@ -358,7 +358,7 @@ def calculate_power_output(self, wind_speed_hub, density_hub):
self.power_plant.power_coefficient_curve[
'wind_speed'],
self.power_plant.power_coefficient_curve[
'power coefficient'],
'power_coefficient'],
self.power_plant.rotor_diameter, density_hub))
else:
raise ValueError("'{0}' is an invalid value. ".format(
Expand Down

0 comments on commit c52f3f6

Please sign in to comment.