ens_pearson_r¶
- hydrostats.ens_metrics.ens_pearson_r(obs: ndarray[tuple[Any, ...], dtype[floating | integer]], fcst_ens: ndarray[tuple[Any, ...], dtype[floating | integer]], remove_neg: bool = False, remove_zero: bool = False, reference: str = 'mean') floating[Any]¶
Calculate the pearson correlation coefficient between observed values and the ensemble mean.
- Parameters:
obs – Array of observations for each start date.
fcst_ens – Array of ensemble forecast of dimension n x M, where n = number of start dates and M = number of ensemble members.
remove_neg – If True, when a negative value is found at the i-th position in the observed OR ensemble array, the i-th value of the observed AND ensemble array are removed before the computation.
remove_zero – If true, when a zero value is found at the i-th position in the observed OR ensemble array, the i-th value of the observed AND ensemble array are removed before the computation.
reference – Determines the reference series against which to calculate the error. Choices are ‘mean’ and ‘median’.
- Returns:
The pearson correlation coefficient between the observed time series data and the ensemble mean.
- Return type:
Examples
>>> import numpy as np >>> import hydrostats.ens_metrics as em >>> np.random.seed(3849590438)
Creating an observed 1D array and an ensemble 2D array
>>> ensemble_array = (np.random.rand(100, 52) + 1) * 100 >>> observed_array = (np.random.rand(100) + 1) * 100
Computing the MSE between the ensemble mean and the observed data
>>> em.ens_pearson_r(obs=observed_array, fcst_ens=ensemble_array) -0.13236871294739733