mtspec - Python Bindings for multitaper "mtspec" f90 Library by German A. Prieto
We are currently in the process of moving the project to GitHub. It was originally hosted at https://svn.geophysik.uni-muenchen.de/trac/mtspecpy/wiki.
mtspec is a Python (ctypes) wrapper for the Multitaper Spectrum Estimation Library mwlib.a by Germán A. Prieto.
Prieto, G. A., R. L. Parker, F. L. Vernon. (2009), A Fortran 90 library for multitaper spectrum analysis, Computers and Geosciences, 35, pp. 1701-1710. doi:10.1016/ j.cageo.2008.06.007
It currently wraps version 3.1 of the library. This is mainly due to later versions using FFTW which would introduce additional dependency.
The following methods are currently wrapped:
- mtspec: Wrapper method for the mtspec subroutine.
- sine_psd: Wrapper method for the sine_psd subroutine.
- wigner_ville_spectrum: Wrapper method of the modified wv_spec (wv_spec_to_array) subroutine.
- mt_coherence: Construct the coherence spectrum from the yk’s and the weights of the usual multitaper spectrum estimation.
- dpss: Wrapper method for the dpss subroutine in the library.
Documentation and Tutorial
- Currently runs on Linux (32 and 64bit), Mac (32 and 64bit) and Windows (only 32bit).
- Dependencies: numpy, distribute, gfortran (not necessary for win32)
After cloning the repository, run either of the following two commands to install it via easy_install or pip, respectively:
python setup.py install or pip install .
Running the tests
Running the tests is a simple case of
python -m mtspec.tests
In case you get the error message "Internal Error: printf is broken" you can use the following workaround:
export LC_ALL=C python script.py
This is a known gfortran bug, see the bottom of http://projects.scipy.org/scipy/ticket/696 for an explanation.