我还有一个关于 numpy python 模块语法的问题,我想将其转换为常规的 python 2.7 语法。这是 numpy 版本:
if any((var.theta < 0) | (var.theta >= 90)):
print('Input incident angles <0 or >=90 detected For input angles with absolute value greater than 90, the ' + 'modifier is set to 0. For input angles between -90 and 0, the ' + 'angle is changed to its absolute value and evaluated.')
var.theta[(var.theta < 0) | (var.theta >= 90)]=abs((var.theta < 0) | (var.theta >= 90))
源代码: https ://github.com/Sandia-Labs/PVLIB_Python/blob/master/pvlib/pvl_physicaliam.py#L93-95
如果我们假设 numpy 数组是一维的,那么常规的 python 2.7 语法会是这样的:
newTheta = []
for item in var.theta:
if (item < 0) and (item >= 90):
print('Input incident angles <0 or >=90 detected For input angles with absolute value greater than 90, the ' + 'modifier is set to 0. For input angles between -90 and 0, the ' + 'angle is changed to its absolute value and evaluated.')
newItem = abs(item)
newTheta.append(newItem)
?? 感谢您的答复。