def compute_store_nwp_motion(
    precip_nwp,
    oflow_method,
    analysis_time,
    nwp_model,
    output_path,
):
    """Computes, per forecast lead time, the velocity field of an NWP model field.

    Parameters
    ----------
    precip_nwp: array-like
      Array of dimension (n_timesteps, x, y) containing the precipitation forecast
      from some NWP model.
    oflow_method: {'constant', 'darts', 'lucaskanade', 'proesmans', 'vet'}, optional
      An optical flow method from pysteps.motion.get_method.
    analysis_time: numpy.datetime64
      The analysis time of the NWP forecast. The analysis time is assumed to be a
      numpy.datetime64 type as imported by the pysteps importer.
    nwp_model: str
      The name of the NWP model.
    output_path: str, optional
      The location where to save the file with the NWP velocity fields. Defaults
      to the path_workdir specified in the rcparams file.

    Returns
    -------
    Nothing
    """

    # Set the output file
    output_date = f"{analysis_time.astype('datetime64[us]').astype(datetime.datetime):%Y%m%d%H%M%S}"
    outfn = Path(output_path) / f"motion_{nwp_model}_{output_date}.npy"

    # Get the velocity field per time step
    v_nwp = np.zeros((precip_nwp.shape[0], 2, precip_nwp.shape[1], precip_nwp.shape[2]))
    # Loop through the timesteps. We need two images to construct a motion
    # field, so we can start from timestep 1.
    for t in range(1, precip_nwp.shape[0]):
        v_nwp[t] = oflow_method(precip_nwp[t - 1 : t + 1, :, :])

    # Make timestep 0 the same as timestep 1.
    v_nwp[0] = v_nwp[1]

    assert v_nwp.ndim == 4, "v_nwp must be a four-dimensional array"

    # Save it as a numpy array
    np.save(outfn, v_nwp)
Computes, per forecast lead time, the velocity field of an NWP model field.

Parameters
----------
precip_nwp: array-like
Array of dimension (n_timesteps, x, y) containing the precipitation forecast
from some NWP model.
oflow_method: {'constant', 'darts', 'lucaskanade', 'proesmans', 'vet'}, optional
An optical flow method from pysteps.motion.get_method.
analysis_time: numpy.datetime64
The analysis time of the NWP forecast. The analysis time is assumed to be a
numpy.datetime64 type as imported by the pysteps importer.
nwp_model: str
The name of the NWP model.
output_path: str, optional
The location where to save the file with the NWP velocity fields. Defaults
to the path_workdir specified in the rcparams file.

Returns
-------
Nothing
pysteps/blending/utils.py