geocat.comp.eofunc.eofunc_pcs
geocat.comp.eofunc.eofunc_pcs#
- geocat.comp.eofunc.eofunc_pcs(data, npcs=1, time_dim=0, pcscaling=0, weights=None, center=True, ddof=1, meta=False)#
Deprecated since version 2022.10.0: The
eofunc
module is deprecated.eofunc_pcs
has been moved to thestats
module for future use. Usegeocat.comp.eofunc_pcs
orgeocat.comp.stats.eofunc_pcs
for the same functionality.Computes the principal components (time projection) in the empirical orthogonal function analysis.
This implementation uses eofs package, which is built upon the following study: Dawson, Andrew, “eofs: A library for EOF analysis of meteorological, oceanographic, and climate data,” Journal of Open Research Software, vol. 4, no. 1, 2016. Further information about this package can be found at: https://ajdawson.github.io/eofs/latest/index.html#
This implementation provides a few conveniences to the user on top of
eofs
package that are described below in the Parameters section.Note
Note:
eofunc_pcs
allows to perform the analysis that was previously done via the NCL functioneofunc_ts
. However, there are a few changes to the NCL flow such as:Only np.nan is supported as missing value,
EOFs are computed only from covariance matrix and there is no support for computation from correlation matrix,
percentage of non-missing points that must exist at any single point is no longer an input.
- Parameters
data (
xarray.DataArray
ornumpy.ndarray
orlist
) – Should contain numbers or np.nan for missing value representation. It must be at least a 2-dimensional array. Function assumes the left-most dimension is thetime
dimension. If input isxarray.DataArray
, the time dimension must be named “time”. If input is anumpy.ndarray
or alist
, this function still assumes the left-most dimension to be the number of observations ortime
dimension: however the user is allowed to input otherwise using thetime_dim
parameter.npcs (
int
, optional) – A scalar integer that specifies the number of principal components (i.e. eigenvalues and eigenvectors) to be returned. This is usually less than or equal to the minimum number of observations or number of variables. Defaults to 1.time_dim (
int
, optional) – An integer defining the time dimension. When input data is of typexarray.DataArray
, this is ignored It must be between0
anddata.ndim - 1
or it could be-1
indicating the last dimension. Defaults to 0.Note: The
time_dim
argument allows to perform the EOF analysis that was previously done via the NCL functioneofunc_n
.pcscaling (
int
, optional) –- (From
eofs
package): Sets the scaling of the retrieved PCs. The following values are accepted: 0 : Un-scaled PCs (default).
1 : PCs are divided by the square-root of their eigenvalues.
2 : PCs are multiplied by the square-root of their eigenvalues.
- (From
weights (array_like, optional) – (From
eofs
package): An array of weights whose shape is compatible with those of the input array dataset. The weights can have the same shape as dataset or a shape compatible with an array broadcast (i.e., the shape of the weights can can match the rightmost parts of the shape of the input array dataset). If the input array dataset does not require weighting then the value None may be used. Defaults toNone
(no weighting).center (
bool
, optional) – (Fromeofs
package): If True, the mean along the first axis of dataset (the time-mean) will be removed prior to analysis. If False, the mean along the first axis will not be removed. Defaults to True (mean is removed).The covariance interpretation relies on the input data being anomaly data with a time-mean of 0. Therefore this option should usually be set to True. Setting this option to True has the useful side effect of propagating missing values along the time dimension, ensuring that a solution can be found even if missing values occur in different locations at different times.
ddof (
int
, optional) – (Fromeofs
package): ‘Delta degrees of freedom’. The divisor used to normalize the covariance matrix is N - ddof where N is the number of samples. Defaults to 1.meta (
bool
, optional) – If set to True and the input array is an Xarray, the metadata from the input array will be copied to the output array. Defaults to False.
See also
Related NCL Functions: eofunc_ts, eofunc_ts_Wrap, eofunc_ts_n, eofunc_ts_n_Wrap