EOF Analysis¶
- pygeode.EOF(x, num=1, iaxis=None, weight=True, out=None)[source]¶
Computes the leading Empirical Orthogonal Function(s) for the given variable.
- Parameters
- xVar object
The data of interest
- numinteger, optional
The number of leading EOFs to calculate. Default is
1
.- iaxisAxis object, Axis class, string, or integer, optional
Which axis/axes to treat as the record axis. Multiple axes can be passed as a tuple. Default is the
Time
axis of the data (if found), otherwise the leftmost axis.- weightVar object or boolean, optional
Weights to use use for the orthogonality condition. If
True
, it uses whatever internal weights the variable posesses. IfFalse
orNone
, it doesn’t use any weights. You can also pass in a Var object with explicit weights. Default isTrue
.- outstring, optional
Which outputs to return. This is a comma-separated string, built from the following keywords:
keyword
meaning
EOF
The EOFs (normalized to unit variance)
EIG
Eigenvalues (of the singular value decomposition of the variable). If you want the eigenvalues of the covariance matrix, square these, or use EIG2).
EIG2
Eigenvalues (of the covariance matrix)
VAR
Variance (a single scalar value).
FRAC
Fraction of total variance explained by each EOF.
PC
Principal components (timeseries data), normalized to unit variance.
Default is
'EOF,EIG,PC'
- Returns
- eof_decompositiontuple
A combination of EOFs, eignenvalues or other computed quantities specified by
out
.
Notes
This routine doesn’t do any pre-processing of the data, such as removing the mean or detrending. If you want to work with anomalies, then you’ll have to first compute the anomalies!
This routine tries to automatically determine the best way to solve the EOFs. If you want to use a particular method, you can call the following functions (with the same parameters):
function
behaviour
EOF_iter
Iterative solver (uses a variant of the power method).
EOF_cov
Calculates the full covariance matrix, and then does an explicit eigendecomposition.
EOF_svd
Does an explicit singular value decomposition on the data.
EOF_guess
Returns an approximation of the EOF decomposition from one pass through the data. This may be useful if you have a large dataset, and you just want the qualitative features of the EOF spatial patterns.
- pygeode.SVD(var1, var2, num=1, subspace=-1, iaxis=<class 'pygeode.timeaxis.Time'>, weight1=True, weight2=True, matrix='cov')[source]¶
Finds coupled EOFs of two fields. Note that the mean/trend/etc. is NOT removed in this routine.
- Parameters
- var1, var2
Var
The variables to analyse.
- numinteger
The number of EOFs to compute (default is
1
).- weight1, weight2optional
Weights to use for defining orthogonality in the var1, var2 domains, respectively. Patterns X and Y in the var1 domain are orthogonal if the sum over X*Y*weights1 is 0. Patterns Z and W in the var2 domain are orthogonal if the sum over Z*W*weights2 is 0. Default is to use internal weights defined for var1 accessed by
Var.getweights()
. If set toFalse
no weighting is used.- matrixstring, optional [‘cov’]
- Which matrix we are diagonalizing (default is ‘cov’).
‘cov’: covariance matrix of var1 & var2
‘cov’: correlation matrix of var1 & var2
- iaxisAxis identifier
The principal component / expansion coefficient axis, i.e., the ‘time’ axis. Can be an integer (the axis number, leftmost = 0), the axis name (string), or a Pygeode axis class. If not specified, will try to use pygeode.timeaxis.Time, and if that fails, the leftmost axis.
- var1, var2
- Returns
- (eof1, pc1, eof2, pc2): tuple
eof1: The coupled eof patterns for var1.
pc1: The principal component / expansion coefficients for var1.
eof2: The coupled eof patterns for var2.
pc2: The principal component / expansion coefficients for var2.
Notes
Multiple orders of EOFs are concatenated along an ‘order’ axis.