我正在尝试运行此脚本,但它显示生成的错误:
UFuncTypeError: ufunc 'add' did not contain a loop with signature matching types (dtype('<U32'), dtype('<U32')) -> dtype('<U32')
以下是我正在尝试运行的代码:
if __name__ == '__main__':
app = Nominatim(user_agent="test_solar")
loc_raw = app.geocode('Postintaival 7, 00230 Helsinki, Finland').raw
latitude = loc_raw['lat']
longitude = loc_raw['lon']
altitude = get_elevation(latitude, longitude)
location_object = Location(latitude, longitude, 'Europe/Helsinki', altitude,
'relex_solutions')
weather = pvlib.iotools.get_pvgis_tmy(latitude, longitude, map_variables=True)[0]
times = weather.index
solpos = location_object.get_solarposition(times)
clearsky_values = location_object.get_clearsky(times, model='ineichen',
solar_position=solpos,
dni_extra=None)
TLDR
将经度(以及一致性所需的纬度)转换为float,它将起作用:
更长的解释
添加所有导入和缺失函数需要一些时间,以获得最小的可复制示例。我猜
get_elevation
函数来自this question这里是
pvlib.spa
模块中出现问题的地方:我添加了一些打印以查看变量(调试点也应该可以工作):
我们得到:
observer_longitude
参数是在numpy sum操作中不受管理的字符串。经过一些探索,我发现这个经度直接来自Location
物体,因此将它简单地转换成float
就解决了这个问题相关问题 更多 >
编程相关推荐