Skip to content

Commit

Permalink
update doc, test
Browse files Browse the repository at this point in the history
  • Loading branch information
cokelaer committed Aug 20, 2017
1 parent 02e26f2 commit 6f7253c
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 12 deletions.
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ install:
#- conda install --yes python=$TRAVIS_PYTHON_VERSION numpy matplotlib nose coverage cython scipy
- conda install --yes --file requirements.txt
- conda install --yes --file requirements-dev.txt
#- conda install --yes cython
- pip install .
# # command to run tests, e.g. python setup.py test
script:
Expand Down
6 changes: 5 additions & 1 deletion doc/source/overview.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
* 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).


10 changes: 7 additions & 3 deletions doc/source/quickstart.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ We can analyse this data using one of the Power Spectrum Estimation method provi

Here, we have created an object Periodogram. No computation has been performed yet. To run the actual estimation, you can use either::

p() # now you run the estimation
p()

or::

Expand All @@ -40,14 +40,19 @@ and finally, you can plot the resulting PSD::

p.plot(marker='o') # standard matplotlib options are accepted

.. warning::

.. versionchanged:: 0.6.7 you do not need to use p() or p.run() anymore. It will be
called automatically when using p.plot() or when you access to the *psd*
attribute.


.. plot::
:width: 80%

from spectrum import *
data = data_cosine(N=1024, A=0.1, sampling=1024, freq=200)
p = Periodogram(data, sampling=1024) #here you just define the PSD estimate
p() # now you run the estimation
p.plot(marker='o')

Since the data is purely real, the PSD (stored in p.psd) is a onesided PSD, with positive frequencies only. If the data were complex, the two-sided PSD would have been computed and plotted. For the real case, you can still plot a two-sided PSD by setting the sides option manually::
Expand All @@ -61,7 +66,6 @@ Since the data is purely real, the PSD (stored in p.psd) is a onesided PSD, with
from spectrum import *
data = data_cosine(N=1024, A=0.1, sampling=1024, freq=200)
p = Periodogram(data, sampling=1024) #here you just define the PSD estimate
p() # now you run the estimation
p.plot(marker='o', sides='twosided')


Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

_MAJOR = 0
_MINOR = 6
_MICRO = 6
_MICRO = 7
version = '%d.%d.%d' % (_MAJOR, _MINOR, _MICRO)
release = '%d.%d' % (_MAJOR, _MINOR)

Expand Down
6 changes: 3 additions & 3 deletions src/spectrum/psd.py
Original file line number Diff line number Diff line change
Expand Up @@ -452,9 +452,9 @@ def _setData(self, data):

def _getPSD(self):
if self.__psd is None:
logging.warning('PSD not yet computed. call the object to estimate the PSD.')
else:
return self.__psd
logging.debug('Computing PSD.')
self()
return self.__psd
def _setPSD(self, psd):
# Reset the sides attribute depending on the datatype
# if a user sets the PSD manually, the only check available is that
Expand Down
3 changes: 1 addition & 2 deletions test/test_arma.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def test_arma_values():
3.22899406+6.39981425j, 3.16557650+5.92783737j,
3.47120865+5.48246963j, 2.79508215+3.3238971j ,
2.13174602+1.51034329j]), decimal=4)


def test_arma():
"""arma, check that rho is correct (appendix 10.A )and reproduce figure 10.2"""
Expand Down Expand Up @@ -73,7 +73,6 @@ def test_arma2psd():

def test_parma():
p = parma(marple_data, 4, 4, 30, NFFT=4096)
p()
p.plot()
print(p)

Expand Down
1 change: 0 additions & 1 deletion test/test_burg.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ def test_burg_criteria():

def test_pburg():
p = pburg(marple_data, 15, NFFT=4096)
p()
p.plot(sides='centerdc')
print(p)
# test real case
Expand Down

0 comments on commit 6f7253c

Please sign in to comment.