pysteps.blending#

Implementation of blending methods for blending (ensemble) nowcasts with Numerical Weather Prediction (NWP) models.

pysteps.blending.interface#

Interface for the blending module. It returns a callable function for computing blended nowcasts with NWP models.

get_method(name)

Return a callable function for computing nowcasts blending into an NWP forecast.

pysteps.blending.clim#

Module with methods to read, write and compute past and climatological NWP model skill scores. The module stores the average daily skill score for the past t days and updates it every day. The resulting average climatological skill score is the skill the NWP model skill regresses to during the blended forecast. If no climatological values are present, the default skill from [BPS06] is used.

get_default_skill([n_cascade_levels, n_models])

Get the default climatological skill values as given in [BPS06].

save_skill(current_skill, validtime, outdir_path)

Add the current NWP skill to update today's daily average skill.

calc_clim_skill(outdir_path[, ...])

Return the climatological skill based on the daily average skill in the rolling window.

pysteps.blending.ens_kalman_filter_methods#

Methods to calculate the ensemble Kalman filter based correction methods for blending between nowcast and NWP. The core of the method occurs in the EnsembleKalmanFilter class. The specific method to use this core class can be selected. Currently, only the implementation of the ensemble Kalman filter from [NFL+19] is available.

Additional keyword arguments for the ensemble Kalman filter are:

n_tapering: int, default=0

Tapering parameter controlling the number of covariance pairs (i, i ± n_tapering) retained in the covariance matrix. With n_tapering=0, only the variances (main diagonal) of the principal components are kept.

non_precip_mask: bool, (True)

Flag to specify whether the computation should be truncated on grid boxes where at least a minimum number (configurable) of ensemble members forecast precipitation. Defaults to True.

n_ens_prec: int, (1)

Minimum number of ensemble members that forecast precipitation for the above mentioned mask. Defaults to 1.

lien_criterion: bool, (True)

Flag to specify whether Lien criterion (Lien et al., 2013) should be applied for the computation of the update step within the ensemble Kalman filter. Defaults to True.

n_lien: int, (n_ens_members/2)

Minimum number of ensemble members that forecast precipitation for the Lien criterion. Defaults to half of the ensemble members.

prob_matching: str, {‘iterative’,’post_forecast’,’none’}

Specify the probability matching method that should be applied as an additional processing step of the forecast computation. Defaults to ‘iterative’.

inflation_factor_bg: float, (1.0)

Inflation factor of the background (NWC) covariance matrix. This factor increases the covariances of the background ensemble and, thus, supports a faster convergence towards the observation ensemble (NWP). Defaults to 1.0.

inflation_factor_obs: float, (1.0)

Inflation factor of the observation (NWP) covariance matrix. This factor increases the covariances of the observation ensemble (NWP) and, thus, supports a slower convergence towards the observation ensemble. Defaults to 1.0.

offset_bg: float, (0.0)

Offset of the background (NWC) covariance matrix. This offset supports a faster convergence towards the observation ensemble (NWP) by linearly increasing all elements of the background covariance matrix. Defaults to 0.0.

offset_obs: float, (0.0)

Offset of the observation (NWP) covariance matrix. This offset supports a slower convergence towards the observation ensemble (NWP) by linearly incerasing all elements of the observation covariance matrix. Defaults to 0.0.

nwp_hres_eff: float

Effective horizontal resolution of the utilized NWP model.

sampling_prob_source: str, {‘ensemble’,’explained_var’}

Computation method of the sampling probability for the probability matching. ‘ensemble’ computes this probability as the ratio between the ensemble differences of analysis_ensemble - background_ensemble and observation_ensemble - background_ensemble. ‘explained_var’ uses the sum of the Kalman gain weighted by the explained variance ratio.

use_accum_sampling_prob: bool, (False)

Flag to specify whether the current sampling probability should be used for the probability matching or a probability integrated over the previous forecast time. Defaults to True.

ensure_full_nwp_weight: bool, (True)

Flag to specify whether the end of the combination should be represent the pure NWP forecast. Defaults to True.

pysteps.nowcasts.linear_blending#

Linear blending method to blend (ensemble) nowcasts and (ensemble) Numerical Weather Prediction (NWP) forecasts. The method uses a predefined start and end time for the blending. Before this start time, the resulting blended forecasts only consists of the nowcast(s). In between the start and end time, the nowcast(s) weight decreases and NWP forecasts weight increases linearly from 1(0) to 0(1). After the end time, the blended forecast entirely consists of the NWP forecasts. The saliency-based blending method also takes into account the pixel intensities and preserves them if they are strong enough based on their ranked salience.

Implementation of the linear blending and saliency-based blending between nowcast and NWP data.

forecast(precip, precip_metadata, velocity, ...)

Generate a forecast by linearly or saliency-based blending of nowcasts with NWP data

pysteps.blending.pca_ens_kalman_filter#

Implementation of the reduced-space ensemble Kalman filter method described in [NFL+19]. The nowcast is iteratively corrected by NWP data using an ensemble Kalman filter in principal component (PC) space. The reduced-space ensemble Kalman filter method consists of the following main steps:

Initialization step#

  1. Set the radar rainfall fields in a Lagrangian space.

  2. Perform the cascade decomposition for the input radar rainfall fields.

  3. Estimate AR parameters for the extrapolation nowcast and noise cascade.

  4. Initialize the noise method and precompute a set of noise fields.

  5. Initialize forecast models equal to the number of ensemble members.

  6. Initialize the ensemble Kalman filter method.

  7. Start the forecasting loop.

