Giter Site home page Giter Site logo

cokelaer / spectrum Goto Github PK

View Code? Open in Web Editor NEW
328.0 20.0 87.0 964 KB

Spectral Analysis in Python

Home Page: http://pyspectrum.readthedocs.io

License: BSD 3-Clause "New" or "Revised" License

Python 93.11% C 6.89%
arma pburg psd periodogram fourier spectral python

spectrum's Introduction

SPECTRUM : Spectral Analysis in Python

image

image

image

image

image

image

image

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

image

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.

Changelog (summary)

release description

0.8.1

  • move CI to github actions
  • include python 3.9 support
  • include PR from tikuma-lshhsc contributor to speedup eigenfre module
  • fix deprecated warnings

Some notebooks (external contributions)

spectrum's People

Contributors

alamkanak avatar anielsen001 avatar arfon avatar carlkl avatar cokelaer avatar eteq avatar gozzilli avatar juhasch avatar maxstrobel avatar sambnh avatar svantana avatar tikuma-lsuhsc avatar wanglongqi avatar yuvlyg avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

spectrum's Issues

minor interpretation pmtm out data issue

I am unable to understand the output of the pmtm. I do not want to plot directly using the show = true so I would like to take the Sk and weight variables and combine them appropriately. They come out different shapes, so I am assuming a transpose will fix this issue. For example, is n=1024, k=4,
then I will:

  1. element by element multiply the Sk matrix by the transpose(weight) matrix.
  2. then add them to get the correct tapered and weighted FFT.
  3. compute spectrum or whatever is desired.

Thanks, sorry for not posting an actual issue.

pyule does not return the correct frequencies.

pyule does not return the correct scaled frequencies as is demonstrated below:

In [1]: import spectrum as sp

In [2]: import numpy as np

In [3]: sig = np.random.random((100,1))

In [4]: s = sp.pyule(sig, 8, sampling = 64)

In [5]: s.run()

In [6]: 1/s.df
Out[6]: 100.0

In [7]: s.sampling
Out[7]: 64

In [8]: s.frequencies()[-1]
Out[8]: 0.5

Spectrum on 2D spatial data?

Is there any documentation or examples of how to use spectrum on 2D data to take a power spectrum of an image? Then I'm planning to azimuthally average that 2D power spectrum to get my 1D power spectrum.

Need to include easydev in the docs (or not in the requirements)

The documentation only references numpy, scpiy, and matplotlib as requirements, but easydev gets installed when I do a pip install. It looks to me like easydev isn't actually needed at runtime, though? Perhaps it should be removed from the baseline requirements list (along with sphinx), but have a separate requirements-dev list?

pmusic example to fix

Check this example.
Frequencies should be 0.2 and 0.257 in the plot

x = cos(0.257*pi*n) + sin(0.2*pi*n) + 0.01*randn(size(n));
p = pmusic(x, 8,4); p(); p.plot()
p = pmusic(x, 8,4); p(); p.plot()

Return data of pburg

Hey,
it would be nice, if you could use the pburg data for further calculations (i use it for an radar angle plot) and rather would not need to write my own pburg to extract the data. Would that be doable?
Thanks! ;)

Documentation and example for usage of pmtm is incorrect

In the docstring of function pmtm
https://github.com/cokelaer/spectrum/blob/master/src/spectrum/mtm.py#L111-L112
as well as in the example on readthedocs.io
http://pyspectrum.readthedocs.io/en/latest/ref_mtm.html
the tapers are used as argument 'e' and the eigenvalues as argument 'v'.

But then arguments are interpreted as eigenvalues = 'e' and tapers = 'v' in
https://github.com/cokelaer/spectrum/blob/master/src/spectrum/mtm.py#L164-L165,
such that multiplication of the signal with the tapers crashes due to incompatible shapes.

Order of return arguments of dpss needs to be re-checked as well as reading of arguments to function pmtm.

SyntaxError

Hi,

I tried the following commands but got a syntax error:

import spectrum as sp
p = sp.Periodogram(stream[0,:], sampling=20)
*** SyntaxError: SyntaxError('invalid syntax', ('', 1, 1, '= sp.Periodogram(stream[0,:], sampling=20)'))

I am using python with conda. stream[0,:] is a numpy array. Any ideas?

