geogridfusion.index.coords_to_ref_index#

geogridfusion.index.coords_to_ref_index(coords: ndarray, tree: cKDTree) ndarray[source]#

Maps points to their nearest unique grid index at a specific resolution as specified by “grid_points_fn”. This function handles file IO and rebuilds the spatial KDTree for each call, for efficiency minimize usage to avoid repeated work.

Parameters:
  • coords (np.ndarray) – tall numpy array of [[lat, lon], [lat, lon]]

  • reference_grid_coordinates (np.ndarray) – tall numpy array of coordinates loaded from prebaked grids of uniform density

  • grid_points_fn (str) – name of file storing compressed numpy array. THIS WILL CHANGE DURING DEVELOPMENT

Returns:

indexes (np.ndarray) – 1 dimensional numpy array of nearest indexes in the precomputed grid coresponding to each entry in the coordinates array input