Forecast step#

  1. Decompose the rainfall forecast field of the previous timestep.

  2. Update the common precipitation mask of nowcast and NWP fields for noise imprint.

  3. Iterate the AR model.

  4. Recompose the rainfall forecast field.

  5. (Optional) Apply probability matching.

  6. Extrapolate the recomposed rainfall field to the current timestep.

Correction step#

  1. Identify grid boxes where rainfall is forecast.

  2. Reduce nowcast and NWP ensembles onto these grid boxes and apply principal component analysis to further reduce the dimensionality.

  3. Apply the update step of the ensemble Kalman filter.

Finalization#

  1. Set no-data values in the final forecast fields.

  2. The original approach iterates between forecast and correction steps. However, to reduce smoothing effects in this implementation, a pure forecast step is computed at the first forecast timestep, and afterwards the method alternates between correction and forecast steps. The smoothing effects arise due to the NWP effective horizontal resolution and due to the spatial decomposition at each forecast timestep.

forecast(obs_precip, obs_timestamps, ...[, ...])

Generate a combined nowcast ensemble by using the reduced-space ensemble Kalman filter method described in Nerini et al. 2019.

pysteps.blending.skill_scores#

Methods for computing skill scores, needed for the blending weights, of two- dimensional model fields with the latest observation field.

spatial_correlation(obs, mod, domain_mask)

Determine the spatial correlation between the cascade of the latest available observed (radar) rainfall field and a time-synchronous cascade derived from a model (generally NWP) field.

lt_dependent_cor_nwp(lt, correlations, ...)

Determine the correlation of a model field for lead time lt and cascade k, by assuming that the correlation determined at t=0 regresses towards the climatological values.

lt_dependent_cor_extrapolation(PHI[, ...])

Determine the correlation of the extrapolation (nowcast) component for lead time lt and cascade k, by assuming that the correlation determined at t=0 regresses towards the climatological values.

clim_regr_values(n_cascade_levels, outdir_path)

Obtains the climatological correlation values and regression parameters from a file called NWP_weights_window.bin in the outdir_path.

pysteps.blending.steps#

Implementation of the STEPS stochastic blending method as described in [BPS04], [BPS06], [SPN13] and [ICD+23]. The STEPS blending method consists of the following main steps:

  1. Set the radar rainfall fields in a Lagrangian space.

  2. Perform the cascade decomposition for the input radar rainfall fields. The method assumes that the cascade decomposition of the NWP model fields is already done prior to calling the function, as the NWP model fields are generally not updated with the same frequency (which is more efficient). A method to decompose and store the NWP model fields whenever a new NWP model field is present, is present in pysteps.blending.utils.decompose_NWP.

  3. Initialize the noise method (this will be bypassed if a deterministic nowcast is provided and n_ens_members is 1).

  4. Estimate AR parameters for the extrapolation nowcast and noise cascade.

  5. Initialize all the random generators.

  6. Calculate the initial skill of the NWP model forecasts at t=0.

  7. Start the forecasting loop:
    1. Determine which NWP models will be combined with which nowcast ensemble member. The number of output ensemble members equals the maximum number of (ensemble) members in the input, which can be either the defined number of (nowcast) ensemble members or the number of NWP models/members.

    2. Determine the skill and weights of the forecasting components (extrapolation, NWP and noise) for that lead time.

    3. Regress the extrapolation and noise cascades separately to the subsequent time step.

    4. Extrapolate the extrapolation and noise cascades to the current time step.

    5. Blend the cascades.

    6. Recompose the cascade to a rainfall field.

    7. Post-processing steps (masking and probability matching, which are different from the original blended STEPS implementation).

forecast(precip, precip_models, velocity, ...)

Generate a blended nowcast ensemble by using the Short-Term Ensemble Prediction System (STEPS) method.

calculate_ratios(correlations)

Calculate explained variance ratios from correlation.

calculate_weights_bps(correlations)

Calculate BPS blending weights for STEPS blending from correlation.

calculate_weights_spn(correlations, covariance)

Calculate SPN blending weights for STEPS blending from correlation.

blend_means_sigmas(means, sigmas, weights)

Calculate the blended means and sigmas, the normalization parameters needed to recompose the cascade.

pysteps.blending.utils#

Module with common utilities used by the blending methods.

stack_cascades(R_d[, donorm])

Stack the given cascades into a larger array.

blend_cascades(cascades_norm, weights)

Calculate blended normalized cascades using STEPS weights following eq.

recompose_cascade(combined_cascade, ...)

Recompose the cascades into a transformed rain rate field.

blend_optical_flows(flows, weights)

Combine advection fields using given weights.

decompose_NWP(R_NWP, NWP_model, ...[, ...])

Decomposes the NWP forecast data into cascades and saves it in a netCDF file

compute_store_nwp_motion(precip_nwp, ...)

Computes, per forecast lead time, the velocity field of an NWP model field.

load_NWP(input_nc_path_decomp, ...)

Loads the decomposed NWP and velocity data from the netCDF files

compute_smooth_dilated_mask(original_mask[, ...])

Compute a smooth dilated mask using Gaussian blur and dilation with varying kernel sizes.