Spectral Analysis in Python

Overview

SPECTRUM : Spectral Analysis in Python

https://github.com/cokelaer/spectrum/actions/workflows/main.yml/badge.svg?branch=master https://coveralls.io/repos/cokelaer/spectrum/badge.png?branch=master
contributions: Please join https://github.com/cokelaer/spectrum
contributors: https://github.com/cokelaer/spectrum/graphs/contributors
issues: Please use https://github.com/cokelaer/spectrum/issues
documentation: http://pyspectrum.readthedocs.io/
Citation: Cokelaer et al, (2017), 'Spectrum': Spectral Analysis in Python, Journal of Open Source Software, 2(18), 348, doi:10.21105/joss.00348

http://www.thomas-cokelaer.info/software/spectrum/html/_images/psd_all.png

Spectrum contains tools to estimate Power Spectral Densities using methods based on Fourier transform, Parametric methods or eigenvalues analysis:

  • The Fourier methods are based upon correlogram, periodogram and Welch estimates. Standard tapering windows (Hann, Hamming, Blackman) and more exotic ones are available (DPSS, Taylor, ...).
  • The parametric methods are based on Yule-Walker, BURG, MA and ARMA, covariance and modified covariance methods.
  • Non-parametric methods based on eigen analysis (e.g., MUSIC) and minimum variance analysis are also implemented.
  • Multitapering is also available

The targetted audience is diverse. Although the use of power spectrum of a signal is fundamental in electrical engineering (e.g. radio communications, radar), it has a wide range of applications from cosmology (e.g., detection of gravitational waves in 2016), to music (pattern detection) or biology (mass spectroscopy).

Quick Installation

spectrum is available on Pypi:

pip install spectrum

and conda:

conda config --append channels conda-forge
conda install spectrum

To install the conda executable itself, please see https://www.continuum.io/downloads .

Contributions

Please see github for any issues/bugs/comments/contributions.

Some notebooks (external contributions)

