Skip to content

Commit dcf8396

Browse files
committed
Add filter to get_turbine_types()
1 parent 1ff7a31 commit dcf8396

File tree

1 file changed

+21
-10
lines changed

1 file changed

+21
-10
lines changed

windpowerlib/wind_turbine.py

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -371,11 +371,14 @@ def load_turbine_data_from_oedb():
371371
return turbine_data
372372

373373

374-
def get_turbine_types(print_out=True):
374+
def get_turbine_types(print_out=True, filter_=True):
375375
r"""
376-
Get the names of all possible wind turbine types for which the power
377-
coefficient curve or power curve is provided in the OpenEnergy Data Base
378-
(oedb).
376+
Get all wind turbine types provided in the OpenEnergy Data Base (oedb).
377+
378+
By default only turbine types for which a power coefficient curve or power
379+
curve is provided are returned. Set `filter_=False` to see all turbine
380+
types for which any data (f.e. hub height, rotor diameter, ...) is
381+
provided.
379382
380383
Parameters
381384
----------
@@ -385,6 +388,10 @@ def get_turbine_types(print_out=True):
385388
information about whether a power (coefficient) curve exists (True) or
386389
not (False) in columns 'has_power_curve' and 'has_cp_curve'.
387390
Default: True.
391+
filter_ : boolean
392+
If True only turbine types for which a power coefficient curve or
393+
power curve is provided in the OpenEnergy Data Base (oedb) are
394+
returned. Default: True.
388395
389396
Returns
390397
-------
@@ -413,12 +420,16 @@ def get_turbine_types(print_out=True):
413420
414421
"""
415422
df = load_turbine_data_from_oedb()
416-
cp_curves_df = df.loc[df['has_cp_curve']][
417-
['manufacturer', 'turbine_type', 'has_cp_curve']]
418-
p_curves_df = df.loc[df['has_power_curve']][
419-
['manufacturer', 'turbine_type', 'has_power_curve']]
420-
curves_df = pd.merge(p_curves_df, cp_curves_df, how='outer',
421-
sort=True).fillna(False)
423+
if filter_:
424+
cp_curves_df = df.loc[df['has_cp_curve']][
425+
['manufacturer', 'turbine_type', 'has_cp_curve']]
426+
p_curves_df = df.loc[df['has_power_curve']][
427+
['manufacturer', 'turbine_type', 'has_power_curve']]
428+
curves_df = pd.merge(p_curves_df, cp_curves_df, how='outer',
429+
sort=True).fillna(False)
430+
else:
431+
curves_df = df[['manufacturer', 'turbine_type', 'has_power_curve',
432+
'has_cp_curve']]
422433
if print_out:
423434
pd.set_option('display.max_rows', len(curves_df))
424435
print(curves_df)

0 commit comments

Comments
 (0)