[Matplotlib-users] specgram bug

2012-11-12 Thread Paul Anton Letnes
Hi,

not 100% sure this is a bug, but here goes:

In file matplotlib/lib/matplotlib/mlab.py, the functions psd (power spectral 
density) and specgram returns the real part of the fourier transform.
% grep -n Pxx.real mlab.py
390:return Pxx.real,freqs
470:Pxx = Pxx.real #Needed since helper implements generically
(git version 4f902fac1c5bf267e3fdeb4c2045926d7498e85a, cloned from github today)

This all means that the specgram plot routine yields the real part of the 
Fourier transform, rather than its absolute square (forgetting normalization 
for simplicity of discussion). The definition of the PSD is that it is the 
absolute square of the Fourier transform:
https://en.wikipedia.org/wiki/Power_spectral_density#Energy_spectral_density

Hence, I believe this is a bug which should be fixed.

Cheers
Paul
--
Monitor your physical, virtual and cloud infrastructure from a single
web console. Get in-depth insight into apps, servers, databases, vmware,
SAP, cloud infrastructure, etc. Download 30-day Free Trial.
Pricing starts from $795 for 25 servers or applications!
http://p.sf.net/sfu/zoho_dev2dev_nov
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] specgram bug

2012-11-12 Thread G Jones
Hi,
If you trace back into the code further, you will see that the Pxx is
computed as X = fft(x), Pxx = X * conj(X) which is real, but the data
type will be complex with a ~0 imaginary part (up to floating point
precision). Thus the Pxx.real is just to ensure that the resulting
data type is real instead of complex to save memory.
Glenn

On Mon, Nov 12, 2012 at 11:42 AM, Paul Anton Letnes
paul.anton.let...@gmail.com wrote:
 Hi,

 not 100% sure this is a bug, but here goes:

 In file matplotlib/lib/matplotlib/mlab.py, the functions psd (power spectral 
 density) and specgram returns the real part of the fourier transform.
 % grep -n Pxx.real mlab.py
 390:return Pxx.real,freqs
 470:Pxx = Pxx.real #Needed since helper implements generically
 (git version 4f902fac1c5bf267e3fdeb4c2045926d7498e85a, cloned from github 
 today)

 This all means that the specgram plot routine yields the real part of the 
 Fourier transform, rather than its absolute square (forgetting normalization 
 for simplicity of discussion). The definition of the PSD is that it is the 
 absolute square of the Fourier transform:
 https://en.wikipedia.org/wiki/Power_spectral_density#Energy_spectral_density

 Hence, I believe this is a bug which should be fixed.

 Cheers
 Paul
 --
 Monitor your physical, virtual and cloud infrastructure from a single
 web console. Get in-depth insight into apps, servers, databases, vmware,
 SAP, cloud infrastructure, etc. Download 30-day Free Trial.
 Pricing starts from $795 for 25 servers or applications!
 http://p.sf.net/sfu/zoho_dev2dev_nov
 ___
 Matplotlib-users mailing list
 Matplotlib-users@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/matplotlib-users

--
Monitor your physical, virtual and cloud infrastructure from a single
web console. Get in-depth insight into apps, servers, databases, vmware,
SAP, cloud infrastructure, etc. Download 30-day Free Trial.
Pricing starts from $795 for 25 servers or applications!
http://p.sf.net/sfu/zoho_dev2dev_nov
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] specgram bug

2012-11-12 Thread G Jones
If you're using pyplot.specgram (i.e. from pylab import *;
specgram(...)), note that the plot is in dB, hence the negative
values.
I'm surprised this fact isn't mentioned in the documentation:
http://matplotlib.org/api/pyplot_api.html?highlight=specgram#matplotlib.pyplot.specgram

However, when in doubt, look at the code.

