Note
eof2 has been replaced by eofs. eof2 is still functional but it is not likely to be maintained any further. Please consider switching to eofs for new installations.
eof2 is a Python package for EOF analysis of spatial-temporal data. Some of the key features of eof2 are:
The package can be downloaded from github. To get the latest source and install the module on your system run:
$ git clone git://github.com/ajdawson/eof2.git
$ cd eof2
$ sudo python setup.py install
or download a zip file from the project’s code page.
The eof2 package provides two interfaces for EOF analysis: one for numpy arrays or masked arrays; and one for cdms2 variables, which preserves metadata. The two interfaces support exactly the same sets of operations.
Regardless of which interface you use, the basic usage is the same. The EOF analysis is handled by eof2.Eof (or eof2.EofSolver for the numpy interface). The EOF solution is computed when an instance of eof2.Eof (or eof2.EofSolver) is initialized. Method calls are then used to return quantities of interest.
The following is a very simple illustrative example which computes the leading 2 EOFs of a temporal spatial field:
import cdms2
from eof2 import Eof
# Read a spatial-temporal field. Time must be the first dimension.
ncin = cdms2.open('sst_monthly.nc')
sst = ncin('sst')
ncin.close()
# Initialize and Eof object. Square-root of cosine of latitude weights
# are used.
solver = Eof(sst, weights='coslat')
# Retrieve the first two EOFs.
eofs = solver.eofs(neofs=2)