def binned_timesteps(timesteps):
    """
    Compute a binning of the given irregular time steps.

    Parameters
    ----------
    timesteps: array_like
        List or one-dimensional array containing the time steps in ascending
        order.

    Returns
    -------
    out: list
        List of length int(np.ceil(timesteps[-1]))+1 containing the bins. Each
        element is a list containing the indices of the time steps falling in
        the bin (excluding the right edge).
    """
    timesteps = list(timesteps)
    if not sorted(timesteps) == timesteps:
        raise ValueError("timesteps is not in ascending order")

    if np.any(np.array(timesteps) < 0):
        raise ValueError("negative time steps are not allowed")

    num_bins = int(np.ceil(timesteps[-1]))
    timestep_range = np.arange(num_bins + 1)
    bin_idx = np.digitize(timesteps, timestep_range, right=False)

    out = [[] for _ in range(num_bins + 1)]
    for i, bi in enumerate(bin_idx):
        out[bi - 1].append(i)

    return out
Compute a binning of the given irregular time steps.

Parameters
----------
timesteps: array_like
List or one-dimensional array containing the time steps in ascending
order.

Returns
-------
out: list
List of length int(np.ceil(timesteps[-1]))+1 containing the bins. Each
element is a list containing the indices of the time steps falling in
the bin (excluding the right edge).
pysteps/nowcasts/utils.py