On Mon, Nov 12, 2012 at 12:28 PM, Paul Anton Letnes
paul.anton.let...@gmail.com wrote:
 Heh,

 that's funny. Now then, why do my plots come out with negative values all 
 over the place? That's why I started digging around. After all, X * conj(X) 
 should be equal to the absolute square of X, right?

 Paul


 On 12. nov. 2012, at 21:00, G Jones wrote:

 Hi,
 If you trace back into the code further, you will see that the Pxx is
 computed as X = fft(x), Pxx = X * conj(X) which is real, but the data
 type will be complex with a ~0 imaginary part (up to floating point
 precision). Thus the Pxx.real is just to ensure that the resulting
 data type is real instead of complex to save memory.
 Glenn

 On Mon, Nov 12, 2012 at 11:42 AM, Paul Anton Letnes
 paul.anton.let...@gmail.com wrote:
 Hi,

 not 100% sure this is a bug, but here goes:

 In file matplotlib/lib/matplotlib/mlab.py, the functions psd (power 
 spectral density) and specgram returns the real part of the fourier 
 transform.
 % grep -n Pxx.real mlab.py
 390:return Pxx.real,freqs
 470:Pxx = Pxx.real #Needed since helper implements generically
 (git version 4f902fac1c5bf267e3fdeb4c2045926d7498e85a, cloned from github 
 today)

 This all means that the specgram plot routine yields the real part of the 
 Fourier transform, rather than its absolute square (forgetting 
 normalization for simplicity of discussion). The definition of the PSD is 
 that it is the absolute square of the Fourier transform:
 https://en.wikipedia.org/wiki/Power_spectral_density#Energy_spectral_density

 Hence, I believe this is a bug which should be fixed.

 Cheers
 Paul
 --
 Monitor your physical, virtual and cloud infrastructure from a single
 web console. Get in-depth insight into apps, servers, databases, vmware,
 SAP, cloud infrastructure, etc. Download 30-day Free Trial.
 Pricing starts from $795 for 25 servers or applications!
 http://p.sf.net/sfu/zoho_dev2dev_nov
 ___
 Matplotlib-users mailing list
 Matplotlib-users@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/matplotlib-users


--
Monitor your physical, virtual and cloud infrastructure from a single
web console. Get in-depth insight into apps, servers, databases, vmware,
SAP, cloud infrastructure, etc. Download 30-day Free Trial.
Pricing starts from $795 for 25 servers or applications!
http://p.sf.net/sfu/zoho_dev2dev_nov
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] specgram memory problem

2012-02-06 Thread Fabrice Silva
On Sat, Feb 4, 2012 at 9:44 AM, Fabrice Silva si...@lma.cnrs-mrs.fr wrote:
 Le vendredi 03 février 2012 à 17:39 +, David Craig a écrit :
  sure how to get it to plot the outputs from specgram. I use
  specgram as follows,
  Pxx, freqs, bins, im = plt.specgram(..)
  what am I trying imshow??
 
 
 plt.specgram computes the spectrogram and when calls imshow to display
 the resulting array into an image
 
 Please tell the shape of Pxx, and try the following
 
 import numpy as np
 import matplotlib.pyplot as plt
 a = np.empty((12000, 14400), dtype=float)
 plt.imshow(a)
 plt.show()

