calculate_nearest_neighbor
Functions:
| Name | Description |
|---|---|
nearest_neighbor |
Perform a nearest neighbor reindexing on the input dataset based on the specified coordinate. |
Functions#
nearest_neighbor #
nearest_neighbor(
input_dataset: Dataset,
coord_name: str,
coord_labels: ndarray,
coord_range: Union[str, int, float],
) -> xr.Dataset
Perform a nearest neighbor reindexing on the input dataset based on the specified coordinate.
This function creates an empty DataArray with the desired coordinate labels and uses
the reindex_like method to align the input dataset with the new coordinate labels.
Args:
input_dataset (xr.Dataset): The input xarray Dataset to be reindexed.
coord_name (str): The name of the coordinate variable to use for reindexing.
coord_labels (np.ndarray): The new coordinate labels to align the dataset with.
coord_range (Union[str, int, float]): The range tolerance for the nearest neighbor search.
This can be a string with units (e.g., "1h" for 1 hour) or a numeric value.
Returns:
xr.Dataset: The reindexed xarray Dataset with the new coordinate labels.