pysteps.postprocessing.probmatching.resample_distributions

pysteps.postprocessing.probmatching.resample_distributions#

pysteps.postprocessing.probmatching.resample_distributions(first_array, second_array, probability_first_array)#

Merges two distributions (e.g., from the extrapolation nowcast and NWP in the blending module) to effectively combine two distributions for probability matching without losing extremes. Entries for which one array has a nan will not be included from the other array either.

Parameters:
  • first_array (array_like) – One of the two arrays from which the distribution should be sampled (e.g., the extrapolation cascade). It must be of the same shape as second_array. Input must not contain NaNs.

  • second_array (array_like) – One of the two arrays from which the distribution should be sampled (e.g., the NWP (model) cascade). It must be of the same shape as first_array.. Input must not contain NaNs.

  • probability_first_array (float) – The weight that first_array should get (a value between 0 and 1). This determines the likelihood of selecting elements from first_array over second_array.

Returns:

csort – The combined output distribution. This is an array of the same shape as the input arrays, where each element is chosen from either first_array or second_array based on the specified probability, and then sorted in descending order.

Return type:

array_like

Raises:

ValueError – If first_array and second_array do not have the same shape.