eof¶
-
eof(data, /, neof=5, axis_time=- 2, axis_space=- 1, weights=None, percent=False, normalize=False)[source]¶ Calculate the first
NEOFs using the scipy algorithm for Hermetian matrices on the covariance matrix.- Parameters
data (array-like) – Data of arbitrary shape.
neof (int, optional) – Number of eigenvalues we want.
axis_time (int, optional) – Axis used as the ‘record’ or ‘time’ dimension.
axis_space (int or list of int, optional) – Axis or axes used as ‘space’ dimension.
weights (array-like, optional) – Area or mass weights; must be broadcastable on multiplication with
dataweights. Will be normalized prior to application.percent (bool, optional) – Whether to return raw eigenvalue(s) or the percentage of total variance explained by eigenvalue(s). Default is
False.normalize (bool, optional) – Whether to normalize the data by its standard deviation at every point prior to obtaining the EOFs.
- Returns
pcs (array-like) – The standardized principal components. The
axis_spacedimensions are reduced to length 1.projs (array-like) – Projections of the standardized principal components onto the original data. The
axis_timedimension is reduced to length 1.evals – If
percentisFlase, these are the eigenvalues. Otherwise, this is the percentage of total variance explained by the corresponding eigenvector. Theaxis_timeandaxis_spacedimensions are reduced to length 1.nstars – The approximate degrees of freedom as determined by the [Wil11] autocorrelation critereon. This can be used to compute the approximate 95% error bounds for the eigenvalues using the [NBCM82] critereon of \(\lambda \sqrt{2 / N^*}\). The
axis_timeandaxis_spacedimensions are reduced to length 1.
Example
>>> from climopy.internals.array import logger, logging ... import xarray as xr ... import climopy as climo ... data = xr.DataArray( ... np.random.rand(10, 6, 100, 40, 20), ... dims=('member', 'run', 'time', 'plev', 'lat'), ... coords={ ... 'member': np.arange(1, 11), ... 'run': np.arange(1, 7), ... 'time': np.arange(100.0), ... 'plev': np.linspace(0.0, 1000.0, 40), ... 'lat': np.linspace(-90.0, 90.0, 20), ... } ... ) ... pcs, projs, evals, nstars = climo.eof(data, axis_time=2, axis_space=(3, 4))
References
- NBCM82
Gerald R. North, Thomas L. Bell, Robert F. Cahalan, and Fanthune J. Moeng. Sampling Errors in the Estimation of Empirical Orthogonal Functions. Monthly Weather Review, 110(7):699–706, July 1982. doi:10.1175/1520-0493(1982)110<0699:SEITEO>2.0.CO;2.
- Wil11
Daniel S. Wilks. Statistical Methods in the Atmospheric Sciences. Academic Press, Amsterdam ; Boston, 3 edition edition, June 2011. ISBN 978-0-12-385022-5.