Le samedi 04 février 2012 à 10:30 +, David Craig a écrit :
 Pxx has shape (6001, 1430) and when I tried the lines of code it returned the 
 following memory error,
 
 Traceback (most recent call last):
   File /usr/lib/python2.7/site-packages/matplotlib/backends/backend_gtk.py, 
 line 394, in expose_event
 self._render_figure(self._pixmap, w, h)
   File 
 /usr/lib/python2.7/site-packages/matplotlib/backends/backend_gtkagg.py, 
 line 75, in _render_figure
 FigureCanvasAgg.draw(self)
   File /usr/lib/python2.7/site-packages/matplotlib/backends/backend_agg.py, 
 line 394, in draw
 self.figure.draw(self.renderer)
   File /usr/lib/python2.7/site-packages/matplotlib/artist.py, line 55, in 
 draw_wrapper
 draw(artist, renderer, *args, **kwargs)
   File /usr/lib/python2.7/site-packages/matplotlib/figure.py, line 798, in 
 draw
 func(*args)
   File /usr/lib/python2.7/site-packages/matplotlib/artist.py, line 55, in 
 draw_wrapper
 draw(artist, renderer, *args, **kwargs)
   File /usr/lib/python2.7/site-packages/matplotlib/axes.py, line 1946, in 
 draw
 a.draw(renderer)
   File /usr/lib/python2.7/site-packages/matplotlib/artist.py, line 55, in 
 draw_wrapper
 draw(artist, renderer, *args, **kwargs)
   File /usr/lib/python2.7/site-packages/matplotlib/image.py, line 354, in 
 draw
 im = self.make_image(renderer.get_image_magnification())
   File /usr/lib/python2.7/site-packages/matplotlib/image.py, line 569, in 
 make_image
 transformed_viewLim)
   File /usr/lib/python2.7/site-packages/matplotlib/image.py, line 201, in 
 _get_unsampled_image
 x = self.to_rgba(self._A, self._alpha)
   File /usr/lib/python2.7/site-packages/matplotlib/cm.py, line 193, in 
 to_rgba
 x = self.norm(x)
   File /usr/lib/python2.7/site-packages/matplotlib/colors.py, line 802, in 
 __call__
 val = ma.asarray(value).astype(np.float)
   File /usr/lib/python2.7/site-packages/numpy/ma/core.py, line 2908, in 
 astype
 output = self._data.astype(newtype).view(type(self))
 MemoryError

Please, answer on the mailing list,
It confirms that the troubles lie in the rendering of images. Could you
tell the versions of numpy and matplotlib you are using, and the
characteristics of the computer you are working on ?


--
Try before you buy = See our experts in action!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-dev2
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] specgram memory problem

2012-02-06 Thread David Craig
I'm using a lenovo laptop with fedora 16. It has 2.9 GiB memory and 4  
intel core CPUs @ 2.3GHz each. Available disk space is 147.9GiB.
numpy 1.6.0
matplotlib 1.0.1