Comments
  • problem with dpss after update on scipy

    problem with dpss after update on scipy

    Spectrum was working perfectly in python 3.5 until I updated scipy to 0.18.1. Now I get this error:

    In[2]: import spectrum as spec In [3]: spec.dpss(512,3,5)

    TypeError Traceback (most recent call last) in () ----> 1 spec.dpss(512,3,5)

    C:\Python\Anaconda\lib\site-packages\spectrum-0.6.1-py3.5-win-amd64.egg\spectrum \mtm.py in dpss(N, NW, k) 298 299 # The values returned in lam are not exacly the same as in the follo wing methods. --> 300 acvs = _autocov(tapers.transpose(), debias=False) * N 301 nidx = arange(N) 302 W = float(NW)/N

    C:\Python\Anaconda\lib\site-packages\spectrum-0.6.1-py3.5-win-amd64.egg\spectrum \mtm.py in _autocov(s, **kwargs) 386 s = remove_bias(s, axis) 387 kwargs['debias'] = False --> 388 return _crosscov(s, s, **kwargs) 389 390

    C:\Python\Anaconda\lib\site-packages\spectrum-0.6.1-py3.5-win-amd64.egg\spectrum \mtm.py in _crosscov(x, y, axis, all_lags, debias) 422 slicing = [slice(d) for d in x.shape] 423 slicing[axis] = slice(None,None,-1) --> 424 sxy = _fftconvolve(x, y[tuple(slicing)], axis=axis, mode='full') 425 N = x.shape[axis] 426 sxy /= N

    C:\Python\Anaconda\lib\site-packages\spectrum-0.6.1-py3.5-win-amd64.egg\spectrum \mtm.py in _fftconvolve(in1, in2, mode, axis) 506 ret = ifftn(IN1)[fslice].copy() 507 else: --> 508 IN1 = fft(in1,fsize,axis=axis) 509 IN1 *= fft(in2,fsize,axis=axis) 510 ret = ifft(IN1,axis=axis)[fslice].copy()

    C:\Python\Anaconda\lib\site-packages\scipy\fftpack\basic.py in fft(x, n, axis, o verwrite_x) 265 n = tmp.shape[axis] 266 elif n != tmp.shape[axis]: --> 267 tmp, copy_made = _fix_shape(tmp,n,axis) 268 overwrite_x = overwrite_x or copy_made 269

    C:\Python\Anaconda\lib\site-packages\scipy\fftpack\basic.py in _fix_shape(x, n, axis) 151 index[axis] = slice(0,s[axis]) 152 s[axis] = n --> 153 z = zeros(s,x.dtype.char) 154 z[index] = x 155 return z, True

    TypeError: 'numpy.float64' object cannot be interpreted as an integer

    opened by senis000 7
  • Package is not installed on Wondows !!

    Package is not installed on Wondows !!

    I used the command "pip install spectrum" to installing spectrum package but it was not installed and I got error (end of this issue). I use windows 7, MinGW, python 2.7.7 and anaconda distribution.

    last part of error:

    c:\mingw\lib\gcc\mingw32\4.8.1\include\stddef.h:1:29: error: stray '\240' in pro
    gram
    
    c:\mingw\lib\gcc\mingw32\4.8.1\include\stddef.h:1:29: error: stray '\17' in prog
    ram
    
    c:\mingw\lib\gcc\mingw32\4.8.1\include\stddef.h:1:29: error: stray '\350' in pro
    gram
    
    c:\mingw\lib\gcc\mingw32\4.8.1\include\stddef.h:1:29: error: stray '\3' in progr
    am
    
    c:\mingw\lib\gcc\mingw32\4.8.1\include\stddef.h:1:29: error: stray '\350' in pro
    gram
    
    c:\mingw\lib\gcc\mingw32\4.8.1\include\stddef.h:1:29: error: stray '\3' in progr
    am
    
    c:\mingw\lib\gcc\mingw32\4.8.1\include\stddef.h:1:29: error: stray '\320' in pro
    gram
    
    c:\mingw\lib\gcc\mingw32\4.8.1\include\stddef.h:1:29: error: stray '\7' in progr
    am
    
    c:\mingw\lib\gcc\mingw32\4.8.1\include\stddef.h:1:29: error: stray '\320' in pro
    gram
    
    c:\mingw\lib\gcc\mingw32\4.8.1\include\stddef.h:1:29: error: stray '\7' in progr
    am
    
    c:\mingw\lib\gcc\mingw32\4.8.1\include\stddef.h:1:29: error: stray '\36' in prog
    ram
    
    c:\mingw\lib\gcc\mingw32\4.8.1\include\stddef.h:1:29: error: stray '\24' in prog
    ram
    
    c:\mingw\lib\gcc\mingw32\4.8.1\include\stddef.h:1:29: error: stray '\350' in pro
    gram
    
    c:\mingw\lib\gcc\mingw32\4.8.1\include\stddef.h:1:29: error: stray '\3' in progr
    am
    
    c:\mingw\lib\gcc\mingw32\4.8.1\include\stddef.h:1:29: error: stray '\372' in pro
    gram
    
    c:\mingw\lib\gcc\mingw32\4.8.1\include\stddef.h:1:29: error: stray '\372' in pro
    gram
    
    c:\mingw\lib\gcc\mingw32\4.8.1\include\stddef.h:1:29: error: stray '\320' in pro
    gram
    
    c:\mingw\lib\gcc\mingw32\4.8.1\include\stddef.h:1:29: error: stray '\7' in progr
    am
    
    c:\mingw\lib\gcc\mingw32\4.8.1\include\stddef.h:1:29: error: stray '\320' in pro
    gram
    
    c:\mingw\lib\gcc\mingw32\4.8.1\include\stddef.h:1:29: error: stray '\7' in progr
    am
    
    c:\mingw\lib\gcc\mingw32\4.8.1\include\stddef.h:1:29: error: stray '\36' in prog
    ram
    
    c:\mingw\lib\gcc\mingw32\4.8.1\include\stddef.h:1:29: error: stray '\24' in prog
    ram
    
    c:\mingw\lib\gcc\mingw32\4.8.1\include\stddef.h:1:29: error: stray '\270' in pro
    gram
    
    c:\mingw\lib\gcc\mingw32\4.8.1\include\stddef.h:1:29: error: stray '\364' in pro
    gram
    
    c:\mingw\lib\gcc\mingw32\4.8.1\include\stddef.h:1:29: error: stray '\1' in progr
    am
    
    c:\mingw\lib\gcc\mingw32\4.8.1\include\stddef.h:1:29: error: stray '\364' in pro
    gram
    
    c:\mingw\lib\gcc\mingw32\4.8.1\include\stddef.h:1:29: error: stray '\1' in progr
    am
    
    c:\mingw\lib\gcc\mingw32\4.8.1\include\stddef.h:1:29: error: stray '\320' in pro
    gram
    
    c:\mingw\lib\gcc\mingw32\4.8.1\include\stddef.h:1:29: error: stray '\7' in progr
    am
    
    c:\mingw\lib\gcc\mingw32\4.8.1\include\stddef.h:1:29: error: stray '\320' in pro
    gram
    
    c:\mingw\lib\gcc\mingw32\4.8.1\include\stddef.h:1:29: error: stray '\7' in progr
    am
    
    c:\mingw\lib\gcc\mingw32\4.8.1\include\stddef.h:1:29: error: stray '\36' in prog
    ram
    
    c:\mingw\lib\gcc\mingw32\4.8.1\include\stddef.h:1:29: error: stray '\24' in prog
    ram
    
    c:\mingw\lib\gcc\mingw32\4.8.1\include\stddef.h:1:29: error: stray '\304' in pro
    gram
    
    c:\mingw\lib\gcc\mingw32\4.8.1\include\stddef.h:1:29: error: stray '\364' in pro
    gram
    
    c:\mingw\lib\gcc\mingw32\4.8.1\include\stddef.h:1:29: error: stray '\1' in progr
    am
    
    c:\mingw\lib\gcc\mingw32\4.8.1\include\stddef.h:1:29: error: stray '\364' in pro
    gram
    
    c:\mingw\lib\gcc\mingw32\4.8.1\include\stddef.h:1:29: error: stray '\1' in progr
    am
    
    c:\mingw\lib\gcc\mingw32\4.8.1\include\stddef.h:1:29: error: stray '\320' in pro
    gram
    
    c:\mingw\lib\gcc\mingw32\4.8.1\include\stddef.h:1:29: error: stray '\7' in progr
    am
    
    c:\mingw\lib\gcc\mingw32\4.8.1\include\stddef.h:1:29: error: stray '\320' in pro
    gram
    
    c:\mingw\lib\gcc\mingw32\4.8.1\include\stddef.h:1:29: error: stray '\7' in progr
    am
    
    c:\mingw\lib\gcc\mingw32\4.8.1\include\stddef.h:1:29: error: stray '\36' in prog
    ram
    
    c:\mingw\lib\gcc\mingw32\4.8.1\include\stddef.h:1:29: error: stray '\24' in prog
    ram
    
    c:\mingw\lib\gcc\mingw32\4.8.1\include\stddef.h:1:29: error: stray '\364' in pro
    gram
    
    c:\mingw\lib\gcc\mingw32\4.8.1\include\stddef.h:1:29: error: stray '\1' in progr
    am
    
    c:\mingw\lib\gcc\mingw32\4.8.1\include\stddef.h:1:29: error: stray '\364' in pro
    gram
    
    c:\mingw\lib\gcc\mingw32\4.8.1\include\stddef.h:1:29: error: stray '\1' in progr
    am
    
    c:\mingw\lib\gcc\mingw32\4.8.1\include\stddef.h:1:29: error: stray '\320' in pro
    gram
    
    c:\mingw\lib\gcc\mingw32\4.8.1\include\stddef.h:1:29: error: stray '\7' in progr
    am
    
    c:\mingw\lib\gcc\mingw32\4.8.1\include\stddef.h:1:29: error: stray '\320' in pro
    gram
    
    c:\mingw\lib\gcc\mingw32\4.8.1\include\stddef.h:1:29: error: stray '\7' in progr
    am
    
    c:\mingw\lib\gcc\mingw32\4.8.1\include\stddef.h:1:29: error: stray '\36' in prog
    ram
    
    c:\mingw\lib\gcc\mingw32\4.8.1\include\stddef.h:1:29: error: stray '\24' in prog
    ram
    
    c:\mingw\lib\gcc\mingw32\4.8.1\include\stddef.h:1:29: error: stray '\210' in pro
    gram
    
    c:\mingw\lib\gcc\mingw32\4.8.1\include\stddef.h:1:29: error: stray '\23' in prog
    ram
    
    c:\mingw\lib\gcc\mingw32\4.8.1\include\stddef.h:1:29: error: stray '\364' in pro
    gram
    
    c:\mingw\lib\gcc\mingw32\4.8.1\include\stddef.h:1:29: error: stray '\1' in progr
    am
    
    c:\mingw\lib\gcc\mingw32\4.8.1\include\stddef.h:1:29: error: stray '\364' in pro
    gram
    
    c:\mingw\lib\gcc\mingw32\4.8.1\include\stddef.h:1:29: error: stray '\1' in progr
    am
    
    c:\mingw\lib\gcc\mingw32\4.8.1\include\stddef.h:1:29: error: stray '\320' in pro
    gram
    
    c:\mingw\lib\gcc\mingw32\4.8.1\include\stddef.h:1:29: error: stray '\7' in progr
    am
    
    c:\mingw\lib\gcc\mingw32\4.8.1\include\stddef.h:1:29: error: stray '\320' in pro
    gram
    
    c:\mingw\lib\gcc\mingw32\4.8.1\include\stddef.h:1:29: error: stray '\7' in progr
    am
    
    c:\mingw\lib\gcc\mingw32\4.8.1\include\stddef.h:1:29: error: stray '\36' in prog
    ram
    
    c:\mingw\lib\gcc\mingw32\4.8.1\include\stddef.h:1:29: error: stray '\24' in prog
    ram
    
    c:\mingw\lib\gcc\mingw32\4.8.1\include\stddef.h:1:29: error: stray '\5' in progr
    am
    
    c:\mingw\lib\gcc\mingw32\4.8.1\include\stddef.h:1:29: error: stray '\5' in progr
    am
    
    c:\mingw\lib\gcc\mingw32\4.8.1\include\stddef.h:1:29: error: stray '\5' in progr
    am
    
    c:\mingw\lib\gcc\mingw32\4.8.1\include\stddef.h:1:29: error: stray '\3' in progr
    am
    
    c:\mingw\lib\gcc\mingw32\4.8.1\include\stddef.h:1:29: error: stray '\3' in progr
    am
    
    c:\mingw\lib\gcc\mingw32\4.8.1\include\stddef.h:1:29: error: stray '\3' in progr
    am
    
    c:\mingw\lib\gcc\mingw32\4.8.1\include\stddef.h:1:29: error: stray '\5' in progr
    am
    
    c:\mingw\lib\gcc\mingw32\4.8.1\include\stddef.h:1:29: error: stray '\5' in progr
    am
    
    c:\mingw\lib\gcc\mingw32\4.8.1\include\stddef.h:1:29: error: stray '\5' in progr
    am
    
    c:\mingw\lib\gcc\mingw32\4.8.1\include\stddef.h:1:29: error: stray '\310' in pro
    gram
    
    c:\mingw\lib\gcc\mingw32\4.8.1\include\stddef.h:1:29: error: stray '\311' in pro
    gram
    
    c:\mingw\lib\gcc\mingw32\4.8.1\include\stddef.h:1:29: error: stray '\1' in progr
    am
    
    c:\mingw\lib\gcc\mingw32\4.8.1\include\stddef.h:1:29: error: stray '\5' in progr
    am
    
    c:\mingw\lib\gcc\mingw32\4.8.1\include\stddef.h:1:29: error: stray '\367' in pro
    gram
    
    c:\mingw\lib\gcc\mingw32\4.8.1\include\stddef.h:1:29: error: stray '\26' in prog
    ram
    
    c:\mingw\lib\gcc\mingw32\4.8.1\include\stddef.h:1:29: error: stray '\227' in pro
    gram
    
    c:\mingw\lib\gcc\mingw32\4.8.1\include\stddef.h:1:29: error: stray '\205' in pro
    gram
    
    c:\mingw\lib\gcc\mingw32\4.8.1\include\stddef.h:1:29: error: stray '\27' in prog
    ram
    
    c:\mingw\lib\gcc\mingw32\4.8.1\include\stddef.h:1:29: error: stray '\312' in pro
    gram
    
    c:\mingw\lib\gcc\mingw32\4.8.1\include\stddef.h:1:29: error: stray '\226' in pro
    gram
    
    c:\mingw\lib\gcc\mingw32\4.8.1\include\stddef.h:1:29: error: stray '\352' in pro
    gram
    
    c:\mingw\lib\gcc\mingw32\4.8.1\include\stddef.h:1:29: error: stray '\20' in prog
    ram
    
    c:\mingw\lib\gcc\mingw32\4.8.1\include\stddef.h:1:29: error: stray '\207' in pro
    gram
    
    c:\mingw\lib\gcc\mingw32\4.8.1\include\stddef.h:1:29: error: stray '\22' in prog
    ram
    
    c:\mingw\lib\gcc\mingw32\4.8.1\include\stddef.h:1:29: error: stray '\352' in pro
    gram
    
    
    
    cc1.exe: out of memory allocating 838860800 bytes
    
    error: command 'C:\\MINGW\\BIN\\gcc.exe' failed with exit status 1
    
    ----------------------------------------
    Cleaning up...
    Command D:\Anaconda\python.exe -c "import setuptools, tokenize;__file__='c:\\use
    rs\\mkhm\\appdata\\local\\temp\\pip_build_MKHM\\spectrum\\setup.py';exec(compile
    (getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file_
    _, 'exec'))" install --record c:\users\mkhm\appdata\local\temp\pip-nb46ob-record
    \install-record.txt --single-version-externally-managed --compile failed with er
    ror code 1 in c:\users\mkhm\appdata\local\temp\pip_build_MKHM\spectrum
    Traceback (most recent call last):
      File "D:\Anaconda\Scripts\pip-script.py", line 5, in <module>
        sys.exit(main())
      File "D:\Anaconda\lib\site-packages\pip\__init__.py", line 198, in main
        return command.main(cmd_args)
      File "D:\Anaconda\lib\site-packages\pip\basecommand.py", line 161, in main
        text = '\n'.join(complete_log)
    UnicodeDecodeError: 'ascii' codec can't decode byte 0xe9 in position 5: ordinal
    not in range(128)
    
    opened by mkhm 7
  • Fix loading mydpss under MacOS

    Fix loading mydpss under MacOS

    Using OSX El Capitan and Anaconda Python 3.5 the library is called mydpss.cpython-35m-darwin.so not mydpss.cpython-35m.so.

    Update Use numpy helper function load_library to load library without having to build the library name manually.

    opened by juhasch 6
  • Authorship on JOSS paper

    Authorship on JOSS paper

    @juhasch @anielsen001 @carlkl I've submitted a paper to JOSS describing the Spectrum package. It's currently under review, and you can read the review and response at the link..

    Please let me know by 16 Oct if you'd like to be listed as co-authors on the paper, in which case please send me your current affiliation and ORCID.

    opened by cokelaer 5
  • error while building the package on installation

    error while building the package on installation

    Hi (newbie here) I'm getting an error while trying to install with pip on windows 7, anaconda 2.4.0, python 3.5 pip install spectrum the error seems to be happening during the building of the package since I get something similar if I try to build it myself with "python setup.py install"

    Below the last output lines of pip install.

    Building wheels for collected packages: spectrum Running setup.py bdist_wheel for spectrum Complete output from command C:\Python\Anaconda\python.exe -c "import setuptoo ls;file='C:\Users\senis\AppData\Local\Temp\pip-build-4s5qgf6i\spectru m\setup.py';exec(compile(open(file).read().replace('\r\n', '\n'), file, 'exec'))" bdist_wheel -d C:\Users\senis\AppData\Local\Temp\tmptse64iuppip-wheel -: running bdist_wheel running build running build_py creating build creating build\lib.win-amd64-3.5 creating build\lib.win-amd64-3.5\cpp copying src\cpp__init__.py -> build\lib.win-amd64-3.5\cpp creating build\lib.win-amd64-3.5\spectrum copying src\spectrum\arma.py -> build\lib.win-amd64-3.5\spectrum copying src\spectrum\burg.py -> build\lib.win-amd64-3.5\spectrum copying src\spectrum\cholesky.py -> build\lib.win-amd64-3.5\spectrum copying src\spectrum\cohere.py -> build\lib.win-amd64-3.5\spectrum copying src\spectrum\correlation.py -> build\lib.win-amd64-3.5\spectrum copying src\spectrum\correlog.py -> build\lib.win-amd64-3.5\spectrum copying src\spectrum\covar.py -> build\lib.win-amd64-3.5\spectrum copying src\spectrum\criteria.py -> build\lib.win-amd64-3.5\spectrum copying src\spectrum\datasets.py -> build\lib.win-amd64-3.5\spectrum copying src\spectrum\eigen.py -> build\lib.win-amd64-3.5\spectrum copying src\spectrum\eigenfre.py -> build\lib.win-amd64-3.5\spectrum copying src\spectrum\errors.py -> build\lib.win-amd64-3.5\spectrum copying src\spectrum\levinson.py -> build\lib.win-amd64-3.5\spectrum copying src\spectrum\linalg.py -> build\lib.win-amd64-3.5\spectrum copying src\spectrum\linear_prediction.py -> build\lib.win-amd64-3.5\spectrum copying src\spectrum\lpc.py -> build\lib.win-amd64-3.5\spectrum copying src\spectrum\minvar.py -> build\lib.win-amd64-3.5\spectrum copying src\spectrum\modcovar.py -> build\lib.win-amd64-3.5\spectrum copying src\spectrum\mtm.py -> build\lib.win-amd64-3.5\spectrum copying src\spectrum\periodogram.py -> build\lib.win-amd64-3.5\spectrum copying src\spectrum\psd.py -> build\lib.win-amd64-3.5\spectrum copying src\spectrum\toeplitz.py -> build\lib.win-amd64-3.5\spectrum copying src\spectrum\tools.py -> build\lib.win-amd64-3.5\spectrum copying src\spectrum\transfer.py -> build\lib.win-amd64-3.5\spectrum copying src\spectrum\waveform.py -> build\lib.win-amd64-3.5\spectrum copying src\spectrum\window.py -> build\lib.win-amd64-3.5\spectrum copying src\spectrum\yulewalker.py -> build\lib.win-amd64-3.5\spectrum copying src\spectrum__init__.py -> build\lib.win-amd64-3.5\spectrum running build_ext building 'spectrum.mydpss' extension error: [WinError 2] The system cannot find the file specified


    Failed building wheel for spectrum Failed to build spectrum Installing collected packages: spectrum Running setup.py install for spectrum Complete output from command C:\Python\Anaconda\python.exe -c "import setupt ools, tokenize;file='C:\Users\senis\AppData\Local\Temp\pip-build-4s5qg f6i\spectrum\setup.py';exec(compile(getattr(tokenize, 'open', open)(file). read().replace('\r\n', '\n'), file, 'exec'))" install --record C:\Users\seni s\AppData\Local\Temp\pip-lr7725kt-record\install-record.txt --single-version-ext ernally-managed --compile: running install running build running build_py running build_ext building 'spectrum.mydpss' extension error: [WinError 2] The system cannot find the file specified

    ----------------------------------------
    

    Command "C:\Python\Anaconda\python.exe -c "import setuptools, tokenize;file= 'C:\Users\senis\AppData\Local\Temp\pip-build-4s5qgf6i\spectrum\setup.py' ;exec(compile(getattr(tokenize, 'open', open)(file).read().replace('\r\n', ' \n'), file, 'exec'))" install --record C:\Users\senis\AppData\Local\Temp\pip -lr7725kt-record\install-record.txt --single-version-externally-managed --compil e" failed with error code 1 in C:\Users\senis\AppData\Local\Temp\pip-build-4s5qg f6i\spectrum

    opened by senis000 5
  • Error: No module named arma

    Error: No module named arma

    A colleague of mine asked me to install spectrum.

    I get a few errors with Python 3 and an ImportError for arma (that is also there for Python 2).

    $ pip install spectrum --user
    Collecting spectrum
      Downloading spectrum-0.6.0.tar.gz (92kB)
        100% |################################| 94kB 794kB/s 
    Requirement already satisfied (use --upgrade to upgrade): matplotlib in /opt/local/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages (from spectrum)
    Requirement already satisfied (use --upgrade to upgrade): numpy in /opt/local/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages (from spectrum)
    Requirement already satisfied (use --upgrade to upgrade): scipy in /opt/local/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages (from spectrum)
    Collecting easydev (from spectrum)
      Downloading easydev-0.8.3.tar.gz (43kB)
        100% |################################| 45kB 4.0MB/s 
    Requirement already satisfied (use --upgrade to upgrade): six>=1.4 in /opt/local/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages (from matplotlib->spectrum)
    Requirement already satisfied (use --upgrade to upgrade): python-dateutil in /opt/local/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages (from matplotlib->spectrum)
    Requirement already satisfied (use --upgrade to upgrade): pytz in /opt/local/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages (from matplotlib->spectrum)
    Requirement already satisfied (use --upgrade to upgrade): pyparsing>=1.5.6 in /opt/local/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages (from matplotlib->spectrum)
    Collecting ordereddict (from easydev->spectrum)
      Downloading ordereddict-1.1.tar.gz
    Installing collected packages: ordereddict, easydev, spectrum
      Running setup.py install for ordereddict
      Running setup.py install for easydev
        Fixing build/lib/easydev/__init__.py build/lib/easydev/codecs.py build/lib/easydev/config_tools.py build/lib/easydev/console.py build/lib/easydev/copybutton.py build/lib/easydev/decorators.py build/lib/easydev/dependencies.py build/lib/easydev/doc.py build/lib/easydev/easytest.py build/lib/easydev/logging_tools.py build/lib/easydev/misc.py build/lib/easydev/multicore.py build/lib/easydev/multigit.py build/lib/easydev/multisetup.py build/lib/easydev/package.py build/lib/easydev/paths.py build/lib/easydev/progressbar.py build/lib/easydev/setuptools.py build/lib/easydev/sphinx_themes.py build/lib/easydev/tools.py build/lib/easydev/url.py
        Fixing build/lib/easydev/__init__.py build/lib/easydev/codecs.py build/lib/easydev/config_tools.py build/lib/easydev/console.py build/lib/easydev/copybutton.py build/lib/easydev/decorators.py build/lib/easydev/dependencies.py build/lib/easydev/doc.py build/lib/easydev/easytest.py build/lib/easydev/logging_tools.py build/lib/easydev/misc.py build/lib/easydev/multicore.py build/lib/easydev/multigit.py build/lib/easydev/multisetup.py build/lib/easydev/package.py build/lib/easydev/paths.py build/lib/easydev/progressbar.py build/lib/easydev/setuptools.py build/lib/easydev/sphinx_themes.py build/lib/easydev/tools.py build/lib/easydev/url.py
        Can't parse docstring in build/lib/easydev/codecs.py line 83: TokenError: ('EOF in multi-line statement', (2, 0))
        Can't parse docstring in build/lib/easydev/codecs.py line 85: ParseError: bad input: type=13, value=';', context=('', (85, 24))
        Can't parse docstring in build/lib/easydev/codecs.py line 87: ParseError: bad input: type=13, value=';', context=('', (87, 24))
        Can't parse docstring in build/lib/easydev/codecs.py line 89: ParseError: bad input: type=13, value=';', context=('', (89, 19))
        Can't parse docstring in build/lib/easydev/multigit.py line 173: ParseError: bad input: type=1, value='multigit', context=(' ', (173, 7))
        Can't parse docstring in build/lib/easydev/multisetup.py line 29: ParseError: bad input: type=1, value='multisetup', context=(' ', (29, 7))
        Can't parse docstring in build/lib/easydev/multisetup.py line 30: ParseError: bad input: type=1, value='multisetup', context=(' ', (30, 7))
        Can't parse docstring in build/lib/easydev/multisetup.py line 31: ParseError: bad input: type=1, value='multisetup', context=(' ', (31, 7))
        Can't parse docstring in build/lib/easydev/multisetup.py line 141: ParseError: bad input: type=1, value='multisetup', context=(' ', (141, 7))
        Can't parse docstring in build/lib/easydev/multisetup.py line 144: ParseError: bad input: type=1, value='multisetup', context=(' ', (144, 7))
        Can't parse docstring in build/lib/easydev/multisetup.py line 147: ParseError: bad input: type=1, value='multisetup', context=(' ', (147, 7))
        Can't parse docstring in build/lib/easydev/tools.py line 169: ParseError: bad input: type=11, value=':', context=('', (169, 20))
        Installing multigit script to /Users/deil/Library/Python/3.4/bin
        Installing easydev_buildPackage script to /Users/deil/Library/Python/3.4/bin
      Running setup.py install for spectrum
        building 'spectrum.mydpss' extension
        /usr/bin/clang -Wno-unused-result -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -pipe -Os -I/opt/local/Library/Frameworks/Python.framework/Versions/3.4/include/python3.4m -c src/cpp/mydpss.c -o build/temp.macosx-10.10-x86_64-3.4/src/cpp/mydpss.o
        /usr/bin/clang -bundle -undefined dynamic_lookup -L/opt/local/lib -Wl,-headerpad_max_install_names build/temp.macosx-10.10-x86_64-3.4/src/cpp/mydpss.o -o build/lib.macosx-10.10-x86_64-3.4/spectrum/mydpss.so
          File "/Users/deil/Library/Python/3.4/lib/python/site-packages/spectrum/psd.py", line 303
            print """To be use with care. THis function is there just to help, it
                    does not populate the proper attribute except psd."""
                                                                        ^
    Successfully installed easydev-0.8.3 ordereddict-1.1 spectrum-0.6.0
    eduroam-3-163:associations deil$ ipython
    Python 3.4.3 (default, Mar 10 2015, 14:53:35) 
    Type "copyright", "credits" or "license" for more information.
    
    IPython 3.0.0 -- An enhanced Interactive Python.
    ?         -> Introduction and overview of IPython's features.
    %quickref -> Quick reference.
    help      -> Python's own help system.
    object?   -> Details about 'object', use 'object??' for extra details.
    
    In [1]: import spectrum
    ---------------------------------------------------------------------------
    ImportError                               Traceback (most recent call last)
    <ipython-input-1-c2dabc14c746> in <module>()
    ----> 1 import spectrum
    
    /Users/deil/Library/Python/3.4/lib/python/site-packages/spectrum/__init__.py in <module>()
          2 default_NFFT = 4096
          3 
    ----> 4 import arma
          5 import burg
          6 import cholesky
    
    ImportError: No module named 'arma'
    
    opened by cdeil 5
  • Python version supported

    Python version supported

    Hey everyone, I would like to use Spectrum, but my analysis are all in python 3.9+, and I wouldn't like to send it back to <3.9. I see that the package works until 3.7? Is that correct?

    Any plans of making this compatible with newer versions soon?

    big thanks, Best.

    opened by eduardacenteno 4
  • What is the output of pmtm?

    What is the output of pmtm?

    I'm unclear what exactly the pmtm function is outputting? It returns three np.arrays and the documentation doesn't say what it returns.

    I'm not sure what to do to those output arrays to get the actual multitapered output and produce a plot similar to what is returned from the show=True parameter. Do I need to average one of the arrays in the output? This doesn't seem to match the plot. Any advice or examples would be much appreciated!

    opened by patrickcgray 3
  • initialized wk before adapt loop

    initialized wk before adapt loop

    pmtm with "adapt" method crashes if data is a constant vector Loop is not entered (since convergence criterion is already met), so wk should be initialized before it.

    opened by yuvlyg 3
  • scipy fftn produces warning that numpy fftn does not

    scipy fftn produces warning that numpy fftn does not

    When working on addressing the deprecation warning announced in #49 , I found that the scipy.fftpack.fftn produces a different warning:

    import numpy as np
    from scipy.fftpack import fftn
    a = np.random.random([16,16])
    fftn(a, [32,32])      
    

    /home/apn/proj/spectrum/lib/python3.6/site-packages/scipy-1.1.0-py3.6-linux-x86_64.egg/scipy/fftpack/basic.py:160: FutureWarning: Using a non-tuple sequence for multidimensional indexing is deprecated; use arr[tuple(seq)] instead of arr[seq]. In the future this will be interpreted as an array index, arr[np.array(seq)], which will result either in an error or a different result. z[index] = x

    If you use the numpy version of fftn, this warning goes away, and the answers are the same:

    np.allclose(np.fft.fftn(a,[32,32]) , fftn(a, [32,32]))

    is True

    I'm not sure if there's a reason to choose one of the fftn over another, but the warning appears to come from scipy and could be removed by switching to the numpy version.

    I'm suing scipy 1.1.0, numpy 1.15.2 and python 3.6.5

    enhancement 
    opened by anielsen001 3
  • Made matplotlib+pylab dependencies optional

    Made matplotlib+pylab dependencies optional

    Motivation

    Since the matplotlib/pylab dependency pulls in graphical dependencies such as Tk, Qt, etc. which are not desirable on a headless server environment (with regards to scaling issues).

    Changes

    To reach optional dependency on matplotlib/pylab, the following changes were made:

    • In setup.py the matplotlib dependency was moved from required to optional.
    • Most pylab functions are mere shortcuts to actual functions of the numpy library. Those dependencies were replaced by their respective numpy replacements.
    • Plotting functions that really need matplotlib functionality now have these respective imports directly in their function's body. Thus, the matplotlib is only required, if one (or more) of these functions is called.
    • None of the changes made produces any semantic change of the library, except for one thing: pmtm()'s show parameter's default value was changed from True to False.
    opened by moritz-ritter 3
  • Times sampling or divides in the Capon method of minvar function.

    Times sampling or divides in the Capon method of minvar function.

    1. Describe the bug A clear and concise description of what the bug is.

    2. To Reproduce If you are facing a bug or installation problem, I cannot help yo without some information of way to reproduce the errors. Please complete the following information as much as possible

    • OS: [e.g. Fedora, windows version, mac version]
    • Python version. for example 3.7.2 (please provide X.Y.Z numbers)
    • Version of spectrum:

    you can figure out the version using this python code::

    import spectrum spectrum.version

    3.Expected behavior A clear and concise description of what you expected to happen.

    4.Screenshots If applicable, add screenshots to help explain your problem.

    5.What you think may explain the pbl

    I like this module and it is so powerful. I have one question/confusion.

    math:: P_{MV}(f) = \frac{T}{e^H(f) R^{-1}p e(f)} def minvar(X, order, sampling=1., NFFT=default_NFFT): .. math:: P{MV}(f) = \frac{T}{e^H(f) R^{-1}_p e(f)} ...... # Invert the psi terms at this point to get PSD values PSD = sampling / np.real(psi)

    It times T in the math, but it times sampling in the PSD calculation inside the minvar function. I believe T=1/sampling. When sampling=1, there is no problem. If sampling !=1, it will get wrong answer for power or PSD. I may misunderstand, but can you please verify that.

    Thanks.

    Steve

    opened by xifenglu 0
  • A suggestion to remove confusion regarding periodograms

    A suggestion to remove confusion regarding periodograms

    Hi there, I've been recently reading about this Python library, because I needed to plot some periodograms. And it has proven to be a very frustrating experience. At first glance it seemed that WelchPeriodogram was a class, just like Periodogram itself. The same goes for DaniellPeriodogram. That caused me quite a lot of confusion until I read the souce code. And at least DaniellPeriodogram does have a class one can call, pdaniell, why not WelchPeriodogram? What am I missing?

    Thank you for your effort though!

    question 
    opened by goznalo-git 1
  • Extract dominant periods from data

    Extract dominant periods from data

    hello, I would like to use the spectrum library for extracting periods from data of time series as I understand it, the strongest frequencies (in the case below) is: 0.2, 0.33 and 0.36 Please, tell me is this correct understanding? Or maybe there is a better way to do this? And the second question: method p.plot() allows you to plot frequencies, but where can you find the power values?

    test case:

    import numpy as np
    import pandas as pd
    
    data=[77943,119335,562383,29789,20429,40612,20523,722055,40659,6521,20008,
          20605,130027,1172649,29964,22227,80446,20008,518405,16597,20322,24951,
          70791,1224887,51838,38906,20258,630595,12250,40800]
    data=np.asarray(data)
    
    p=Periodogram(data)
    p.periodogram()
    p.plot()
    
    p.periodogram()
    f=p.frequencies()
    f=pd.Series(f)
    pd.DataFrame([1/f,f], index=['period', 'freq'])
    

    Result:

    image

    opened by q121212 0