Installed Spectrum 0.6.1 Anaconda python 3.5 does not get imported on Spyder IPython console

Hello,
I have installed spectrum 0.6.1 on my Anaconda python 3.5 distribution on windows 7.
On the Spyder IPython console it cannot be imported. Would you please help???
Here's the end of the installation output:
....
File "C:\Users\olb\AppData\Local\Continuum\Anaconda3\lib\site-packages\spectrum-0.6.1-Installed c:\users\olb\appdata\local\continuum\anaconda3\lib\site-packages\spectrum-0.6.1-py3.5-win-amd64.egg
Processing dependencies for spectrum
Finished processing dependencies for spectrum-win-amd64.egg\spectrum

....
Here's the console error:
import spectrum
Traceback (most recent call last):

File "", line 1, in
import spectrum

init.py", line 8, in
from .mtm import *

File "C:\Users\olb\AppData\Local\Continuum\Anaconda3\lib\site-packages\spectrum-0.6.1-py3.5-win-amd64.egg\spectrum\mtm.py", line 53, in
mtspeclib = ctypes.cdll.LoadLibrary(pj(p, lib_name))

File "C:\Users\olb\AppData\Local\Continuum\Anaconda3\lib\ctypes__init__.py", line 425, in LoadLibrary
return self._dlltype(name)

File "C:\Users\olb\AppData\Local\Continuum\Anaconda3\lib\ctypes__init__.py", line 347, in init
self._handle = _dlopen(self._name, mode)

OSError: [WinError 126] The specified module could not be found

No output at Jupyter Notebook

from spectrum.window import Window
h = Window(64, name='hamming')
h.plot_time_freq()

I just tried to run the code above at Jupyter notebook code cell. No problem was reported, but no outputs either.
EDIT: I had to use '%matplotlib inline' for the plotting to be shown.

multi-taper future deprecation warning

There seems to be an issue regarding complex valued type conversion in mtm.py:

/Users/XXX/Library/anaconda3/lib/python3.6/site-packages/spectrum/mtm.py:529: FutureWarning: Conversion of the second argument of issubdtype from `complex` to `np.complexfloating` is deprecated. In future, it will be treated as `np.complex128 == np.dtype(complex).type`.
  complex_result = (np.issubdtype(in1.dtype, np.complex) or
/Users/XXX/Library/anaconda3/lib/python3.6/site-packages/spectrum/mtm.py:530: FutureWarning: Conversion of the second argument of issubdtype from `complex` to `np.complexfloating` is deprecated. In future, it will be treated as `np.complex128 == np.dtype(complex).type`.
  np.issubdtype(in2.dtype, np.complex))

I am using anaconda python 3.6.5 on macos.

conda portage

Spectrum is not available on conda but dependencies are.
If you want to port it on conda-forge for instance, I would appreciate some help !

No module named 'spectrum'

After successfully installed. spectrum can be found when use pip list.

But shows no module named "spectrum"

Move away from "from spectrum import *" in docs

This is a suggestion which you are free to ignore, but I think is important to think about.

In most contexts, wildcard imports (from x import *) is highly-discouraged - even PEP8 itself says to avoid this. In science I think this is especially important because many users don't have a full understanding of what that's doing and its consequences.

So I would suggest trying to migrate all the examples in the docs to do something like:

import spectrum as sp
p = sp.Periodogram(...)

instead of

from spectrum import *
p =Periodogram(...)

where feasible.

conda-forge

README.rst says to use conda config --add channels conda-forge. However, on conda>4.1 this leads to a channel order where conda-forge has a higher priority than the defaults channel. Documentation is here: https://conda.io/docs/user-guide/tasks/manage-channels.html
This will lead to undesirabley switching ALL packages (not only spectrum) to conda-forge with the next conda update.
Maybe you can change it to conda config --append channels conda-forge.

Missing version tags

Hi,

on PyPI, there are different versions of this package but I can't find the corresponding commits here on GitHub. Could you please add version labels/tags to your commits which lead/led to versions on PyPI ?

The reason is that I would like to build conda packages for your package which is much more comfortable to use with Git tags than with PyPI archive files.

Thanks!

Wolfgang

Odd ylabel position in plot_time_freq

