pysteps.utils.pca.pca_transform#
- pysteps.utils.pca.pca_transform(forecast_ens: ndarray, mask: ndarray | None = None, pca_params: dict | None = None, get_params: bool = False, **kwargs: dict)#
Transform ensemble forecasts from physical space into principal component (PC) space.
- Parameters:
forecast_ens (np.ndarray) – Array of shape (n_ens, n_features) containing the ensemble forecasts in physical space.
mask (np.ndarray, optional) – Mask to transform only grid points at which at least 10 ensemble members have forecast precipitation, to fulfill the Lien criterion (Lien et al., 2013) mentioned in Nerini et al., 2019. The default is None.
pca_params (dict, optional) – Preconstructed Principal Component Analysis (PCA) object. If given, this is used instead of fitting a new PCA. The default is None.
get_params (bool, optional) – If True, return the PCA parameters in addition to the transformed data. The default is False.
n_components (int) – Number of principal components to retain.
svd_solver ({'auto', 'full', 'covariance_eigh', 'arpack', 'randomized'}) – Solver to use for the singular value decomposition. For details, see the documentation of
sklearn.decomposition.PCA.
- Returns:
forecast_ens_pc (np.ndarray) – Array of shape (n_components, n_ens) containing the ensemble forecasts transformed into PC space. If no mask is given, the full dataset is transformed; otherwise only the mask-filtered values are transformed.
pca_params (dict, optional) – Dictionary containing the PCA parameters, returned if
get_params=True. The dictionary has the following keys:- principal_componentsnp.ndarray
Array of shape (n_components, n_features) containing the principal component vectors in feature space.
- meannp.ndarray
Array of shape (n_features,) containing the per-feature empirical mean estimated from the input data.
- explained_variancenp.ndarray
Array of shape (n_features,) containing the per-feature explained variance ratio.