1919except ImportError :
2020 rq = None
2121
22- class WindTurbine (object ): # todo add data_source
22+ class WindTurbine (object ):
2323 r"""
2424 Defines a standard set of wind turbine attributes.
2525
@@ -50,13 +50,19 @@ class WindTurbine(object): # todo add data_source
5050 coordinates : list or None
5151 List of coordinates [lat, lon] of location for loading data.
5252 Default: None.
53+ data_source : string
54+ Specifies whether turbine data (f.e. nominal power, power curve, power
55+ coefficient curve) is loaded from the Open Energy Database ('oedb') or
56+ from a csv file ('<name of csv file>'). See `example_power_curves.csv'
57+ and `example_power_coefficient_curves.csv` in windpowerlib/data for
58+ the required form of a csv file. Default: 'oedb'.
5359
5460 Attributes
5561 ----------
5662 name : string
5763 Name of the wind turbine type.
58- Use :py:func:`~.get_turbine_types` to see a list of all wind turbines for which
59- power (coefficient) curve data is provided.
64+ Use :py:func:`~.get_turbine_types` to see a list of all wind turbines
65+ for which power (coefficient) curve data is provided.
6066 hub_height : float
6167 Hub height of the wind turbine in m.
6268 rotor_diameter : None or float
@@ -71,10 +77,6 @@ class WindTurbine(object): # todo add data_source
7177 corresponding power curve value in W. Default: None.
7278 nominal_power : None or float
7379 The nominal output of the wind turbine in W.
74- fetch_curve : string
75- Parameter to specify whether a power or power coefficient curve
76- should be retrieved from the provided turbine data. Valid options are
77- 'power_curve' and 'power_coefficient_curve'. Default: None.
7880 coordinates : list or None
7981 List of coordinates [lat, lon] of location for loading data.
8082 Default: None.
@@ -84,9 +86,9 @@ class WindTurbine(object): # todo add data_source
8486 Notes
8587 ------
8688 Your wind turbine object should have a power coefficient or power curve.
87- You can set the `fetch_curve` parameter if you don't want to provide one
88- yourself but want to automatically fetch a curve from the data set
89- provided along with the windpowerlib .
89+ You can set the `fetch_curve` parameter and the `data_source` parameter if
90+ you don't want to provide one yourself but want to automatically fetch a
91+ curve from a data set provided in the Open Energy Database (oedb) .
9092
9193 Examples
9294 --------
@@ -121,17 +123,31 @@ def __init__(self, name, hub_height, rotor_diameter=None,
121123 if self .power_coefficient_curve is None and self .power_curve is None :
122124 self .fetch_turbine_data (fetch_curve , data_source )
123125
124- def fetch_turbine_data (self , fetch_curve , data_source ): # todo add parameter description
126+ def fetch_turbine_data (self , fetch_curve , data_source ):
125127 r"""
126128 Fetches data of the requested wind turbine.
127129
128130 Method fetches nominal power as well as power coefficient curve or
129- power curve from a data file provided along with the windpowerlib.
130- You can also use this function to import your own power (coefficient)
131- curves. Therefore the wind speeds in m/s have to be in the first row
132- and the corresponding power coefficient curve values or power
131+ power curve from a data set provided in the Open Energy Database
132+ (oedb). You can also use this function to import your own power
133+ (coefficient) curves. For that the wind speeds in m/s have to be in the
134+ first row and the corresponding power coefficient curve values or power
133135 curve values in W in a row where the first column contains the turbine
134- name (See directory windpowerlib/data as reference).
136+ name (see directory windpowerlib/data as reference).
137+
138+ Parameters
139+ ----------
140+ fetch_curve : string
141+ Parameter to specify whether a power or power coefficient curve
142+ should be retrieved from the provided turbine data. Valid options
143+ are 'power_curve' and 'power_coefficient_curve'. Default: None.
144+ data_source : string
145+ Specifies whether turbine data (f.e. nominal power, power curve,
146+ power coefficient curve) is loaded from the Open Energy Database
147+ ('oedb') or from a csv file ('<name of csv file>'). See
148+ `example_power_curves.csv` and
149+ `example_power_coefficient_curves.csv` in windpowerlib/data for the
150+ required form of a csv file. Default: 'oedb'.
135151
136152 Returns
137153 -------
@@ -168,7 +184,7 @@ def fetch_turbine_data(self, fetch_curve, data_source): # todo add parameter des
168184
169185 def restructure_data ():
170186 r"""
171- Restructures data read from a csv file.
187+ Restructures data fetched from oedb or read from a csv file.
172188
173189 Method creates a two-dimensional DataFrame containing the power
174190 coefficient curve or power curve of the requested wind turbine.
@@ -225,6 +241,7 @@ def restructure_data():
225241 df = pd .DataFrame (data , columns = ['wind_speed' ,
226242 'power coefficient' ])
227243 return df , nominal_power
244+
228245 if fetch_curve == 'power_curve' :
229246 self .power_curve , p_nom = restructure_data ()
230247 elif fetch_curve == 'power_coefficient_curve' :
@@ -284,15 +301,16 @@ def read_turbine_data(filename, **kwargs):
284301
285302def load_turbine_data_from_oedb ():
286303 r"""
287-
304+ Loads turbine data from the Open Energy Database (oedb).
288305
289306 Returns
290307 -------
291308 turbine_data : pd.DataFrame
292309 Contains turbine data of different turbine types like 'manufacturer',
293- nominal power ('installed_capacity_kw')
310+ 'turbine_type', nominal power ('installed_capacity_kw'), '
294311
295312 """
313+
296314 if rq :
297315 # url of Open Energy Platform that contains the oedb
298316 oep_url = 'http://oep.iks.cs.ovgu.de/'
@@ -314,9 +332,6 @@ def load_turbine_data_from_oedb():
314332 "Error: " .format (result .status_code ))
315333 # extract data
316334 turbine_data = pd .DataFrame (result .json ())
317- # dump data as csv
318- turbine_data .to_csv (os .path .join (os .path .dirname (__file__ ), 'data' ,
319- 'turbine_data_oedb.csv' ))
320335 else :
321336 raise ImportError ('If you want to load turbine data from the oedb' +
322337 'you have to install the requests package.' +
@@ -366,6 +381,3 @@ def get_turbine_types(print_out=True):
366381 print (curves_df )
367382 pd .reset_option ('display.max_rows' )
368383 return curves_df
369-
370- if __name__ == "__main__" :
371- get_turbine_types (print_out = True ) # todo delete
0 commit comments