Releases(v0.8.1)
Owner
Thomas Cokelaer
Bioinformatician, Scientific Software Developer, Python developer
Thomas Cokelaer
Feature engineering and machine learning: together at last

Feature engineering and machine learning: together at last! Lambdo is a workflow engine which significantly simplifies data analysis by unifying featu

Alexandr Savinov 14 Sep 15, 2022
Data collection, enhancement, and metrics calculation.

l3_data_collection Data collection, enhancement, and metrics calculation. Summary Repository containing code for QuantDAO's JDT data collection task.

Ruiwyn 3 Dec 23, 2022
NFCDS Workshop Beginners Guide Bioinformatics Data Analysis

Genomics Workshop FIXME: overview of workshop Code of Conduct All participants s

Elizabeth Brooks 2 Jun 13, 2022
Python utility to extract differences between two pandas dataframes.

Python utility to extract differences between two pandas dataframes.

Jaime Valero 8 Jan 07, 2023
Deep universal probabilistic programming with Python and PyTorch

Getting Started | Documentation | Community | Contributing Pyro is a flexible, scalable deep probabilistic programming library built on PyTorch. Notab

7.7k Dec 30, 2022
First and foremost, we want dbt documentation to retain a DRY principle. Every time we repeat ourselves, we waste our time. Second, we want to understand column level lineage and automate impact analysis.