On 6 Feb 2012, at 10:29, Fabrice Silva wrote:

 On Sat, Feb 4, 2012 at 9:44 AM, Fabrice Silva si...@lma.cnrs- 
 mrs.fr wrote:
 Le vendredi 03 février 2012 à 17:39 +, David Craig a  
 écrit :
 sure how to get it to plot the outputs from specgram. I use
 specgram as follows,
 Pxx, freqs, bins, im = plt.specgram(..)
 what am I trying imshow??


 plt.specgram computes the spectrogram and when calls  
 imshow to display
 the resulting array into an image

 Please tell the shape of Pxx, and try the following

 import numpy as np
 import matplotlib.pyplot as plt
 a = np.empty((12000, 14400), dtype=float)
 plt.imshow(a)
 plt.show()

 Le samedi 04 février 2012 à 10:30 +, David Craig a écrit :
 Pxx has shape (6001, 1430) and when I tried the lines of code it  
 returned the following memory error,

 Traceback (most recent call last):
   File /usr/lib/python2.7/site-packages/matplotlib/backends/ 
 backend_gtk.py, line 394, in expose_event
 self._render_figure(self._pixmap, w, h)
   File /usr/lib/python2.7/site-packages/matplotlib/backends/ 
 backend_gtkagg.py, line 75, in _render_figure
 FigureCanvasAgg.draw(self)
   File /usr/lib/python2.7/site-packages/matplotlib/backends/ 
 backend_agg.py, line 394, in draw
 self.figure.draw(self.renderer)
   File /usr/lib/python2.7/site-packages/matplotlib/artist.py,  
 line 55, in draw_wrapper
 draw(artist, renderer, *args, **kwargs)
   File /usr/lib/python2.7/site-packages/matplotlib/figure.py,  
 line 798, in draw
 func(*args)
   File /usr/lib/python2.7/site-packages/matplotlib/artist.py,  
 line 55, in draw_wrapper
 draw(artist, renderer, *args, **kwargs)
   File /usr/lib/python2.7/site-packages/matplotlib/axes.py, line  
 1946, in draw
 a.draw(renderer)
   File /usr/lib/python2.7/site-packages/matplotlib/artist.py,  
 line 55, in draw_wrapper
 draw(artist, renderer, *args, **kwargs)
   File /usr/lib/python2.7/site-packages/matplotlib/image.py,  
 line 354, in draw
 im = self.make_image(renderer.get_image_magnification())
   File /usr/lib/python2.7/site-packages/matplotlib/image.py,  
 line 569, in make_image
 transformed_viewLim)
   File /usr/lib/python2.7/site-packages/matplotlib/image.py,  
 line 201, in _get_unsampled_image
 x = self.to_rgba(self._A, self._alpha)
   File /usr/lib/python2.7/site-packages/matplotlib/cm.py, line  
 193, in to_rgba
 x = self.norm(x)
   File /usr/lib/python2.7/site-packages/matplotlib/colors.py,  
 line 802, in __call__
 val = ma.asarray(value).astype(np.float)
   File /usr/lib/python2.7/site-packages/numpy/ma/core.py, line  
 2908, in astype
 output = self._data.astype(newtype).view(type(self))
 MemoryError

 Please, answer on the mailing list,
 It confirms that the troubles lie in the rendering of images. Could  
 you
 tell the versions of numpy and matplotlib you are using, and the
 characteristics of the computer you are working on ?


 -- 
 
 Try before you buy = See our experts in action!
 The most comprehensive online learning library for Microsoft  
 developers
 is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3,  
 MVC3,
 Metro Style Apps, more. Free future releases when you subscribe now!
 http://p.sf.net/sfu/learndevnow-dev2
 ___
 Matplotlib-users mailing list
 Matplotlib-users@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/matplotlib-users


--
Try before you buy = See our experts in action!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-dev2
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] specgram memory problem

2012-02-06 Thread Benjamin Root
On Mon, Feb 6, 2012 at 11:59 AM, David Craig dcdavem...@gmail.com wrote:

 I'm using a lenovo laptop with fedora 16. It has 2.9 GiB memory and 4
 intel core CPUs @ 2.3GHz each. Available disk space is 147.9GiB.
 numpy 1.6.0
 matplotlib 1.0.1


32-bit or 64-bit OS?  Please use 'uname -a' to tell us, because you can
install a 32-bit OS on a 64-bit machine.

Ben Root
--
Try before you buy = See our experts in action!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-dev2___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] specgram memory problem

2012-02-06 Thread David Craig
uname -a gives,
Linux David 3.2.2-1.fc16.i686 #1 SMP Thu Jan 26 03:38:31 UTC 2012 i686 i686
i386 GNU/Linux

On Mon, Feb 6, 2012 at 6:07 PM, Benjamin Root ben.r...@ou.edu wrote:



 On Mon, Feb 6, 2012 at 11:59 AM, David Craig dcdavem...@gmail.com wrote:

 I'm using a lenovo laptop with fedora 16. It has 2.9 GiB memory and 4
 intel core CPUs @ 2.3GHz each. Available disk space is 147.9GiB.
 numpy 1.6.0
 matplotlib 1.0.1


 32-bit or 64-bit OS?  Please use 'uname -a' to tell us, because you can
 install a 32-bit OS on a 64-bit machine.

 Ben Root


--
Try before you buy = See our experts in action!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-dev2___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] specgram memory problem

2012-02-04 Thread Fabrice Silva
Le vendredi 03 février 2012 à 17:39 +, David Craig a écrit :
 sure how to get it to plot the outputs from specgram. I use 
 specgram as follows,
 Pxx, freqs, bins, im = plt.specgram(..)
 what am I trying imshow?? 

