我试图参考windpowerlib文档(https://windpowerlib.readthedocs.io/en/stable/getting_started.html#examplereference-label),并使用示例Python脚本和示例天气数据文件。我在Anaconda 3中创建了一个名为windproject1
的新虚拟环境,并通过windpowerlib
在该目录中安装了pip
。
我在上述链接中执行的PyCharm Community Edition 2018.1中执行示例代码,但未成功编译。我在提2种可能根据下面的Stacktrace引起错误的方法:-
def initialise_wind_turbines():
r"""
Initialises two :class:`~.wind_turbine.WindTurbine` objects.
Function shows two ways to initialise a WindTurbine object. You can either
specify your own turbine, as done below for 'myTurbine', or fetch power
and/or power coefficient curve data from data files provided by the
windpowerlib, as done for the 'enerconE126'.
Execute ``windpowerlib.wind_turbine.get_turbine_types()`` or
``windpowerlib.wind_turbine.get_turbine_types(
filename='power_coefficient_curves.csv')`` to get a list of all wind
turbines for which power and power coefficient curves respectively are
provided.
Returns
-------
Tuple (WindTurbine, WindTurbine)
"""
# specification of own wind turbine (Note: power coefficient values and
# nominal power have to be in Watt)
myTurbine = {
'turbine_name': 'myTurbine',
'nominal_power': 3e6, # in W
'hub_height': 105, # in m
'rotor_diameter': 90, # in m
'power_curve': pd.DataFrame(
data={'values': [p * 1000 for p in [
0.0, 26.0, 180.0, 1500.0, 3000.0, 3000.0]], # in W
'wind_speed': [0.0, 3.0, 5.0, 10.0, 15.0, 25.0]}) # in m/s
}
# initialise WindTurbine object
my_turbine = WindTurbine(**myTurbine)
# specification of wind turbine where power curve is provided
# if you want to use the power coefficient curve add
# {'fetch_curve': 'power_coefficient_curve'} to the dictionary
enerconE126 = {
'turbine_name': 'ENERCON E 126 7500', # turbine name as in register
'hub_height': 135, # in m
'rotor_diameter': 127 # in m
}
# initialise WindTurbine object
e126 = WindTurbine(**enerconE126)
return my_turbine, e126
def run_basic_example():
r"""
Run the basic example.
"""
weather = get_weather_data('weather.csv')
my_turbine, e126 = initialise_wind_turbines()
calculate_power_output(weather, my_turbine, e126)
plot_or_print(my_turbine, e126)
if __name__ == "__main__":
run_basic_example()
但是无法成功编译它。从下面的堆栈跟踪中可以明显看出错误:-
/Users/joyjitchatterjee/anaconda3/envs/windproject1/bin/python /Users/joyjitchatterjee/Desktop/windAnalysis/test.py
Traceback (most recent call last):
File "/Users/joyjitchatterjee/Desktop/windAnalysis/test.py", line 243, in <module>
run_basic_example()
File "/Users/joyjitchatterjee/Desktop/windAnalysis/test.py", line 237, in run_basic_example
my_turbine, e126 = initialise_wind_turbines()
File "/Users/joyjitchatterjee/Desktop/windAnalysis/test.py", line 111, in initialise_wind_turbines
my_turbine = WindTurbine(**myTurbine)
TypeError: __init__() got an unexpected keyword argument 'name'
Process finished with exit code 1
这里要提到的关键是我的桌面(/Users/joyjitchatterjee/Desktop/example)
上有一个带weather.csv文件的文件夹。另外,我正在编译的代码存储在名为(/Users/joyjitchatterjee/Desktop/windAnalysis)
的文件夹test.py
中。我不确定__init__()
dunder方法为什么会产生此奇怪错误,并且是否需要指定任何显式参数而不是名称来运行示例代码。我不熟悉将windpowerlib和Python与此类软件包一起使用,在这方面的任何帮助将不胜感激。谢谢!