Skip to content

Commit da59b3d

Browse files
committed
Use WplUser-Warning to warn if a turbine is initialised without any curve
1 parent 2297c2f commit da59b3d

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

windpowerlib/wind_turbine.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@
1010

1111
import pandas as pd
1212
import logging
13-
import sys
13+
import warnings
1414
import requests
1515
import os
16+
from windpowerlib.tools import WindpowerlibUserWarning
1617

1718

1819
class WindTurbine(object):
@@ -140,6 +141,14 @@ def __init__(self, hub_height, nominal_power=None, path='oedb',
140141
if self.rotor_diameter is None and turbine_data is not None:
141142
self.rotor_diameter = float(turbine_data['rotor_diameter'])
142143

144+
if self.power_curve is None and self.power_coefficient_curve is None:
145+
msg = ("The WindTurbine has been initialised without a power curve"
146+
" and without a power coefficient curve.\nYou will not be"
147+
" able to calculate the power output.\n"
148+
" Check if the turbine type {0} is in your database file"
149+
" or if you you passed a valid curve.")
150+
warnings.warn(msg.format(turbine_type), WindpowerlibUserWarning)
151+
143152
def __repr__(self):
144153
info = []
145154
if self.nominal_power is not None:

0 commit comments

Comments
 (0)