plt.specgram computes the spectrogram and when calls imshow to display
the resulting array into an image

Please tell the shape of Pxx, and try the following

import numpy as np
import matplotlib.pyplot as plt
a = np.empty((12000, 14400), dtype=float)
plt.imshow(a)
plt.show()


--
Try before you buy = See our experts in action!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-dev2
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] specgram memory problem

2012-02-03 Thread David Craig
Hi, I am using matplotlib to produce some spectrograms for seismic data. I
am looking at a 10 day period with a sample rate of 20sps. I would like to
have my spectrogram to be composed of 10 minute windows with an overlap of
90%. However when I try and run my script I run out of memory. I can
produce the spectrogram for a maximum of 3 days before an error occurs.
I have also tried to produce a spectrogram for each day and stick them
together using subplot, but I then get the error given below. Anyone know a
way around this??
Thanks,
David

Traceback (most recent call last):
  File
/usr/lib/python2.7/site-packages/matplotlib/backends/backend_gtk.py, line
394, in expose_event
self._render_figure(self._pixmap, w, h)
  File
/usr/lib/python2.7/site-packages/matplotlib/backends/backend_gtkagg.py,
line 75, in _render_figure
FigureCanvasAgg.draw(self)
  File
/usr/lib/python2.7/site-packages/matplotlib/backends/backend_agg.py, line
394, in draw
self.figure.draw(self.renderer)
  File /usr/lib/python2.7/site-packages/matplotlib/artist.py, line 55, in
draw_wrapper
draw(artist, renderer, *args, **kwargs)
  File /usr/lib/python2.7/site-packages/matplotlib/figure.py, line 798,
in draw
func(*args)
  File /usr/lib/python2.7/site-packages/matplotlib/artist.py, line 55, in
draw_wrapper
draw(artist, renderer, *args, **kwargs)
  File /usr/lib/python2.7/site-packages/matplotlib/axes.py, line 1946, in
draw
a.draw(renderer)
  File /usr/lib/python2.7/site-packages/matplotlib/artist.py, line 55, in
draw_wrapper
draw(artist, renderer, *args, **kwargs)
  File /usr/lib/python2.7/site-packages/matplotlib/image.py, line 354, in
draw
im = self.make_image(renderer.get_image_magnification())
  File /usr/lib/python2.7/site-packages/matplotlib/image.py, line 569, in
make_image
transformed_viewLim)
  File /usr/lib/python2.7/site-packages/matplotlib/image.py, line 201, in
_get_unsampled_image
x = self.to_rgba(self._A, self._alpha)
  File /usr/lib/python2.7/site-packages/matplotlib/cm.py, line 194, in
to_rgba
x = self.cmap(x, alpha=alpha, bytes=bytes)
  File /usr/lib/python2.7/site-packages/matplotlib/colors.py, line 551,
in __call__
rgba = np.empty(shape=xa.shape+(4,), dtype=lut.dtype)
MemoryError
--
Try before you buy = See our experts in action!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-dev2___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] specgram memory problem

2012-02-03 Thread Fabrice Silva
Le vendredi 03 février 2012 à 12:11 +, David Craig a écrit :
 Hi, I am using matplotlib to produce some spectrograms for seismic
 data. I am looking at a 10 day period with a sample rate of 20sps. I
 would like to have my spectrogram to be composed of 10 minute windows
 with an overlap of 90%. However when I try and run my script I run out
 of memory. I can produce the spectrogram for a maximum of 3 days
 before an error occurs. 
 I have also tried to produce a spectrogram for each day and stick them
 together using subplot, but I then get the error given below. Anyone
 know a way around this??
 Thanks,
 David

It seems that the MemoryError does not occur when computing the
spectrogram, but when rendering it. A quick rule of a thumb tells me
that you have to display an image that is 12000x14400:
12000 frequencies, as you are using windows with 12000 samples
(no padded assumed)
14400 windows, due to the 90% overlap