dbt-osmosis First and foremost, we want dbt documentation to retain a DRY principle. Every time we repeat ourselves, we waste our time. Second, we wan

Alexander Butler 150 Jan 06, 2023
This python script allows you to manipulate the audience data from Sl.ido surveys

Slido-Automated-VoteBot This python script allows you to manipulate the audience data from Sl.ido surveys Since Slido blocks interference from automat

Pranav Menon 1 Jan 24, 2022
VevestaX is an open source Python package for ML Engineers and Data Scientists.

VevestaX Track failed and successful experiments as well as features. VevestaX is an open source Python package for ML Engineers and Data Scientists.

Vevesta 24 Dec 14, 2022
A utility for functional piping in Python that allows you to access any function in any scope as a partial.

WithPartial Introduction WithPartial is a simple utility for functional piping in Python. The package exposes a context manager (used with with) calle

Michael Milton 1 Oct 26, 2021
Single-Cell Analysis in Python. Scales to >1M cells.

Scanpy – Single-Cell Analysis in Python Scanpy is a scalable toolkit for analyzing single-cell gene expression data built jointly with anndata. It inc

Theis Lab 1.4k Jan 05, 2023
Containerized Demo of Apache Spark MLlib on a Data Lakehouse (2022)

Spark-DeltaLake-Demo Reliable, Scalable Machine Learning (2022) This project was completed in an attempt to become better acquainted with the latest b

