find_nearest_index_haversine#

find_nearest_index_haversine(lat, lon, lat_p, lon_p)[source]#

Find the index (i, j) of the nearest grid point in 2D arrays lat and lon to a given target coordinate (lat_p, lon_p) using great-circle (Haversine) distance.

Parameters:
  • lat (np.ndarray) – 2D array of latitude values (degrees).

  • lon (np.ndarray) – 2D array of longitude values (degrees).

  • lat_p (float) – Target latitude (degrees).

  • lon_p (float) – Target longitude (degrees).

Returns:

(i, j) index of the nearest grid point.

Return type:

tuple