Having a 4-channel for the RGBA image may throw the MemoryError.
Can you check by trying to imshow such an array ?
You can also reduce the overlap, the one you used lead to a spectrum
computation each minute...


--
Try before you buy = See our experts in action!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-dev2
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] specgram

2012-02-01 Thread David Craig
Hi, I am trying to produce a spectrogram for my data set and am having 
an issue with the color map. My data is filtered between 0.02 and 1.0Hz, 
but specgram() produces an image in the range 0 to 10Hz. Also the color 
map is not set properly. I would like to have it so the colormap ranges 
from the min and max powers obtained by specgram. Anyone know how to do 
this? My code is below.

Pxx, freqs, bins, im = plt.specgram(data, NFFT=nfft, Fs=sps, 
detrend=py.detrend_none, window=py.window_hanning, noverlap=nfft/2, 
cmap=None, xextent=None, pad_to=None, sides='default', scale_by_freq=None)
plt.ylim(0,1)
plt.colorbar()
plt.show()

thanks,
D

--
Keep Your Developer Skills Current with LearnDevNow!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-d2d
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] specgram with zeros array

2011-01-14 Thread Gus
I am using Matplotlib version 1.0.1 and I get errors if I try the following:

import matplotlib.pyplot as plt
import numpy as np
plt.specgram(np.zeros(50))

I have pasted the error output below, but hopefully it would reproduce 
in other systems. I'm not sure if this is intended behavior and was 
wondering. I came across this when I was plotting the specgram of my 
sound input, but my microphone was muted!

---
AttributeErrorTraceback (most recent call last)

/usr/local/lib/python2.6/dist-packages/matplotlib/backends/backend_wx.pyc in 
_onPaint(self, evt)
1192 drawDC = wx.PaintDC(self)
1193 if not self._isDrawn:
- 1194 self.draw(drawDC=drawDC)
1195 else:
1196 self.gui_repaint(drawDC=drawDC)

/usr/local/lib/python2.6/dist-packages/matplotlib/backends/backend_wxagg.pyc 
in draw(self, drawDC)
  57 
  58 DEBUG_MSG(draw(), 1, self)
--- 59 FigureCanvasAgg.draw(self)
  60
  61 self.bitmap = 
_convert_agg_to_wx_bitmap(self.get_renderer(), None)

/usr/local/lib/python2.6/dist-packages/matplotlib/backends/backend_agg.pyc 
in draw(self)
 392
 393 self.renderer = self.get_renderer()
-- 394 self.figure.draw(self.renderer)
 395
 396 def get_renderer(self):

/usr/local/lib/python2.6/dist-packages/matplotlib/artist.pyc in 
draw_wrapper(artist, renderer, *args, **kwargs)
  53 def draw_wrapper(artist, renderer, *args, **kwargs):
  54 before(artist, renderer)
--- 55 draw(artist, renderer, *args, **kwargs)
  56 after(artist, renderer)
  57

/usr/local/lib/python2.6/dist-packages/matplotlib/figure.pyc in 
draw(self, renderer)
 796 dsu.sort(key=itemgetter(0))
 797 for zorder, func, args in dsu:
-- 798 func(*args)
 799
 800 renderer.close_group('figure')

/usr/local/lib/python2.6/dist-packages/matplotlib/artist.pyc in 
draw_wrapper(artist, renderer, *args, **kwargs)
  53 def draw_wrapper(artist, renderer, *args, **kwargs):
  54 before(artist, renderer)
--- 55 draw(artist, renderer, *args, **kwargs)
  56 after(artist, renderer)
  57

/usr/local/lib/python2.6/dist-packages/matplotlib/axes.pyc in draw(self, 
renderer, inframe)
1944
1945 for zorder, a in dsu:
- 1946 a.draw(renderer)
1947
1948 renderer.close_group('axes')