Using plot_time_freq of a Window. The ylabel of the spectrum is plotted over the time domain plot.
Possible solution: add some space between time domain and frequency domain plot.

MWE:

import spectrum
wind=spectrum.Window(128,'hanning')
wind.plot_time_freq()

Result
window_hanning

Error in import spectrum with Windows

Hi,

I have an error when trying to import the library after installation with 'pip install spectrum'.
My file system is Windows 10.
This is my error message:

pydev debugger: process 1700 is connecting

Connected to pydev debugger (build 145.1504)
Backend Qt4Agg is interactive backend. Turning interactive mode on.
Traceback (most recent call last):
File "C:\Program Files (x86)\JetBrains\PyCharm Community Edition 2016.1.4\helpers\pydev\pydevd.py", line 1531, in
globals = debugger.run(setup['file'], None, None, is_module)
File "C:\Program Files (x86)\JetBrains\PyCharm Community Edition 2016.1.4\helpers\pydev\pydevd.py", line 938, in run
pydev_imports.execfile(file, globals, locals) # execute the script
File "C:/Users/.../main_temp.py", line 7, in
import preprocessing
File "C:/Users/...\preprocessing.py", line 6, in
import configuration
File "C:/Users/...\configuration.py", line 2, in
from signalprocessing.spectral_analysis import TapersAnalyzer
File "C:/Users/...\signalprocessing__init__.py", line 4, in
import spectral_analysis
File "C:/Users/...\spectral_analysis.py", line 8, in
import spectrum
File "C:\Anaconda2\lib\site-packages\spectrum__init__.py", line 8, in
from .mtm import *
File "C:\Anaconda2\lib\site-packages\spectrum\mtm.py", line 53, in
mtspeclib = ctypes.cdll.LoadLibrary(pj(p, lib_name))
File "C:\Anaconda2\lib\ctypes__init__.py", line 440, in LoadLibrary
return self.dlltype(name)
File "C:\Anaconda2\lib\ctypes__init
_.py", line 362, in init
self._handle = _dlopen(self._name, mode)
WindowsError: [Error 126] The specified module could not be found

when I put a break point earlier in 'mtm.py' line 47:
I get the following error:

File "", line 1, in
ctypes.cdll.LoadLibrary(pj(p, lib_name))
File "C:\Anaconda2\lib\ctypes__init__.py", line 440, in LoadLibrary
return self.dlltype(name)
File "C:\Anaconda2\lib\ctypes__init
_.py", line 362, in init
self._handle = _dlopen(self._name, mode)
WindowsError: [Error 1114] A dynamic link library (DLL) initialization routine failed

Thanks

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

Real datatype, appending last value not always required