8 Mar 21, 2022
Python Implementation of Scalable In-Memory Updatable Bitmap Indexing

PyUpBit CS490 Large Scale Data Analytics — Implementation of Updatable Compressed Bitmap Indexing Paper Table of Contents About The Project Usage Cont

Hyeong Kyun (Daniel) Park 1 Jun 28, 2022
A Python 3 library making time series data mining tasks, utilizing matrix profile algorithms

MatrixProfile MatrixProfile is a Python 3 library, brought to you by the Matrix Profile Foundation, for mining time series data. The Matrix Profile is

Matrix Profile Foundation 302 Dec 29, 2022
PyIOmica (pyiomica) is a Python package for omics analyses.

PyIOmica (pyiomica) This repository contains PyIOmica, a Python package that provides bioinformatics utilities for analyzing (dynamic) omics datasets.

G. Mias Lab 13 Jun 29, 2022
Zipline, a Pythonic Algorithmic Trading Library

Zipline is a Pythonic algorithmic trading library. It is an event-driven system for backtesting. Zipline is currently used in production as the backte

Quantopian, Inc. 15.7k Jan 07, 2023
Karate Club: An API Oriented Open-source Python Framework for Unsupervised Learning on Graphs (CIKM 2020)

Karate Club is an unsupervised machine learning extension library for NetworkX. Please look at the Documentation, relevant Paper, Promo Video, and Ext

Benedek Rozemberczki 1.8k Jan 09, 2023
Project under the certification "Data Analysis with Python" on FreeCodeCamp

Sea Level Predictor Assignment You will anaylize a dataset of the global average sea level change since 1880. You will use the data to predict the sea

Bhavya Gopal 3 Jan 31, 2022
Get mutations in cluster by querying from LAPIS API

Cluster Mutation Script Get mutations appearing within user-defined clusters. Usage Clusters are defined in the clusters dict in main.py: clusters = {

neherlab 1 Oct 22, 2021
Tokyo 2020 Paralympics, Analytics

Tokyo 2020 Paralympics, Analytics Thanks for checking out my app! It was built entirely using matplotlib and Tokyo 2020 Paralympics data. This applica

Petro Ivaniuk 1 Nov 18, 2021
Spaghetti: an open-source Python library for the analysis of network-based spatial data

pysal/spaghetti SPAtial GrapHs: nETworks, Topology, & Inference Spaghetti is an open-source Python library for the analysis of network-based spatial d

Python Spatial Analysis Library 203 Jan 03, 2023