因此,我在第50行中使用val = np.argmin(R_abs)
找到了数组中的最低值,但现在我试图找到该值的索引。我尝试在第52行中使用val_index = [idx for idx, minval in enumerate(R_abs) if minval == val]
,但得到了一个空数组。我做错了什么?我相信.list()只适用于list。R_abs是一个数组
R_abs = abs(R-atm_tropo)
val = np.argmin(R_abs) # (line 50)
# val_index = np.where(R_abs == val)
val_index = [idx for idx, minval in enumerate(R_abs) if minval == val] # (line 52)
更新了NumPy数组而不是Python列表:
This article建议您使用
np.where
:返回
相关问题 更多 >
编程相关推荐