xscape.utils.get_gridcenter_time
- xscape.utils.get_gridcenter_time(dates, var_da)
Gets the nearest time coordinates in a grid for a series of datetime values.
- Parameters:
dates (pd.DataFrame) – DataFrame with a “time” column.
var_da (xr.DataArray) – Gridded data array with a “time” dimension.
- Returns:
A DataFrame equivalent to dates with the “time” column replaced with the closest available time in var_da for each datetime in dates. Any duplicate rows after the operation are dropped.
- Return type:
pd.DataFrame
- Raises:
AttributeError – If dates has no “time” column or if var_da has no “time” coordinate.