def zero_precipitation_forecast(
    n_ens_members,
    timesteps,
    precip,
    callback,
    return_output,
    measure_time,
    start_time_init,
):
    """
    Generate a zero-precipitation forecast (filled with the minimum precip value)
    when no precipitation above the threshold is detected. The forecast is
    optionally returned or passed to a callback.

    Parameters
    ----------
    n_ens_members: int, optional
        The number of ensemble members to generate.
    timesteps: int or list of floats
        Number of time steps to forecast or a list of time steps for which the
        forecasts are computed (relative to the input time step). The elements
        of the list are required to be in ascending order.
    precip: array-like
        Array of shape (ar_order+1,m,n) containing the input precipitation fields
        ordered by timestamp from oldest to newest. The time steps between the
        inputs are assumed to be regular.
    callback: function, optional
        Optional function that is called after computation of each time step of
        the nowcast. The function takes one argument: a three-dimensional array
        of shape (n_ens_members,h,w), where h and w are the height and width
        of the input precipitation fields, respectively. This can be used, for
        instance, writing the outputs into files.
    return_output: bool, optional
        Set to False to disable returning the outputs as numpy arrays. This can
        save memory if the intermediate results are written to output files using
        the callback function.
    measure_time: bool
        If set to True, measure, print and return the computation time.
    start_time_init: float
        The value of the start time counter used to compute total run time.

    Returns
    -------
    out: ndarray
        If return_output is True, a four-dimensional array of shape
        (n_ens_members,num_timesteps,m,n) containing a time series of forecast
        precipitation fields for each ensemble member. Otherwise, a None value
        is returned. The time series starts from t0+timestep, where timestep is
        taken from the input precipitation fields. If measure_time is True, the
        return value is a three-element tuple containing the nowcast array, the
        initialization time of the nowcast generator and the time used in the
        main loop (seconds).
    """
    print("No precipitation above the threshold found in the radar field")
    print("The resulting forecast will contain only zeros")
    return_single_member = False
    if n_ens_members is None:
        n_ens_members = 1
        return_single_member = True
    # Create the output list
    precip_forecast = [[] for j in range(n_ens_members)]

    # Save per time step to ensure the array does not become too large if
    # no return_output is requested and callback is not None.
    timesteps, _, __ = create_timestep_range(timesteps)
    for t, subtimestep_idx in enumerate(timesteps):
        # If the timestep is not the first one, we need to provide the zero forecast
        if t > 0:
            # Create an empty np array with shape [n_ens_members, rows, cols]
            # and fill it with the minimum value from precip (corresponding to
            # zero precipitation)
            N, M = precip.shape[1:]
            precip_forecast_workers = np.full((n_ens_members, N, M), np.nanmin(precip))
            if subtimestep_idx:
                if callback is not None:
                    if precip_forecast_workers.shape[1] > 0:
                        callback(precip_forecast_workers.squeeze())
                if return_output:
                    for j in range(n_ens_members):
                        precip_forecast[j].append(precip_forecast_workers[j])
            precip_forecast_workers = None

    if measure_time:
        zero_precip_time = time.time() - start_time_init

    if return_output:
        precip_forecast_all_members_all_times = np.stack(
            [np.stack(precip_forecast[j]) for j in range(n_ens_members)]
        )
        if return_single_member:
            precip_forecast_all_members_all_times = (
                precip_forecast_all_members_all_times[0]
            )

        if measure_time:
            return (
                precip_forecast_all_members_all_times,
                zero_precip_time,
                zero_precip_time,
            )
        else:
            return precip_forecast_all_members_all_times
    else:
        return None
Generate a zero-precipitation forecast (filled with the minimum precip value)
when no precipitation above the threshold is detected. The forecast is
optionally returned or passed to a callback.

Parameters
----------
n_ens_members: int, optional
The number of ensemble members to generate.
timesteps: int or list of floats
Number of time steps to forecast or a list of time steps for which the
forecasts are computed (relative to the input time step). The elements
of the list are required to be in ascending order.
precip: array-like
Array of shape (ar_order+1,m,n) containing the input precipitation fields
ordered by timestamp from oldest to newest. The time steps between the
inputs are assumed to be regular.
callback: function, optional
Optional function that is called after computation of each time step of
the nowcast. The function takes one argument: a three-dimensional array
of shape (n_ens_members,h,w), where h and w are the height and width
of the input precipitation fields, respectively. This can be used, for
instance, writing the outputs into files.
return_output: bool, optional
Set to False to disable returning the outputs as numpy arrays. This can
save memory if the intermediate results are written to output files using
the callback function.
measure_time: bool
If set to True, measure, print and return the computation time.
start_time_init: float
The value of the start time counter used to compute total run time.

Returns
-------
out: ndarray
If return_output is True, a four-dimensional array of shape
(n_ens_members,num_timesteps,m,n) containing a time series of forecast
precipitation fields for each ensemble member. Otherwise, a None value
is returned. The time series starts from t0+timestep, where timestep is
taken from the input precipitation fields. If measure_time is True, the
return value is a three-element tuple containing the nowcast array, the
initialization time of the nowcast generator and the time used in the
main loop (seconds).
pysteps/nowcasts/utils.py