PCR-GLOBWB (PCRaster Global Water Balance) is a large-scale hydrological model intended for global to regional studies and developed at the Department of Physical Geography, Utrecht University (Netherlands). Contact: Edwin Sutanudjaja (E.H.Sutanudjaja@uu.nl).
Note that the bug can easily be solved by adding one more pair of brackets:
xIdxSta = int(np.where(np.abs(lons - (xULClone - cellsizeInput/2)) == minX)[0][0])
However, the proposed fix using np.argmin avoids the need to explicitly identify minX first and then identify the corresponding point with np.where. Note the numpy docs: In case of multiple occurrences of the minimum values, the indices corresponding to the first occurrence are returned. Also, there is no need to convert to int explicitly, because that's the default return type of np.argmin.
The following configuration exposes the bug:
Note that the bug can easily be solved by adding one more pair of brackets:
xIdxSta = int(np.where(np.abs(lons - (xULClone - cellsizeInput/2)) == minX)[0][0])
However, the proposed fix using
np.argmin
avoids the need to explicitly identifyminX
first and then identify the corresponding point withnp.where
. Note the numpy docs: In case of multiple occurrences of the minimum values, the indices corresponding to the first occurrence are returned. Also, there is no need to convert toint
explicitly, because that's the default return type ofnp.argmin
.