Git Product home page Git Product logo

python-deltasigma's Introduction

python-deltasigma

A port of the MATLAB Delta Sigma Toolbox based on free software and very little sleep

The python-deltasigma is a Python package to synthesize, simulate, scale and map to implementable topologies delta sigma modulators.

It aims to provide a 1:1 Python port of Richard Schreier's excellent MATLAB Delta Sigma Toolbox, the de facto standard tool for high-level delta sigma simulation, upon which it is very heavily based.


Homepage: python-deltasigma.io

Documentation: docs.python-deltasigma.io

Latest version: 0.2

Build Status Coverage Status PyPi version PyPi downloads PyPi pythons BSD 2 clause license DOI


Status

The fundamental functionality is available and working.

Secondary features such as "native" quadrature modulator support, PIS calculation or ESL are still work in progress. A list of functions and files is included in files.csv, updated with the current status.

Further functionality is expected to be completed in the next versions according to the ROADMAP.

Install

python-deltasigma runs on Linux, Mac OS X and Windows.

Installing requires Python 2.6+ or 3.3+, numpy, scipy (>= 0.11.0) and matplotlib.

Strongly recommended: Cython - for significantly faster delta sigma modulator simulations.

They are packaged by virtually all the major Linux distributions.

I do not run Windows, so I can't really provide more info (sorry), except that people tell me they manage to have a working setup.

When the dependencies are satisfied, run:

pip install deltasigma

to install the latest stable version from the Python Package Index (PYPI), or:

python setup.py install

if you're installing a development version from Git.

Extras

Install the sphinx package to build the documentation yourself.

The test suite requires setuptools, used to access the reference function outputs.

Testing can be automated with nose, issuing:

nosetests -v deltasigma

Documentation

In addition to the notebooks found in the examples/ directory, ported from the MATLAB Delta Sigma toolbox:

  1. You can find the included package documentation online.

  2. The original MATLAB Toolbox provides in-depth documentation, which is very useful to understand what the toolbox is capable of. See DSToolbox.pdf and OnePageStory.pdf (PDF warning).

  3. The book:

    Richard Schreier, Gabor C. Temes, Understanding Delta-Sigma Data Converters, ISBN: 978-0-471-46585-0, November 2004, Wiley-IEEE Press

    is probably the most authoritative resource on the topic. Chapter 8-9 show how to use the MATLAB toolkit and the observations apply also to this Python port. Links on amazon, on the Wiley-IEEE press.

    I am not affiliated with neither the sellers nor the authors.

How to contribute

I write this software in my free time, this is not funded research.

If you find this package useful, you are welcome to freely contribute to its development in one of the following ways.

Send a pull request my way

Pull requests are most gladly received!

There are only a few guidelines, which can be overridden every time it is reasonable to do so:

  • Please try to follow PEP8.

  • Try to keep the functions signature identical. Parameters with NaN/[] as default values have their default value replaced with None.

  • If a function has a varible number of return values, its Python port should implement the maximum number of return values.

Support python-deltasigma with a donation

I do not want your money. I develop this software because I enjoy it and because I use it myself.

If you wish to support the development of python-deltasigma and you wish to contribute monetarily, please donate to cancer research instead:

Consider sending me a mail afterwards, it makes for great motivation!

Licensing and copyright notice

All original MATLAB code is Copyright (c) 2009, Richard Schreier. See the LICENSE file for the licensing terms.

The Python code here provided is a derivative work from the above toolkit and subject to the same license terms.

This package contains some source code from pydsm, also based on the same MATLAB toolbox. The pydsm package is copyright (c) 2012, Sergio Callegari.

When not otherwise specified, the Python code is Copyright 2013, Giuseppe Venturini and the python-deltasigma contributors.

MATLAB is a registered trademark of The MathWorks, Inc.

python-deltasigma's People

Contributors

ggventurini avatar schodge avatar thomasrussellmurphy 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

python-deltasigma's Issues

Anaconda MKL (no blas.h)

I installed the Anaconda MKL extensions - which includes BLAS - but it doesn't include C header files, everything is precompiled. http://docs.continuum.io/mkl-optimizations/index.html

I received this error, is there an easy way to make the program use the faster MKL extensions / BLAS? (Apologies if this question doesn't make a ton of sense, I don't completely understand the Python/Cython/BLAS/MKL interaction/architecture here).

C:\Anaconda\lib\site-packages\deltasigma\_config.py:40: UserWarning: Numpy did not detect the BLAS library in the system
  warn("Numpy did not detect the BLAS library in the system")
