[英]pvlib IV curve - TypeError: must be str, not int
I'm trying to make an IV curve from pvlib
but am getting the error: 我正在尝试从
pvlib
制作IV曲线,但出现错误:
TypeError: must be str, not int.
TypeError:必须为str,而不是int。
Running on Spyder. 在Spyder上运行。 Could you advise please?
你能告诉我吗? This example taken from the web.
此示例来自网络。
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
rom pvlib.pvsystem import singlediode, v_from_i, i_from_v, retrieve_sam
def fivepoints_to_frame(pnt):
"""
Converts a 1 dimensional, dict-like singlediode or sapm result
to a 5 row DataFrame with columns current and voltage.
Users can iterate over the rows of a multidimensional
singlediode or sapm result, if necessary.
"""
ivframe = {'i_sc': (pnt['i_sc'], 0),
'p_mp': (pnt['i_mp'], pnt['v_mp']),
'i_x': (pnt['i_x'], 0.5*pnt['v_oc']),
'i_xx': (pnt['i_xx'], 0.5*(pnt['v_oc']+pnt['v_mp'])),
'v_oc': (0, pnt['v_oc'])}
ivframe = pd.DataFrame(ivframe, index=['current', 'voltage']).T
ivframe = ivframe.sort_values(by='voltage')
return ivframe
resistance_shunt = 16
resistance_series = 0.094
nNsVth = 0.473
saturation_current = 1.943e-09
photocurrent = 7
module_parameters = retrieve_sam('cecmod')['Example_Module']
v_oc = v_from_i(resistance_shunt, resistance_series, nNsVth, 0,
saturation_current, photocurrent)
voltage = np.linspace(0, v_oc, 100)
current = i_from_v(resistance_shunt, resistance_series, nNsVth,
voltage,saturation_current, photocurrent)
fivepnts = singlediode(
module_parameters, photocurrent, saturation_current, resistance_series,
resistance_shunt, nNsVth)
ivframe = fivepoints_to_frame(fivepnts)
fig, ax = plt.subplots()
ax.plot(voltage, current)
ax.scatter(ivframe['voltage'], ivframe['current'], c='k', s=36, zorder=10)
ax.set_xlim(0, None)
ax.set_ylim(0, None)
ax.set_ylabel('current (A)')
ax.set_xlabel('voltage (V)')
pvlib.pvsystem.singlediode(photocurrent, saturation_current, resistance_series,
resistance_shunt, nNsVth, ivcurve_pnts=None)
The first parameter to singlediode()
is incorrect. singlediode()
的第一个参数不正确。 If I remove it like: 如果我将其删除,例如:
fivepnts = singlediode(
photocurrent, saturation_current, resistance_series,
resistance_shunt, nNsVth)
I get: 我得到:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.