geost.models.model_utils.sample_with_coords#

geost.models.model_utils.sample_with_coords(ds: Dataset | DataArray, coords: ndarray)[source]#

Sample x and y dims of an Xarray Dataset or DataArray using an array of x and y coordinates. Only coordinates that are within the extent of the Dataset or DataArray are selected.

Parameters:
  • ds (xr.Dataset or xr.DataArray) – Dataset or DataArray to sample. Must contain dimensions ‘x’ and ‘y’ that refer to the coordinates.

  • coords (np.ndarray) – Numpy array with shape (n, 2) of the x and y coordinates to select.

Returns:

ds_sel – Sampled Dataset or DataArray with dimension ‘idx’ which is the index of the input coordinates which are selected.

Return type:

xr.Dataset or xr.DataArray