esmtools.spatial.find_indices¶
-
esmtools.spatial.
find_indices
(xgrid, ygrid, xpoint, ypoint)[source]¶ Returns the i, j index for a latitude/longitude point on a grid.
Note
Longitude and latitude points (
xpoint
/ypoint
) should be in the same range as the grid itself (e.g., if the longitude grid is 0-360, should be 200 instead of -160).Parameters: Returns: Keys for the inputted grid that lead to the lat/lon point the user is seeking.
Return type: i, j (int)
Examples
>>> import esmtools as et >>> import numpy as np >>> x = np.linspace(0, 360, 37) >>> y = np.linspace(-90, 90, 19) >>> xx, yy = np.meshgrid(x, y) >>> xp = 20 >>> yp = -20 >>> i, j = et.spatial.find_indices(xx, yy, xp, yp) >>> print(xx[i, j]) 20.0 >>> print(yy[i, j]) -20.0