@@ -169,12 +169,15 @@ def fetch_turbine_data(self, fetch_curve, data_source):
169169 >>> print(e126.nominal_power)
170170 4200000.0
171171
172+ >>> import os
173+ >>> source = os.path.join(os.path.dirname(__file__), '../example/data',
174+ ... 'example_power_curves.csv')
172175 >>> example_turbine = {
173176 ... 'hub_height': 100,
174177 ... 'rotor_diameter': 70,
175178 ... 'name': 'DUMMY 3',
176179 ... 'fetch_curve': 'power_curve',
177- ... 'data_source': 'example_power_curves.csv' }
180+ ... 'data_source': source }
178181 >>> e_t_1 = wind_turbine.WindTurbine(**example_turbine)
179182 >>> print(e_t_1.power_curve['power'][7])
180183 18000.0
@@ -211,7 +214,7 @@ def restructure_data():
211214 nominal_power = df .loc [self .name ][
212215 'installed_capacity_kw' ] * 1000
213216 else :
214- df = read_turbine_data (filename = data_source )
217+ df = read_turbine_data (data_source )
215218 wpp_df = df [df .turbine_id == self .name ]
216219 # if turbine not in data file
217220 if wpp_df .shape [0 ] == 0 :
@@ -256,7 +259,7 @@ def restructure_data():
256259 return self
257260
258261
259- def read_turbine_data (filename , ** kwargs ):
262+ def read_turbine_data (file_ ):
260263 r"""
261264 Fetches power (coefficient) curves from a or a file.
262265 Turbine data is provided by the Open Energy Database (oedb) or can be
@@ -265,17 +268,11 @@ def read_turbine_data(filename, **kwargs):
265268
266269 Parameters
267270 ----------
268- filename : string
271+ file_ : string
269272 Specifies the source of the turbine data.
270- Use 'example_power_coefficient_curves.csv' or
273+ Use 'example_power_coefficient_curves.csv' or # todo adapt
271274 'example_power_curves.csv' to use the example data.
272275
273- Other Parameters
274- ----------------
275- datapath : string, optional
276- Path where the data file is stored if `source` is name of a csv file.
277- Default: './data'
278-
279276 Returns
280277 -------
281278 pandas.DataFrame
@@ -286,17 +283,10 @@ def read_turbine_data(filename, **kwargs):
286283
287284 """
288285
289- if 'datapath' not in kwargs :
290- kwargs ['datapath' ] = os .path .join (os .path .dirname (__file__ ),
291- 'data' )
292286 try :
293- df = pd .read_csv (os .path .join (kwargs ['datapath' ], filename ),
294- index_col = 0 )
287+ df = pd .read_csv (file_ , index_col = 0 )
295288 except FileNotFoundError :
296- raise FileNotFoundError (
297- "The file '{}' was not found. Check spelling " .format (filename ) +
298- "and `datapath` - is '{}' " .format (kwargs ['datapath' ]) +
299- "and can be changed in read_turbine_data()" )
289+ raise FileNotFoundError ("The file '{}' was not found." .format (file_ ))
300290 return df
301291
302292
0 commit comments