/usr/local/lib/python2.6/dist-packages/matplotlib/artist.pyc in 
draw_wrapper(artist, renderer, *args, **kwargs)
  53 def draw_wrapper(artist, renderer, *args, **kwargs):
  54 before(artist, renderer)
--- 55 draw(artist, renderer, *args, **kwargs)
  56 after(artist, renderer)
  57

/usr/local/lib/python2.6/dist-packages/matplotlib/image.pyc in 
draw(self, renderer, *args, **kwargs)
 352 warnings.warn(Image will not be shown 
correctly with this backend.)
 353
-- 354 im = self.make_image(renderer.get_image_magnification())
 355 if im is None:
 356 return

/usr/local/lib/python2.6/dist-packages/matplotlib/image.pyc in 
make_image(self, magnification)
 567 im, xmin, ymin, dxintv, dyintv, sx, sy = \
 568 self._get_unsampled_image(self._A, [_x1, _x2, _y1, 
_y2],
-- 569   transformed_viewLim)
 570
 571 fc = self.axes.patch.get_facecolor()

/usr/local/lib/python2.6/dist-packages/matplotlib/image.pyc in 
_get_unsampled_image(self, A, image_extents, viewlim)
 199 else:
 200 if self._rgbacache is None:
-- 201 x = self.to_rgba(self._A, self._alpha)
 202 self._rgbacache = x
 203 else:

/usr/local/lib/python2.6/dist-packages/matplotlib/cm.pyc in 
to_rgba(self, x, alpha, bytes)
 191 pass
 192 x = ma.asarray(x)
-- 193 x = self.norm(x)
 194 x = self.cmap(x, alpha=alpha, bytes=bytes)
 195 return x

/usr/local/lib/python2.6/dist-packages/matplotlib/colors.pyc in 
__call__(self, value, clip)
 809 if vmin  vmax:
 810 raise ValueError(minvalue must be less than or 
equal to maxvalue)
-- 811 elif vmin==vmax:
 812 result = 0.0 * val
 813 else:

/usr/lib/python2.6/dist-packages/numpy/ma/core.pyc in __eq__(self, other)
3117 mask =  np.all([[f[n].all() for n in 
mask.dtype.names]
3118 for f in mask], axis=axis)
- 3119 check._mask = mask
3120 return check
3121 #


AttributeError: 'numpy.bool_' object has no attribute '_mask'



[Matplotlib-users] specgram: Warning: divide by zero encountered in log10

2007-03-28 Thread Niklas Saers

Hi guys,
I'm trying to make a specgram() for some wave samples that I have  
read into 'data' using pyaudiolab's read_frames() (put into wavread())


When I do

from wavread import *
from pylab import *
from statistics import *

data, datasize, samplerate, channels = wavread(myfile.wav)
specgram(data)