C:\Anaconda\lib\site-packages\deltasigma\_config.py:55: UserWarning: Cannot find the path for 'cblas.h'. You may set it using the environment variable BLAS_H.
NOTE: You need to pass the path to the directories were the header files are, not the path to the files.
  warn("Cannot find the path for 'cblas.h'. You may set it using the environment variable "

Unit test setup

I was wondering if you'd be willing to take pull requests moving the tests into their own files. I was trying to track down an issue on windows, and would get an error that I couldn't import * when I ran nosetests -v ./deltasigma/*.py. What I think is happening is on *nix systems the shell is globbing the *.py and replacing it with all the filenames. cmd.exe doesn't do this on Windows, and so when I try to just run nosetests it doesn't find any tests. I think that's because nosetests is generally looking for tests in places they're not located in this package: http://nose.readthedocs.org/en/latest/finding_tests.html

It would (theoretically) be fairly simple to move over the tests into their own file, but I don't know if you want that architecture change.

DocumentNTF(NTF1,osr=8) shows blank plots

DocumentNTF(NTF1,osr=8) shows blank plots
Errors are:
plotPZ(ntf, 'b', 6, showlist=False) line 85, in plotPZ
hold_status = plt.ishold()
AttributeError: module 'pylab' has no attribute 'ishold'
Please suggest an alternative to get the plot in spyder windows

nosetest failures

Hello everyone. I ran

nosetests -v deltasigma

and lots of errors came up. What could be the problem? I am running this inside a CentOS 7 container with what i think all dependencies installed.
nose.txt

Using deprecated NumPy API warnings

.../numpy/core/include/numpy/npy_1_7_deprecated_api.h:15:2: warning: #warning "Using deprecated NumPy API, disable it by " "#defining NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION" [-Wcpp]

pulse fails its unit test

/usr/lib/python2.7/dist-packages/scipy/signal/ltisys.py:554: ComplexWarning: Casting complex values to real discards the imaginary part
  GT = dot(dot(vti, diag(numpy.exp(dt * lam))), vt).astype(xout.dtype)
/usr/lib/python2.7/dist-packages/scipy/signal/ltisys.py:568: ComplexWarning: Casting complex values to real discards the imaginary part
  vt).astype(xout.dtype)
E
======================================================================
ERROR: Test function for pulse()
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/nose/case.py", line 197, in runTest
    self.test(*self.arg)
  File "./python-deltasigma/pydelsigma/_pulse.py", line 103, in test_pulse
    pp = pulse(H, tp=(0., 1.), dt=.1, tfinal=10., nosum=False)
  File "./python-deltasigma/pydelsigma/_pulse.py", line 89, in pulse
    yy = + np.concatenate((np.zeros(z1), y1[:nf-n1+1, :, (i-1)*nis:i*nis+1]), axis=0) \
ValueError: all the input array dimensions except for the concatenation axis must match exactly

----------------------------------------------------------------------
Ran 1 test in 0.022s

FAILED (errors=1)

realizeNTF_ct failure for FF structure

The function realizeNTF_ct breaks for feed forward (FF) structure.

Try the test defined for realizeNTF but with FF from instead of FB form:

ntf = (np.array([1., 1.]), np.array([0., 0.]), 1)
ABCDc, tdac2 = realizeNTF_ct(ntf, 'FF')

Traceback:

ValueError                                Traceback (most recent call last)
<ipython-input-71-9373c6f6636c> in <module>()
      1 ntf = (np.array([1., 1.]), np.array([0., 0.]), 1)
----> 2 ABCDc, tdac2 = realizeNTF_ct(ntf, 'FF')
      3 print(ABCDc)
      4 print(tdac2)

anaconda/lib/python2.7/site-packages/deltasigma-0.1-py2.7.egg/deltasigma/_realizeNTF_ct.pyc in realizeNTF_ct(ntf, form, tdac, ordering, bp, ABCDc)
    214     sys_c = []
    215     for i in range(Bc.shape[1]): # number of inputs
--> 216         sys_c.append(ss2zpk(Ac, Bc, Cc, Dc, input=i))
    217     yy = pulse(sys_c, tp, 1, n_imp, 1)
    218     yy = np.squeeze(yy)

anaconda/lib/python2.7/site-packages/scipy/signal/ltisys.pyc in ss2zpk(A, B, C, D, input)
    223 
    224     """
--> 225     return tf2zpk(*ss2tf(A, B, C, D, input=input))
    226 
    227 

anaconda/lib/python2.7/site-packages/scipy/signal/ltisys.pyc in ss2tf(A, B, C, D, input)
    177 
    178     num_states = A.shape[0]
--> 179     type_test = A[:, 0] + B[:, 0] + C[0, :] + D
    180     num = numpy.zeros((nout, num_states + 1), type_test.dtype)
    181     for k in range(nout):

ValueError: operands could not be broadcast together with shapes (2) (3) 

Problem with simulateDSM for nlev > 3

It looks simulateDSM operates correctly for nlev=2 and nlev=3 but not for nlev > 3:
for even nlev it gives same results as for nlev=2 and for odd nlev it gives same results as for nlev=3.

/usr/bin/ld: cannot find -lcblas

deltasigma is working nicely for me on a Mac 10.9 setup, but not on 10.11 and not on Ubuntu. The problems are all to do with cblas.
On Mac OS 10.11 and up /usr/include is "restricted", and opencblas puts things in a weird place (/opt/local/include/cblas.h).
On my linux 4.5.3-x86_64 I have /usr/include/cblas.h, and instead get the message in the title when I "import deltasigma"
Any help appreciated; your python version of deltasigma is much more useful than the Matlab one.

Unit Test Migration File Tracker

Files that have had tests moved to separate file in /tests/ folder:

  • _axisLabels.py (PR #31)
  • _bilogplot.py
  • _bplogsmooth.py
  • _bquantize.py
  • _bunquantize.py
  • _calculateSNR.py
  • _calculateTF.py
  • _cancelPZ.py
  • _changeFig.py (no programmatic test to port)
  • _circ_smooth.py
  • _clans.py
  • _config.py (no test to port)
  • _constants.py (no test to port)
  • _db.py
  • _dbm.py
  • _dbp.py
  • _dbv.py
  • _delay.py
  • _DocumentNTF.py
  • _dsclansNTF.py
  • _ds_f1f2.py
  • _ds_freq.py
  • _ds_hann.py
  • _ds_optzeros.py
  • _ds_quantize.py
  • _ds_synNTFobj1.py
  • _evalF0.py
  • _evalF1.py
  • _evalMixedTF.py
  • _evalRPoly.py
  • _evalTF.py
  • _evalTFP.py
  • _figureMagic.py
  • _frespF1.py (no test)
  • _impL1.py
  • _infnorm.py
  • _l1norm.py
  • _logsmooth.py
  • _lollipop.py
  • _mapABCD.py
  • _mapCtoD.py
  • _mapQtoR.py
  • _mapRtoQ.py
  • _mod1.py
  • _mod2.py
  • _nabsH.py
  • _padb.py
  • _padl.py
  • _padr.py
  • _padt.py
  • _partitionABCD.py
  • _peakSNR.py
  • _PlotExampleSpectrum.py
  • _plotPZ.py
  • _plotSpectrum.py
  • _predictSNR.py
  • _pulse.py
  • _realizeNTF.py
  • _realizeNTF_ct.py
  • _rms.py
  • _rmsGain.py
  • _scaleABCD.py
  • _simulateDSM.py
  • _simulateDSM_python.py
  • _simulateSNR.py
  • _sinc_decimate.py
  • _SIunits.py
  • _stuffABCD.py
  • _synthesizeChebyshevNTF.py
  • _synthesizeNTF.py
  • _synthesizeNTF0.py
  • _synthesizeNTF1.py
  • _test_dsdemo.py
  • _thermometer.py
  • _undbm.py
  • _undbp.py
  • _undbv.py
  • _utils.py
  • _zinc.py

Fix to work with new scipy 0.16.x

New LTI description have been added to scipy in version 0.16.0, effectively breaking the API for functions and classes in the ltisubpackage .

For now, users should stick with 0.15.x (and lower) versions of the library

For the future, we should decide what to do:

  • Support 0.16.0 and break support with previous versions of the library,
  • Attempt to support all versions

Obviously the latter being best, if custom code can be kept to a minimum.

Support for different TF representations is inconsistent

Sometimes a TF can be provided only with "simplified zpk form", ie (ndarray zeros, ndarray poles, scalar gain), sometimes an LTI object from scipy is accepted too, sometimes a tuple representation like (ndarray num, ndarray den) is also valid.

  • Evaluate adding an helper method
  • Ensure consistency across the package

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.