pysteps.nowcasts.linda.forecast(precip, velocity, timesteps, feature_method='blob', max_num_features=25, feature_kwargs=None, ari_order=1, kernel_type='anisotropic', localization_window_radius=None, errdist_window_radius=None, acf_window_radius=None, extrap_method='semilagrangian', extrap_kwargs=None, add_perturbations=True, pert_thrs=(0.5, 1.0), n_ens_members=10, vel_pert_method='bps', vel_pert_kwargs=None, kmperpixel=None, timestep=None, seed=None, num_workers=1, use_multiprocessing=False, measure_time=False, callback=None, return_output=True)#

Generate a deterministic or ensemble nowcast by using the Lagrangian INtegro-Difference equation model with Autoregression (LINDA) model.

  • precip (array_like) – Array of shape (ari_order + 2, m, n) containing the input rain rate or reflectivity fields (in linear scale) ordered by timestamp from oldest to newest. The time steps between the inputs are assumed to be regular.

  • velocity (array_like) – Array of shape (2, m, n) containing the x- and y-components of the advection field. The velocities are assumed to represent one time step between the inputs.

  • timesteps (int) – Number of time steps to forecast.

  • feature_method ({'blob', 'domain' 'shitomasi'}) –

    Feature detection method:

    Method name



    Laplacian of Gaussian (LoG) blob detector implemented in scikit-image


    no feature detection, the model is applied over the whole domain without localization


    Shi-Tomasi corner detector implemented in OpenCV

    Default: ‘blob’

  • max_num_features (int, optional) – Maximum number of features to use. It is recommended to set this between 20 and 50, which gives a good tradeoff between localization and computation time. Default: 25

  • feature_kwargs (dict, optional) – Keyword arguments that are passed as **kwargs for the feature detector. See pysteps.feature.blob and pysteps.feature.shitomasi.

  • ari_order ({1, 2}, optional) – The order of the ARI(p, 1) model. Default: 1

  • kernel_type ({"anisotropic", "isotropic"}, optional) – The type of the kernel. Default: ‘anisotropic’

  • localization_window_radius (float, optional) – The standard deviation of the Gaussian localization window. Default: 0.2 * min(m, n)

  • errdist_window_radius (float, optional) – The standard deviation of the Gaussian window for estimating the forecast error distribution. Default: 0.15 * min(m, n)

  • acf_window_radius (float, optional) – The standard deviation of the Gaussian window for estimating the forecast error ACF. Default: 0.25 * min(m, n)

  • extrap_method (str, optional) – The extrapolation method to use. See the documentation of pysteps.extrapolation.interface. Default: ‘semilagrangian’

  • extrap_kwargs (dict, optional) – Optional dictionary containing keyword arguments for the extrapolation method. See pysteps.extrapolation.interface.

  • add_perturbations (bool) – Set to False to disable perturbations and generate a single deterministic nowcast. Default: True

  • pert_thrs (float) – Two-element tuple containing the threshold values for estimating the perturbation parameters (mm/h). Default: (0.5, 1.0)

  • n_ens_members (int, optional) – The number of ensemble members to generate. Default: 10

  • vel_pert_method ({'bps', None}, optional) – Name of the generator to use for perturbing the advection field. See pysteps.noise.interface. Default: ‘bps’

  • vel_pert_kwargs (dict, optional) – Optional dictionary containing keyword arguments ‘p_par’ and ‘p_perp’ for the initializer of the velocity perturbator. The choice of the optimal parameters depends on the domain and the used optical flow method. For the default values and parameters optimized for different domains, see pysteps.nowcasts.steps.forecast().

  • kmperpixel (float, optional) – Spatial resolution of the input data (kilometers/pixel). Required if vel_pert_method is not None.

  • timestep (float, optional) – Time step of the motion vectors (minutes). Required if vel_pert_method is not None.

  • seed (int, optional) – Optional seed for the random generators.

  • num_workers (int, optional) – The number of workers to use for parallel computations. Applicable if dask is installed. Default: 1

  • use_multiprocessing (bool, optional) – Set to True to improve the performance of certain parallelized parts of the code. If set to True, the main script calling linda.forecast must be enclosed within the ‘if __name__ == “__main__”:’ block. Default: False

  • measure_time (bool, optional) – If set to True, measure, print and return the computation time. Default: False

  • 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. Default: None

  • 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. Default: True


out – A four-dimensional array of shape (n_ens_members, timesteps, m, n) containing a time series of forecast precipitation fields for each ensemble member. If add_perturbations is False, the first dimension is dropped. The time series starts from t0 + timestep, where timestep is taken from the input 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). If return_output is set to False, a single None value is returned instead.

Return type:



It is recommended to choose the feature detector parameters so that the number of features is around 20-40. This gives a good tradeoff between localization and computation time.

It is highly recommented to set num_workers>1 to reduce computation time. In this case, it is advisable to disable OpenMP by setting the environment variable OMP_NUM_THREADS to 1. This avoids slowdown caused by too many simultaneous threads.