get_overlapping_time_slice#

mhm_tools.common.xarray_utils.get_overlapping_time_slice(input_ds, ref_ds)[source]#

Return the inclusive overlapping time window of two time-indexed objects.

The overlap is computed from the first/last non-all-NaN timesteps of each input. Time-of-day components are dropped before creating the slice so small sub-daily offsets (e.g. 00:00 vs 11:00 for daily data) still produce a common calendar-day window.

Parameters:
  • input_ds – Simulation (or first) xarray object with a time dimension.

  • ref_ds – Reference (or second) xarray object with a time dimension.

Return type:

slice(start, end) with pandas.Timestamp endpoints.