我正在使用一个名为 pvmismatch 的库,它可以测量不完美阴影对太阳能电池的影响,我认为它很快就会与 pvlib 兼容。我不确定这是一个与 python 相关的问题,还是与库相关的问题,但可能是前者。
我想创建一个函数,该函数接受使用“setSuns”的“阴影”列表以及要着色的单元格的索引。我的代码如下:
def shade_into_powers(shades_list = [], temperatures_list = [], cells_list = []):
length_of_lists = len(shades_list)
list_of_powers = []
for i in range(0, length_of_lists):
my_module_shaded.setSuns(Ee = shades_list[i], cells = cells_list[i])
my_module_shaded.setTemps(Tc=temperatures_list[i], cells= cells_list[i])
list_of_powers[i] = my_module_shaded.pvcells[i].Igen*max(my_module_shaded.pvcells[i].Vcell)
return list_of_powers
我后来尝试如下尝试此功能:
shadez = [0.43, 0.43, 0.43]
tempez = [88, 81, 77]
cellz = [30, 31, 32]
powers_listed = shade_into_powers(shadez, tempez, cellz)
我得到的错误是“'int'类型的对象不可迭代”。我在这里做错了什么?
所有帮助表示赞赏。
以下是回溯:
Traceback (most recent call last):
File "/home/abed/.config/JetBrains/PyCharmCE2020.2/scratches/scratch_2.py", line 176, in <module>
powers_listed = shade_into_powers(shadez, tempez, cellz)
File "/home/abed/.config/JetBrains/PyCharmCE2020.2/scratches/scratch_2.py", line 168, in shade_into_powers
my_module_shaded.setSuns(Ee = shades_list[i], cells = cells_list[i])
File "/home/abed/.local/lib/python3.7/site-packages/pvmismatch/pvmismatch_lib/pvmodule.py", line 323, in setSuns
cells_to_update = [self.pvcells[i] for i in cells]
TypeError: 'int' object is not iterable