TODO comment left at burg.py:145 was right
# TODO: check the last value is correct or required ?
in case int(self.NFFT//2) is odd, appending last value is not required because the length is already odd.

For example,
self.NFFT = 1189 โ€”> int(self.NFFT//2) = **594** โ€”> append... is needed to get length 595
self.NFFT = 1186 โ€”> int(self.NFFT//2) = **593** โ€”> append... is not needed, length already odd

In attach, explanation from MATLAB implementation help
screen shot 2018-11-28 at 08 44 11

The documents cannot be compiled.

Configure file for Sphinx is missing.

Error: Source directory doesn't contain a conf.py file.

Build finished. The HTML pages are in _build/html.

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!

Missing files during installation

I have installed spectrum 0.6.1 on my Anaconda python 3.5 distribution on Mac OS 10.11.5 using pip install spectrum. I then tried to import it from an ipython notebook and I got the following error:

---------------------------------------------------------------------------
OSError                                   Traceback (most recent call last)
/Users/Armen/anaconda/lib/python3.5/site-packages/spectrum/mtm.py in <module>()
     56         lib_name = 'mydpss.so'
---> 57         mtspeclib = ctypes.cdll.LoadLibrary(pj(p, lib_name))
     58     except:

/Users/Armen/anaconda/lib/python3.5/ctypes/__init__.py in LoadLibrary(self, name)
    424     def LoadLibrary(self, name):
--> 425         return self._dlltype(name)
    426 

/Users/Armen/anaconda/lib/python3.5/ctypes/__init__.py in __init__(self, name, mode, handle, use_errno, use_last_error)
    346         if handle is None:
--> 347             self._handle = _dlopen(self._name, mode)
    348         else:

OSError: dlopen(/Users/Armen/anaconda/lib/python3.5/site-packages/spectrum/mydpss.so, 6): image not found

During handling of the above exception, another exception occurred:

OSError                                   Traceback (most recent call last)
<ipython-input-1-c2dabc14c746> in <module>()
----> 1 import spectrum

/Users/Armen/anaconda/lib/python3.5/site-packages/spectrum/__init__.py in <module>()
      6 default_NFFT = 4096
      7 
----> 8 from .mtm import *
      9 from .transfer import *
     10 from .arma import *

/Users/Armen/anaconda/lib/python3.5/site-packages/spectrum/mtm.py in <module>()
     61         minor = sys.version_info.minor
     62         lib_name = 'mydpss.cpython-{0}{1}m.so'.format(major, minor)
---> 63         mtspeclib = ctypes.cdll.LoadLibrary(pj(p, lib_name))
     64 else:
     65     try:

/Users/Armen/anaconda/lib/python3.5/ctypes/__init__.py in LoadLibrary(self, name)
    423 
    424     def LoadLibrary(self, name):
--> 425         return self._dlltype(name)
    426 
    427 cdll = LibraryLoader(CDLL)

/Users/Armen/anaconda/lib/python3.5/ctypes/__init__.py in __init__(self, name, mode, handle, use_errno, use_last_error)
    345 
    346         if handle is None:
--> 347             self._handle = _dlopen(self._name, mode)
    348         else:
    349             self._handle = handle

OSError: dlopen(/Users/Armen/anaconda/lib/python3.5/site-packages/spectrum/mydpss.cpython-35m.so, 6): image not found

I had a friend email me those files, and I placed them where they belonged, and now it imports successfully. What went wrong during my installation? I believe this issue might be related to #14 .

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'

Strong line in the middle of MTM spectrum

Hi,
when using MTM, I get a strong component at zero, which looks like an artifact, no matter what the time bandwidth product or the number of Slepians are. For comparison, I send the pure FFT (numpy) compared to MTM (spectrum 0.6.1) of an example data set. This happens of course with other data as well.

Any ideas are welcome!
Cheers!

UPDATE:

sorry it seems that I have been feeding the pmtm abs value of a complex (IQ) signal, which is the cause of the problem. Now I have to check how to go complex.

:-)

Failed to build spectrum

Failed to build spectrum
Installing collected packages: spectrum
Running setup.py install for spectrum ... error

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)

method used in spectrum.ma ?

Hi :) I would like to use your MA parameters estimations. But i don't find the name of the used method. Is it th Durbin's method ? (Some similarities)

Thanks,

Claire

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

Window function input should be integer

Issue: error dealing with rectangular windows for correlog.
Source file: spectrum/src/spectrum/correlog.py
Line: 112

Reason:
The '2.*lag+1' which is a float output gives error for generating rectangular windows. So the window input should always be integer.

Change '2.lag+1' to '2lag+1'

Fixed line:
w = Window(2*lag+1, window, **window_params)

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.

Spectrum on AWS Lambda DistributionNotFound

Hi,
I am hoping to get some help. I am building AWS Lambda function with pyHRV that uses spectrum. I am running into an error when deploying with Serverless Framework.

The error looks like this:

[ERROR] DistributionNotFound: The 'spectrum' distribution was not found and is required by the application
Traceback (most recent call last):
  File "/var/task/serverless_sdk/__init__.py", line 128, in wrapped_handler
    return user_handler(event, context)
  File "/var/task/s_HQ_Analyser.py", line 23, in error_handler
    raise e
  File "/var/runtime/bootstrap.py", line 131, in handle_event_request
    response = request_handler(event, lambda_context)
  File "/var/task/serverless_sdk/__init__.py", line 128, in wrapped_handler
    return user_handler(event, context)
  File "/var/task/s_HQ_Analyser.py", line 23, in error_handler
    raise e
  File "/var/runtime/bootstrap.py", line 131, in handle_event_request
    response = request_handler(event, lambda_context)
  File "/var/task/serverless_sdk/__init__.py", line 128, in wrapped_handler
    return user_handler(event, context)
  File "/var/task/s_HQ_Analyser.py", line 23, in error_handler
    raise e
  File "/var/task/s_HQ_Analyser.py", line 18, in <module>
    user_handler = serverless_sdk.get_user_handler('hq-analyser.main')
  File "/var/task/serverless_sdk/__init__.py", line 54, in get_user_handler
    user_module = import_module(user_module_name)
  File "/var/lang/lib/python3.8/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 783, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/var/task/hq-analyser.py", line 16, in <module>
    import pyhrv
  File "/tmp/sls-py-req/pyhrv/__init__.py", line 36, in <module>
    from pyhrv.hrv import hrv
  File "/tmp/sls-py-req/pyhrv/hrv.py", line 47, in <module>
    import pyhrv.frequency_domain as fd
  File "/tmp/sls-py-req/pyhrv/frequency_domain.py", line 46, in <module>
    import spectrum
  File "/tmp/sls-py-req/spectrum/__init__.py", line 19, in <module>
    from .datasets import *
  File "/tmp/sls-py-req/spectrum/datasets.py", line 148, in <module>
    dolphin_filename = spectrum_data("DOLPHINS.wav")
  File "/tmp/sls-py-req/spectrum/datasets.py", line 137, in spectrum_data
    info = pkg_resources.get_distribution('spectrum')
  File "/tmp/sls-py-req/pkg_resources/__init__.py", line 482, in get_distribution
    dist = get_provider(dist)
  File "/tmp/sls-py-req/pkg_resources/__init__.py", line 358, in get_provider
    return working_set.find(moduleOrReq) or require(str(moduleOrReq))[0]
  File "/tmp/sls-py-req/pkg_resources/__init__.py", line 901, in require
    needed = self.resolve(parse_requirements(requirements))
  File "/tmp/sls-py-req/pkg_resources/__init__.py", line 787, in resolve
    raise DistributionNotFound(req, requirers)

I am not to sure what this error means and do not have much more info on this which makes it hard to debug. I was thinking that it might relate to Spectrum and how it gets installed in the environment. I am using serverless-python-requirements and docker to manage the python dependencies.

Apologies if this is not the right place to log an issue.
Any help or point in the right direction would be great.

Thanks

Multi-tapering example not working

I'm trying to test the multi-taper calculation with the example:

from spectrum import *

data = data_cosine(N=2048, A=0.1, sampling=1024, freq=200)
# If you already have the DPSS windows
[tapers, eigen] = dpss(2048, 2.5, 4)
res = pmtm(data, e=tapers, v=eigen, show=False)

But I'm getting the error:

ValueError: operands could not be broadcast together with shapes (4,) (2048,)

I'm using latest Spectrum with anaconda on Windows 64-bit.

problem when calculating psd using pburg method with "real" signal

Hi,
I was trying to estimate the psd of a sinusoidal signal and I got the following exception:

    *** TypeError: slice indices must be integers or None or have an __index__ method

I was using Python 3.6.0 and I've ran the following code:

import numpy as np
import spectrum
t = np.linspace(0, 1, 1000)
s = np.sin(2 * np.pi * 5 * t)
p = spectrum.pburg(s, order=16, NFFT=None, sampling=1000)
p()

The traceback:

    127         #self.psd = psd
    128         if self.datatype == 'real':
--> 129             newpsd  = psd[0:self.NFFT/2]*2
    130             newpsd[0] /= 2.
    131             newpsd = numpy.append(newpsd, psd[-1])

TypeError: slice indices must be integers or None or have an __index__ method

The same happened when I've used an integer for NFFT (i.e 256)

import numpy as np
import spectrum
t = np.linspace(0, 1, 1000)
s = np.sin(2 * np.pi * 5 * t)
p = spectrum.pburg(s, order=16, NFFT=256, sampling=1000)
p()

Thanks in advance

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

consider having Periodogram.run be "lazy executed"

While looking over the documentation (and doing some test runs myself) for openjournals/joss-reviews#348, I high-level API/interface item struck me. Why does p.run() (or p() need to happen at all? All of the subsequent accessor methods or functions (e.g. p.plot(...) or p. pcorrelogram or the like) could "lazily" execute p.run() inside them...? That is, something like:

if not self._has_run:
    self.run()
    self._has_run = True

This would free the user from the seemingly unnecessary task of running run before doing anything they might actually want to get as an output.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.