Skip to content

Commit 1e08715

Browse files
committed
Add doctests / examples
1 parent 747688f commit 1e08715

File tree

1 file changed

+36
-13
lines changed

1 file changed

+36
-13
lines changed

windpowerlib/wind_turbine.py

Lines changed: 36 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,12 @@ class WindTurbine(object): # todo add data_source
9494
>>> enerconE126 = {
9595
... 'hub_height': 135,
9696
... 'rotor_diameter': 127,
97-
... 'name': 'ENERCON E 126 7500',
98-
... 'fetch_curve': 'power_curve'}
97+
... 'name': 'E-126/4200',
98+
... 'fetch_curve': 'power_curve',
99+
... 'data_source': 'oedb'}
99100
>>> e126 = wind_turbine.WindTurbine(**enerconE126)
100101
>>> print(e126.nominal_power)
101-
7500000
102+
4200000.0
102103
103104
"""
104105

@@ -142,13 +143,26 @@ def fetch_turbine_data(self, fetch_curve, data_source): # todo add parameter des
142143
>>> enerconE126 = {
143144
... 'hub_height': 135,
144145
... 'rotor_diameter': 127,
145-
... 'name': 'ENERCON E 126 7500',
146-
... 'fetch_curve': 'power_coefficient_curve'}
146+
... 'name': 'E-126/4200',
147+
... 'fetch_curve': 'power_coefficient_curve',
148+
... 'data_source': 'oedb'}
147149
>>> e126 = wind_turbine.WindTurbine(**enerconE126)
148-
>>> print(e126.power_coefficient_curve['power coefficient'][5]) # todo adapt example
149-
0.423
150+
>>> print(e126.power_coefficient_curve['power coefficient'][5])
151+
0.44
150152
>>> print(e126.nominal_power)
151-
7500000
153+
4200000.0
154+
155+
>>> example_turbine = {
156+
... 'hub_height': 100,
157+
... 'rotor_diameter': 70,
158+
... 'name': 'DUMMY 3',
159+
... 'fetch_curve': 'power_curve',
160+
... 'data_source': 'example_power_curves.csv'}
161+
>>> e_t_1 = wind_turbine.WindTurbine(**example_turbine)
162+
>>> print(e_t_1.power_curve['power'][7])
163+
18000.0
164+
>>> print(e_t_1.nominal_power)
165+
150000
152166
153167
"""
154168

@@ -324,13 +338,22 @@ def get_turbine_types(print_out=True):
324338
Examples
325339
--------
326340
>>> from windpowerlib import wind_turbine
327-
>>> turbines = wind_turbine.get_turbine_types(print_out=False)
328-
>>> print(turbines[turbines["turbine_id"].str.contains("ENERCON")].iloc[0]) # todo adapt example
329-
turbine_id ENERCON E 101 3000
330-
p_nom 3000000
331-
Name: 25, dtype: object
341+
>>> df = wind_turbine.get_turbine_types(print_out=False)
342+
>>> print(df[df["turbine_type"].str.contains("E-126")].iloc[0])
343+
manufacturer Enercon
344+
turbine_type E-126/4200
345+
has_power_curve True
346+
has_cp_curve True
347+
Name: 5, dtype: object
348+
>>> print(df[df["manufacturer"].str.contains("Enercon")].iloc[0])
349+
manufacturer Enercon
350+
turbine_type E-101/3050
351+
has_power_curve True
352+
has_cp_curve True
353+
Name: 1, dtype: object
332354
333355
"""
356+
334357
df = load_turbine_data_from_oedb()
335358
cp_curves_df = df.iloc[df.loc[df['has_cp_curve'] == True].index][
336359
['manufacturer', 'turbine_type', 'has_cp_curve']]

0 commit comments

Comments
 (0)