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
Statistical Analysis ๐Ÿ“ˆ focused on statistical analysis and exploration used on various data sets for personal and professional projects.

Statistical Analysis ?? This repository focuses on statistical analysis and the exploration used on various data sets for personal and professional pr

Andy Pham 1 Sep 3, 2022
Sensitivity Analysis Library in Python (Numpy). Contains Sobol, Morris, Fractional Factorial and FAST methods.

Sensitivity Analysis Library (SALib) Python implementations of commonly used sensitivity analysis methods. Useful in systems modeling to calculate the

SALib 663 Jan 5, 2023
๐Ÿงช Panel-Chemistry - exploratory data analysis and build powerful data and viz tools within the domain of Chemistry using Python and HoloViz Panel.

???? ??. The purpose of the panel-chemistry project is to make it really easy for you to do DATA ANALYSIS and build powerful DATA AND VIZ APPLICATIONS within the domain of Chemistry using using Python and HoloViz Panel.

Marc Skov Madsen 97 Dec 8, 2022
Tablexplore is an application for data analysis and plotting built in Python using the PySide2/Qt toolkit.

Tablexplore is an application for data analysis and plotting built in Python using the PySide2/Qt toolkit.

Damien Farrell 81 Dec 26, 2022
Repositori untuk menyimpan material Long Course STMKGxHMGI tentang Geophysical Python for Seismic Data Analysis

Long Course "Geophysical Python for Seismic Data Analysis" Instruktur: Dr.rer.nat. Wiwit Suryanto, M.Si Dipersiapkan oleh: Anang Sahroni Waktu: Sesi 1

Anang Sahroni 0 Dec 4, 2021
A data analysis using python and pandas to showcase trends in school performance.

A data analysis using python and pandas to showcase trends in school performance. A data analysis to showcase trends in school performance using Panda

Jimmy Faccioli 0 Sep 7, 2021
HyperSpy is an open source Python library for the interactive analysis of multidimensional datasets

HyperSpy is an open source Python library for the interactive analysis of multidimensional datasets that can be described as multidimensional arrays o

HyperSpy 411 Dec 27, 2022
PyPSA: Python for Power System Analysis

1 Python for Power System Analysis Contents 1 Python for Power System Analysis 1.1 About 1.2 Documentation 1.3 Functionality 1.4 Example scripts as Ju

null 758 Dec 30, 2022
A collection of learning outcomes data analysis using Python and SQL, from DQLab.

Data Analyst with PYTHON Data Analyst berperan dalam menghasilkan analisa data serta mempresentasikan insight untuk membantu proses pengambilan keputu

null 6 Oct 11, 2022
DaDRA (day-druh) is a Python library for Data-Driven Reachability Analysis.

DaDRA (day-druh) is a Python library for Data-Driven Reachability Analysis. The main goal of the package is to accelerate the process of computing estimates of forward reachable sets for nonlinear dynamical systems.

null 2 Nov 8, 2021
BioMASS - A Python Framework for Modeling and Analysis of Signaling Systems

Mathematical modeling is a powerful method for the analysis of complex biological systems. Although there are many researches devoted on produ

BioMASS 22 Dec 27, 2022
Python-based Space Physics Environment Data Analysis Software

pySPEDAS pySPEDAS is an implementation of the SPEDAS framework for Python. The Space Physics Environment Data Analysis Software (SPEDAS) framework is

SPEDAS 98 Dec 22, 2022
Python Project on Pro Data Analysis Track

Udacity-BikeShare-Project: Python Project on Pro Data Analysis Track Basic Data Exploration with pandas on Bikeshare Data Basic Udacity project using

Belal Mohammed 0 Nov 10, 2021
Weather analysis with Python, SQLite, SQLAlchemy, and Flask

Surf's Up Weather analysis with Python, SQLite, SQLAlchemy, and Flask Overview The purpose of this analysis was to examine weather trends (precipitati

Art Tucker 1 Sep 5, 2021
Stock Analysis dashboard Using Streamlit and Python

StDashApp Stock Analysis Dashboard Using Streamlit and Python If you found the content useful and want to support my work, you can buy me a coffee! Th

StreamAlpha 27 Dec 9, 2022
Python implementation of Principal Component Analysis

Principal Component Analysis Principal Component Analysis (PCA) is a dimension-reduction algorithm. The idea is to use the singular value decompositio

Ignacio Darago 1 Nov 6, 2021
Powerful, efficient particle trajectory analysis in scientific Python.

freud Overview The freud Python library provides a simple, flexible, powerful set of tools for analyzing trajectories obtained from molecular dynamics

Glotzer Group 195 Dec 20, 2022
A Python adaption of Augur to prioritize cell types in perturbation analysis.

A Python adaption of Augur to prioritize cell types in perturbation analysis.

Theis Lab 2 Mar 29, 2022
Sentiment analysis on streaming twitter data using Spark Structured Streaming & Python

Sentiment analysis on streaming twitter data using Spark Structured Streaming & Python This project is a good starting point for those who have little

Himanshu Kumar singh 2 Dec 4, 2021