私は 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 です。
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