0
我试图让从pvlib
IV曲线关系,但我得到的错误:pvlib IV曲线 - 类型错误:必须海峡,不是int
TypeError: must be str, not int.
上运行的Spyder。 你能提醒一下吗?这个例子来自网络。
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)')
问题寻求帮助调试(“为什么不是这个代码的工作?”)必须包括所期望的行为,一个具体问题或错误和在问题本身中重现它所需的最短代码。没有明确问题陈述的问题对其他读者无益。请参阅:如何创建[mcve]。 – ImportanceOfBeingErnest