From: David C. <dcd...@gm...> - 2012-01-30 13:34:34
|
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 On Mon, Jan 30, 2012 at 12:13 PM, Fabrice Silva <si...@lm...>wrote: > Le lundi 30 janvier 2012 à 11:45 +0000, David Craig a écrit : > > Hi I have some data for a 24hr period with a sample rate of 100 > > samples/second. I want to create a power spectrum using matplotlibs > > function psd. I want it to have 10 minute windows with a 50% overlap, > > but cant seem to get the syntax right. My code is as follows: > > > > NFFT = len(data) > > Fs = 100 > > window=np.hanning(Fs*60*10) > > noverlap = window*0.5 > > plt.psd(data, NFFT, Fs, window, noverlap ) > > > > anyone kow how to do this properly??? > > Be careful to use a suitable value for NFFT. It must be linked to your > windows size, not the total data length, and you would rather use a > power of 2 for efficience. Do not use it to increase the frequency > resolution (use pad_to instead). > > Fs = 100 > NFFT = Fs*60*10 > Pxx, f = plt.psd(data, NFFT, Fs, window=np.hanning(NFFT), NFFT/2) > > -- > 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 > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > |