[英]Get Max Values of a Datetime Dependent Range
I hope you all are fine.我希望你们都很好。
I got a function (Y axis) that gets values according to a datetime pandas array (X axis) as shown below.我得到了一个 function(Y 轴),它根据日期时间 pandas 数组(X 轴)获取值,如下所示。
I need to get all the maximum values .我需要得到所有的最大值。 Those n maximum values depends on the number of days that are between a start and end pd.timestamp.这 n 个最大值取决于开始和结束 pd.timestamp 之间的天数。 Then, I also need to save those values in an array ;然后,我还需要将这些值保存在一个数组中; something like this:像这样的东西:
max_values = [
(A_value_1, B_value_1),
(A_value_2, B_value_1),
...,
(A_value_n, A_value_n)]
Note: The B_value_#
is the same that I am asking for but with another function (A_values: Irradiance and B_values: Cell temperature, just a contextualization for the PVLIB-Python
community.注意: B_value_#
与我要求的相同,但与另一个 function 相同(A_values:辐照度和 B_values:细胞温度,只是PVLIB-Python
社区的上下文。
For those who are familiar with PVLIB-Python
, I am trying to get the IV curve by using the pvsystem.calcparams_desoto
function (this is because I am using a CEC module and it doesn't have the parameters required by the SAPM
function. Part of this code is snipped below:对于那些熟悉PVLIB-Python
的人,我试图通过使用pvsystem.calcparams_desoto
function 来获得 IV 曲线(这是因为我使用的是 CEC 模块并且它没有SAPM
function 所需的参数。这段代码的片段如下:
IL, I0, Rs, Rsh, nNsVth = pvsystem.calcparams_desoto(
effective_irrad_calc,
pvtemps['temp_cell'],
module['alpha_sc'],
module['a_ref'],
module['I_L_ref'],
module['I_o_ref'],
module['R_sh_ref'],
module['R_s'],
EgRef=1.121,
dEgdT=-0.0002677
)
curve_info = pvsystem.singlediode(
photocurrent=IL,
saturation_current=I0,
resistance_series=Rs,
resistance_shunt=Rsh,
nNsVth=nNsVth,
ivcurve_pnts=100,
method='lambertw'
)
# plot the calculated curves:
plt.figure()
for i, case in conditions.iterrows():
label = (
"$G_{eff}$ " + f"{case['Geff']} $W/m^2$\n"
"$T_{cell}$ " + f"{case['Tcell']} $C$"
)
plt.plot(curve_info['v'][i], curve_info['i'][i], label=label)
v_mp = curve_info['v_mp'][i]
i_mp = curve_info['i_mp'][i]
# mark the MPP
plt.plot([v_mp], [i_mp], ls='', marker='o', c='k')
plt.legend(loc=(1.0, 0))
plt.xlabel('Module voltage [V]')
plt.ylabel('Module current [A]')
plt.title(parameters['Name'])
plt.show()
plt.gcf().set_tight_layout(True)
Note: This code snipped was taken at: https://github.com/pvlib/pvlib-python/blob/master/docs/examples/plot_singlediode.py注意:此代码截取于: https://github.com/pvlib/pvlib-python/blob/master/docs/examples/plot_singlediode.py
Thanks in advance.提前致谢。 :) :)
First just making a small example:首先只是做一个小例子:
df = pd.DataFrame(index=pd.date_range('2020-01-01', freq='1h', periods=24*5))
df['irradiance'] = np.clip(np.cos(np.linspace(np.pi, 2*np.pi*5+np.pi, 24*5)),
a_min=0, a_max=None)
Then using pandas' resample function with a daily frequency and the max function, would give you the daily value for the peak:然后使用 pandas 的重采样 function 和每日频率和最大 function,将为您提供峰值的每日值:
max_value = df['irradiance'].resample('1d').max()
Similarly, the location of the max value can be found:同样可以找到最大值的位置:
max_location = df['irradiance'].resample('1d').apply(lambda s: s.idxmax())
Now knowing the location/index of the max value you can apply this to another column of your DataFrame.现在知道最大值的位置/索引,您可以将其应用于 DataFrame 的另一列。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.