# [SciPy-User] Signal to noise ratio

Ivo Maljevic ivo.maljevic@gmail....
Thu Mar 4 11:48:50 CST 2010

If your signal is sampled at 200 Hz (like in this example), and you want to
filter out everything above 4 Hz or 12 Hz, you might want to consider using
a wider LPF first, downsapling the signal, and then doing the filtering.
Usually, sampling rate is related to the frequency content of the signal
(Nyquist), and since your signal of interest is much narrower, you have very
high oversampling (maybe due to very wide noise?).

In any case, even Matlab wouldn't help you much if you wanted to implement
such a narrow LPF:

Python:

>>> b, a = butter(14, ws3, 'low')
C:\Python26\lib\site-packages\scipy\signal\filter_design.py:221:
results may be meaningless
C:\Python26\lib\site-packages\scipy\signal\filter_design.py:221:
results may be meaningless
>>> ws3
0.040000000000000001
>>> b
array([  1.21542041e-16,   7.90023266e-16,   3.16009306e-15,
8.69025592e-15,   1.73805118e-14,   2.60707678e-14,
2.97951632e-14,   2.60707678e-14,   1.73805118e-14,
8.69025592e-15,   3.16009306e-15,   7.90023266e-16,
1.21542041e-16,   8.68157435e-18])
>>> a
array([  1.00000000e+00,  -1.28776717e+01,   7.70365408e+01,
-2.83749831e+02,   7.18912579e+02,  -1.32537586e+03,
1.83351674e+03,  -1.93352359e+03,   1.56186993e+03,
-9.61728148e+02,   4.44354147e+02,  -1.49385526e+02,
3.45431991e+01,  -4.91770336e+00,   3.25194854e-01])

Matlab:

>> [b,a]=butter(14, 0.04, 'low')
b =
Columns 1 through 12
0     0     0     0     0     0     0     0     0     0     0     0
Columns 13 through 15
0     0     0

a =
1.0e+003 *
Columns 1 through 7
0.0010   -0.0129    0.0770   -0.2837    0.7189   -1.3254    1.8335
Columns 8 through 14
-1.9335    1.5619   -0.9617    0.4444   -0.1494    0.0345   -0.0049
Column 15
0.0003

On 4 March 2010 12:24, Warren Weckesser <warren.weckesser@enthought.com>wrote:

> Ariel Rokem wrote:
> > Hi Warren,
> >
> > thanks for this example!
> >
> > I am getting the following error:
> >
> >
> Library/Frameworks/Python.framework/Versions/6.0.0/lib/python2.6/site-packages/scipy/signal/filter_design.py:224:
> > the results may be meaningless
> >   "results may be meaningless", BadCoefficients)
> >
> > For any attempt to filter a low-pass below 12 Hz in this example (so -
> > I don't get the plot you got - instead I get a flat line on the bottom
> > subplot). Do you (or anyone?) have any idea why that is?
> >
>
> Nils Wagner reported the same behavior a week or so ago, and I see the
> same behavior now ("BadCoefficients" and a flat line in the last plot).
> Try lowering the order of the Butterworth filter to order=6.
>
> Warren
>
>
> > Cheers,
> >
> > Ariel
> >
> > On Wed, Feb 24, 2010 at 7:51 AM, Warren Weckesser
> > <warren.weckesser@enthought.com
> > <mailto:warren.weckesser@enthought.com>> wrote:
> >
> >     Nils Wagner wrote:
> >     > Hi all,
> >     >
> >     > I have two questions concerning signal processing
> >     >
> >     > I have used scipy.stats.signaltonoise to compute the
> >     > signal-to-noise ratio.
> >     > The value is 0.0447.
> >     > How can I judge it ?
> >     >
> >     > How can I filter out high frequencies using scipy ?
> >     >
> >
> >     I posted an example low-pass filtering using 'butter' and
> >     'lfilter' from
> >     scipy.signal here:
> >
> >
> http://mail.scipy.org/pipermail/scipy-user/2010-January/024032.html
> >
> >     Warren
> >
> >     > How can I eliminate noise from the signal ?
> >     >
> >     > Nils
> >     > _______________________________________________
> >     > SciPy-User mailing list
> >     > SciPy-User@scipy.org <mailto:SciPy-User@scipy.org>
> >     > http://mail.scipy.org/mailman/listinfo/scipy-user
> >     >
> >
> >     _______________________________________________
> >     SciPy-User mailing list
> >     SciPy-User@scipy.org <mailto:SciPy-User@scipy.org>
> >     http://mail.scipy.org/mailman/listinfo/scipy-user
> >
> >
> >
> >
> > --
> > Ariel Rokem
> > Helen Wills Neuroscience Institute
> > University of California, Berkeley
> > http://argentum.ucbso.berkeley.edu/ariel
> > ------------------------------------------------------------------------
> >
> > _______________________________________________
> > SciPy-User mailing list
> > SciPy-User@scipy.org
> > http://mail.scipy.org/mailman/listinfo/scipy-user
> >
>
> _______________________________________________
> SciPy-User mailing list
> SciPy-User@scipy.org
> http://mail.scipy.org/mailman/listinfo/scipy-user
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/scipy-user/attachments/20100304/bdbe2033/attachment-0001.html