Le lundi 30 janvier 2012 à 13:34 +0000, David Craig a écrit :
> Hi, thanks for that. I've made the following changes:
> 
> NFFT = 100*60*10        # Linked to window size
> Fs = stream[0].stats.sampling_rate
> win = np.hanning(NFFT)
> overlap = NFFT/2
> power, freq = plt.psd(data, NFFT, Fs, win, overlap)
> 
> but it returns the following error:
> 
> Traceback (most recent call last):
>   File "/home/davcra/Desktop/python_scripts/welchPSD.py", line 20, in <module>
>     power, freq = plt.psd(data, NFFT, Fs, win, overlap)
>   File "/usr/lib/python2.7/site-packages/matplotlib/pyplot.py", line 2322, in 
> psd
>     ret = ax.psd(x, NFFT, Fs, Fc, detrend, window, noverlap, pad_to, sides, 
> scale_by_freq, **kwargs)
>   File "/usr/lib/python2.7/site-packages/matplotlib/axes.py", line 7876, in 
> psd
>     sides, scale_by_freq)
>   File "/usr/lib/python2.7/site-packages/matplotlib/mlab.py", line 389, in psd
>     scale_by_freq)
>   File "/usr/lib/python2.7/site-packages/matplotlib/mlab.py", line 419, in csd
>     noverlap, pad_to, sides, scale_by_freq)
>   File "/usr/lib/python2.7/site-packages/matplotlib/mlab.py", line 268, in 
> _spectral_helper
>     thisX = windowVals * detrend(thisX)
> TypeError: 'int' object is not callable

Please be careful with argument order. Expected arguments for psd are
- the data array
- the NFFT value
- the sampling frequency
- the detrend callable (*missing in your example*)
- and then the overlap number

You should either specify on of the detrend pylab functions
(detrend_none, detrend_mean, and detrend_linear) or use keyword
arguments as I did in the example. 

-- 
Fabrice Silva


------------------------------------------------------------------------------
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

Reply via email to