I get:
Warning: divide by zero encountered in log10
(array([[  2.26730611e-02,   1.51890672e-02,   7.78123371e-03, ...,
  0.e+00,   0.e+00,   0.e+00],
   [  9.11969843e-03,   2.81931459e-03,   3.13995580e-03, ...,
  0.e+00,   0.e+00,   0.e+00],
   [  7.25346631e-04,   4.83291216e-05,   2.59076878e-04, ...,
  0.e+00,   0.e+00,   0.e+00],
   ...,
   [  5.19279887e-08,   1.53242938e-07,   1.46461798e-07, ...,
  0.e+00,   0.e+00,   0.e+00],
   [  1.00769359e-07,   2.00314891e-07,   3.04618029e-07, ...,
  0.e+00,   0.e+00,   0.e+00],
   [  2.86252093e-08,   5.42052713e-07,   1.50494595e-07, ...,
  0.e+00,   0.e+00,   0.e+00]]),  
array([ 0.   ,  0.0078125,  0.015625 ,  0.0234375,  0.03125  ,

0.0390625,  0.046875 ,  0.0546875,  0.0625   ,  0.0703125,
0.078125 ,  0.0859375,  0.09375  ,  0.1015625,  0.109375 ,
0.1171875,  0.125,  0.1328125,  0.140625 ,  0.1484375,
0.15625  ,  0.1640625,  0.171875 ,  0.1796875,  0.1875   ,
0.1953125,  0.203125 ,  0.2109375,  0.21875  ,  0.2265625,
0.234375 ,  0.2421875,  0.25 ,  0.2578125,  0.265625 ,
0.2734375,  0.28125  ,  0.2890625,  0.296875 ,  0.3046875,
0.3125   ,  0.3203125,  0.328125 ,  0.3359375,  0.34375  ,
0.3515625,  0.359375 ,  0.3671875,  0.375,  0.3828125,
0.390625 ,  0.3984375,  0.40625  ,  0.4140625,  0.421875 ,
0.4296875,  0.4375   ,  0.4453125,  0.453125 ,  0.4609375,
0.46875  ,  0.4765625,  0.484375 ,  0.4921875,  0.5  ,
0.5078125,  0.515625 ,  0.5234375,  0.53125  ,  0.5390625,
0.546875 ,  0.5546875,  0.5625   ,  0.5703125,  0.578125 ,
0.5859375,  0.59375  ,  0.6015625,  0.609375 ,  0.6171875,
0.625,  0.6328125,  0.640625 ,  0.6484375,  0.65625  ,
0.6640625,  0.671875 ,  0.6796875,  0.6875   ,  0.6953125,
0.703125 ,  0.7109375,  0.71875  ,  0.7265625,  0.734375 ,
0.7421875,  0.75 ,  0.7578125,  0.765625 ,  0.7734375,
0.78125  ,  0.7890625,  0.796875 ,  0.8046875,  0.8125   ,
0.8203125,  0.828125 ,  0.8359375,  0.84375  ,  0.8515625,
0.859375 ,  0.8671875,  0.875,  0.8828125,  0.890625 ,
0.8984375,  0.90625  ,  0.9140625,  0.921875 ,  0.9296875,
0.9375   ,  0.9453125,  0.953125 ,  0.9609375,  0.96875  ,
0.9765625,  0.984375 ,  0.9921875,  1.   ]), array 
([  6.4000e+01,   1.2800e+02,   1.9200e+02, ...,
 9.7344e+04,   9.7408e+04,   9.7472e+04]),  
matplotlib.image.AxesImage instance at 0x3324fa8)


For another sample, I get a nice spectrogram. What can it be about my  
sample that would give me such an error? What is the error caused by?  
A Google on the error message provided me with nothing.


Sincerely yours

Niklas Saers-
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT  business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.phpp=sourceforgeCID=DEVDEV___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] specgram: Warning: divide by zero encountered in log10

2007-03-28 Thread John Hunter
On 3/28/07, Niklas Saers [EMAIL PROTECTED] wrote:
 Hi guys,
 I'm trying to make a specgram() for some wave samples that I have read into
 'data' using pyaudiolab's read_frames() (put into wavread())

 When I do

 from wavread import *
 from pylab import *
 from statistics import *

 data, datasize, samplerate, channels = wavread(myfile.wav)
 specgram(data)

 I get:
 Warning: divide by zero encountered in log10
 (array([[  2.26730611e-02,   1.51890672e-02,   7.78123371e-03, ...,
   0.e+00,   0.e+00,   0.e+00],
[  9.11969843e-03,   2.81931459e-03,   3.13995580e-03, ...,


So there is no traceback, just a warning?

Perhaps you could pickle or otherwise store data and write a simple
test script which doesn't depend on any external packages (eg
waveread)  and post a link to the files and we'll take a look.  My
guess is that there is some frequency that has no power and the call
to Z = 10*log10(Pxx) is failing because Pxx is zero for that
frequency.  We've seen this before, and if anyone has a suggestion on
how this case *should* be handled, I'd be happy to hear some
suggestions.

JDH

JDH

-
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT  business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.phpp=sourceforgeCID=DEVDEV
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users