Skip to content

Commit 7d8fb04

Browse files
committed
Merge master
2 parents 8045224 + 5471557 commit 7d8fb04

File tree

4 files changed

+53
-70
lines changed

4 files changed

+53
-70
lines changed

doc/conf.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
# General information about the project.
6262
project = u'windpowerlib'
6363
copyright = u'2016, oemof developer group'
64-
author = u'Uwe Krien, oemof developing group'
64+
author = u'oemof developing group'
6565

6666
import windpowerlib
6767

@@ -285,7 +285,7 @@
285285

286286
# Bibliographic Dublin Core info.
287287
epub_title = u'windpowerlib'
288-
epub_author = u'Uwe Krien, oemof developing group'
288+
epub_author = u'oemof developing group'
289289
epub_publisher = u'oemof developing group'
290290
epub_copyright = u'2016, oemof developing group'
291291

example/test_basic_example.py

Lines changed: 0 additions & 16 deletions
This file was deleted.

example/test_examples.py

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import os
2+
import subprocess
3+
import tempfile
4+
import nbformat
5+
6+
from example import basic_example as be
7+
from numpy.testing import assert_allclose
8+
9+
10+
class TestExamples:
11+
12+
def test_basic_example_flh(self):
13+
# tests full load hours
14+
weather = be.get_weather_data('weather.csv')
15+
my_turbine, e126 = be.initialise_wind_turbines()
16+
be.calculate_power_output(weather, my_turbine, e126)
17+
18+
assert_allclose(1766.6870, (e126.power_output.sum() /
19+
e126.nominal_power), 0.01)
20+
assert_allclose(1882.7567, (my_turbine.power_output.sum() /
21+
my_turbine.nominal_power), 0.01)
22+
23+
def _notebook_run(self, path):
24+
"""
25+
Execute a notebook via nbconvert and collect output.
26+
Returns (parsed nb object, execution errors)
27+
"""
28+
dirname, __ = os.path.split(path)
29+
os.chdir(dirname)
30+
with tempfile.NamedTemporaryFile(suffix=".ipynb") as fout:
31+
args = ["jupyter", "nbconvert", "--to", "notebook", "--execute",
32+
"--ExecutePreprocessor.timeout=60",
33+
"--output", fout.name, path]
34+
subprocess.check_call(args)
35+
36+
fout.seek(0)
37+
nb = nbformat.read(fout, nbformat.current_nbformat)
38+
39+
errors = [output for cell in nb.cells if "outputs" in cell
40+
for output in cell["outputs"]
41+
if output.output_type == "error"]
42+
43+
return nb, errors
44+
45+
def test_basic_example_ipynb(self):
46+
dir_path = os.path.dirname(os.path.realpath(__file__))
47+
nb, errors = self._notebook_run(os.path.join(dir_path,
48+
'basic_example.ipynb'))
49+
assert errors == []

windpowerlib/tools.py

Lines changed: 2 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ def linear_interpolation_extrapolation(df, target_height):
6060
... 'wind_speed']),
6161
... np.array([10, 80])])
6262
>>> round(linear_interpolation_extrapolation(
63-
... weather_df['wind_speed'], 100)[0], 10)
64-
6.8571428571
63+
... weather_df['wind_speed'], 100)[0], 2)
64+
6.86
6565
6666
"""
6767
# find closest heights
@@ -71,53 +71,3 @@ def linear_interpolation_extrapolation(df, target_height):
7171
return ((df[heights_sorted[1]] - df[heights_sorted[0]]) /
7272
(heights_sorted[1] - heights_sorted[0]) *
7373
(target_height - heights_sorted[0]) + df[heights_sorted[0]])
74-
75-
76-
def gaussian_distribution(function_variable, standard_deviation, mean=0):
77-
r"""
78-
Normal distribution or gaussian distribution.
79-
80-
Parameters
81-
----------
82-
function_variable : Float
83-
Variable of the gaussian distribution.
84-
standard_deviation : Float
85-
Standard deviation of the gaussian distribution.
86-
mean : Float
87-
Defines the offset of the gaussian distribution function. Default: 0.
88-
89-
Returns
90-
-------
91-
pandas.Series or numpy.array
92-
Wind speed at hub height. Data type depends on type of `wind_speed`.
93-
94-
Notes
95-
-----
96-
The following equation is used [1]_:
97-
98-
.. math:: f(x) = \frac{1}{\sigma \sqrt{2 \pi}} exp
99-
\left[ -\frac{(x-\mu)^2}{2 \sigma^2} \right]
100-
101-
with:
102-
# TODO: add variables
103-
104-
References
105-
----------
106-
.. [1] Berendsen, H.: "A Student's Guide to Data and Error Analysis".
107-
New York, Cambridge University Press, 2011, p. 37
108-
109-
# TODO: add references
110-
111-
"""
112-
return (1 / (standard_deviation * np.sqrt(2 * np.pi)) *
113-
np.exp(-(function_variable - mean)**2 /
114-
(2 * standard_deviation**2)))
115-
116-
117-
def estimate_turbulence_intensity(height, roughness_length):
118-
"""
119-
Calculate turbulence intensity.
120-
121-
"""
122-
# TODO: Search other possibilities for TI.
123-
return 1 / (np.log(height / roughness_length))

0 commit comments

Comments
 (0)