- pysteps.nowcasts.utils.nowcast_main_loop(precip, velocity, state, timesteps, extrap_method, func, extrap_kwargs=None, velocity_pert_gen=None, params=None, ensemble=False, num_ensemble_members=1, callback=None, return_output=True, num_workers=1, measure_time=False)#
Utility method for advection-based nowcast models that are applied in the Lagrangian coordinates. In addition, this method allows the case, where one or more components of the model (e.g. an autoregressive process) require using regular integer time steps but the user-supplied values are irregular or non-integer.
precip (array_like) – Array of shape (m,n) containing the most recently observed precipitation field.
velocity (array_like) – Array of shape (2,m,n) containing the x- and y-components of the advection field.
state (object) – The initial state of the nowcast model.
timesteps (int or list of floats) – Number of time steps to forecast or a list of time steps for which the forecasts are computed. The elements of the list are required to be in ascending order.
extrap_method (str, optional) – Name of the extrapolation method to use. See the documentation of
ensemble (bool) – Set to True to produce a nowcast ensemble.
num_ensemble_members (int) – Number of ensemble members. Applicable if ensemble is set to True.
func (function) – A function that takes the current state of the nowcast model and its parameters and returns a forecast field and the new state. The shape of the forecast field is expected to be (m,n) for a deterministic nowcast and (n_ens_members,m,n) for an ensemble.
extrap_kwargs (dict, optional) – Optional dictionary containing keyword arguments for the extrapolation method. See the documentation of pysteps.extrapolation.
velocity_pert_gen (list, optional) – Optional list of functions that generate velocity perturbations. The length of the list is expected to be n_ens_members. The functions are expected to take lead time (relative to timestep index) as input argument and return a perturbation field of shape (2,m,n).
params (dict, optional) – Optional dictionary containing keyword arguments for func.
callback (function, optional) – Optional function that is called after computation of each time step of the nowcast. The function takes one argument: the nowcast array. This can be used, for instance, writing output files.
return_output (bool, optional) – Set to False to disable returning the output forecast fields and return None instead. This can save memory if the intermediate results are instead written to files using the callback function.
num_workers (int, optional) – Number of parallel workers to use. Applicable if a nowcast ensemble is generated.
measure_time (bool, optional) – If set to True, measure, print and return the computation time.
out – List of forecast fields for the given time steps. If measure_time is True, return a pair, where the second element is the total computation time in the loop.
- Return type: