interpolate_quantiles#
- openstef_core.utils.interpolate_quantiles(predictions: ndarray, source_quantiles: Sequence[float], target_quantiles: Sequence[float]) ndarray[source]#
Resample quantile predictions onto a new quantile grid.
Performs piecewise-linear interpolation across the quantile dimension (the last axis of predictions). Target levels outside the source range are clamped to the nearest source prediction (constant extrapolation), which keeps the resampled values within the predicted envelope. Because the model cannot say anything beyond its most extreme level, a request for, say, q0.999 against a model whose highest level is q0.99 returns the q0.99 prediction; a warning is logged whenever this clamping happens.
- Parameters:
predictions (
ndarray) – Array of shape(..., n_source)whose last axis holds predictions for each level in source_quantiles, in the same order.source_quantiles (
Sequence[float]) – Strictly ascending quantile levels the model emits.target_quantiles (
Sequence[float]) – Quantile levels to resample onto. Any order.predictions
source_quantiles
target_quantiles
- Returns:
Array of shape
(..., n_target)with predictions for each level in target_quantiles, in the same order.- Raises:
ValueError – If source_quantiles is not strictly ascending, or its length does not match the last axis of predictions.
- Return type: