resample_to_daily_or_hourly_adaptive#

mhm_tools.common.time_utils.resample_to_daily_or_hourly_adaptive(in_obj: DataArray | Dataset, target: Literal['daily', 'hourly'], upsample_for_intensive: Literal['linear', 'ffill', 'nearest'] = 'linear', var: str | None = None) DataArray | Dataset[source]#

Resample to daily or hourly with adaptive choice of aggregation.

  • Intensive vars → downsample = mean; upsample = interpolate/fill.

  • Extensive vars → downsample = sum; upsample = sum-preserving distribution.

Parameters:
  • in_obj (xr.DataArray | xr.Dataset)

  • target (‘daily’ | ‘hourly’)

  • upsample_for_intensive (fill method for intensive vars when going finer.)

  • var (str | None)

Return type:

Same type as input, resampled to calendar-aware ‘D’ or ‘1h’.