def save_skill(
    current_skill,
    validtime,
    outdir_path,
    window_length=30,
    **kwargs,
):
    """
    Add the current NWP skill to update today's daily average skill. If the day
    is over, update the list of daily average skill covering a rolling window.

    Parameters
    ----------
    current_skill: array-like
      Array of shape [model, scale_level, ...]
      containing the current skill of the different NWP models per cascade
      level.
    validtime: datetime
      Datetime object containing the date and time for which the current
      skill are valid.
    outdir_path: string
      Path to folder where the historical skill are stored. Defaults to
      path_workdir from rcparams.
    window_length: int, optional
      Length of window (in days) of daily skill that should be retained.
      Defaults to 30.

    Returns
    -------
    None

    """

    n_cascade_levels = current_skill.shape[1]

    # Load skill_today, a dictionary containing {mean_skill, n, last_validtime}
    new_skill_today_file = False

    skill_today_file = Path(outdir_path) / "NWP_skill_today.pkl"
    if skill_today_file.is_file():
        with open(skill_today_file, "rb") as f:
            skill_today = pickle.load(f)
        if skill_today["mean_skill"].shape != current_skill.shape:
            new_skill_today_file = True
    else:
        new_skill_today_file = True

    if new_skill_today_file:
        skill_today = {
            "mean_skill": np.copy(current_skill),
            "n": 0,
            "last_validtime": validtime,
        }

    # Load the past skill which is an array with dimensions day x model x scale_level
    past_skill_file = Path(outdir_path) / "NWP_skill_window.npy"
    past_skill = None
    if past_skill_file.is_file():
        past_skill = np.load(past_skill_file)
    # First check if we have started a new day wrt the last written skill, in which
    # case we should update the daily skill file and reset daily statistics.
    if skill_today["last_validtime"].date() < validtime.date():
        # Append skill to the list of the past X daily averages.
        if (
            past_skill is not None
            and past_skill.shape[2] == n_cascade_levels
            and past_skill.shape[1] == skill_today["mean_skill"].shape[0]
        ):
            past_skill = np.append(past_skill, [skill_today["mean_skill"]], axis=0)
        else:
            past_skill = np.array([skill_today["mean_skill"]])

        # Remove oldest if the number of entries exceeds the window length.
        if past_skill.shape[0] > window_length:
            past_skill = np.delete(past_skill, 0, axis=0)
        # FIXME also write out last_validtime.date() in this file?
        # In that case it will need pickling or netcdf.
        # Write out the past skill within the rolling window.
        np.save(past_skill_file, past_skill)
        # Reset statistics for today.
        skill_today["n"] = 0
        skill_today["mean_skill"] = 0

    # Reset today's skill if needed and/or compute online average from the
    # current skill using numerically stable algorithm
    skill_today["n"] += 1
    skill_today["mean_skill"] += (
        current_skill - skill_today["mean_skill"]
    ) / skill_today["n"]
    skill_today["last_validtime"] = validtime
    # Make path if path does not exist
    skill_today_file.parent.mkdir(exist_ok=True, parents=True)
    # Open and write to skill file
    with open(skill_today_file, "wb") as f:
        pickle.dump(skill_today, f)

    return None
Add the current NWP skill to update today's daily average skill. If the day
is over, update the list of daily average skill covering a rolling window.

Parameters
----------
current_skill: array-like
Array of shape [model, scale_level, ...]
containing the current skill of the different NWP models per cascade
level.
validtime: datetime
Datetime object containing the date and time for which the current
skill are valid.
outdir_path: string
Path to folder where the historical skill are stored. Defaults to
path_workdir from rcparams.
window_length: int, optional
Length of window (in days) of daily skill that should be retained.
Defaults to 30.

Returns
-------
None
pysteps/blending/clim.py