Re: [matplotlib-devel] Comparison of mlab.csd and Matlab's cpsd
Hi - thanks Ludwig. I don't think that a major reworking of the logic of the function is needed. Simply replacing the line you mentioned with: Pxy *= 1 / (np.abs(windowVals)**2).sum() Pxy[1:-1] *= scaling_factor if scale_by_freq: Pxy[[0,-1]] /= Fs seems to solve the 0 and NFFT/2 problem for the 'onesided' case (that is, the result is very similar to the Matlab result, patch attached) and still seems to work with twosided (because then the scaling factor is equal to 1 and it doesn't really do anything, except scale by frequency, if that is required). In the 'twosided' case, the output in matlab is fftshift-ed relative to the mlab output, but that's not crucial. What does become more apparent when I do that is that in frequency bands in which the power is rather small, the ratio discrepancies between the mlab result and the matlab result can be rather large, on the order of a factor of 2-2.5, even when the differences are tiny. Similarly, when the power is rather large, there can be non-negligible differences between the two results. Is there anything to do about that? Cheers, Ariel On Fri, Feb 5, 2010 at 11:53 PM, Ludwig Schwardt wrote: > Hi, > > > From: Ariel Rokem > > However - two elements are off by a factor of approximately 2 - the > > very first element and the very last. ... Does anyone have any idea > > why this would be the case? > > >From a quick look at the mlab code, it looks like a bug in > mlab._spectral_helper. > > The default spectrum is 'onesided' (same as for Matlab's cpsd). A > single-sided spectrum of a real signal has double the magnitude of a > double-sided spectrum, *except* at the origin (frequency index n = 0) > and Nyquist frequency (n = NFFT / 2), where it is the *same* as the > double-sided one [1]_. > > In the mlab code, all the spectral values are simply scaled by a > factor of 2 (among other factors) in this line: > ># Scale the spectrum by the norm of the window to compensate for ># windowing loss; see Bendat & Piersol Sec 11.5.2. Also include ># scaling factors for one-sided densities and dividing by the sampling ># frequency, if desired. >Pxy *= scaling_factor / (np.abs(windowVals)**2).sum() > > This should be easy to fix (although the function probably needs a > little rework). > > Regards, > Ludwig > > Quick reference from my bookshelf: > --- > .. [1] W. L. Briggs, V. E. Henson, "The DFT: An Owner's Manual for the > Discrete Fourier Transform," Section 1.3, Problem 6 (a), p. 13. > > > -- > The Planet: dedicated and managed hosting, cloud storage, colocation > Stay online with enterprise data centers and the best network in the > business > Choose flexible plans and management services without long-term contracts > Personal 24x7 support from experience hosting pros just a phone call away. > http://p.sf.net/sfu/theplanet-com > ___ > Matplotlib-devel mailing list > Matplotlib-devel@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/matplotlib-devel > -- Ariel Rokem Helen Wills Neuroscience Institute University of California, Berkeley http://argentum.ucbso.berkeley.edu/ariel one_sided_spectrum_normalization.diff Description: Binary data -- The Planet: dedicated and managed hosting, cloud storage, colocation Stay online with enterprise data centers and the best network in the business Choose flexible plans and management services without long-term contracts Personal 24x7 support from experience hosting pros just a phone call away. http://p.sf.net/sfu/theplanet-com___ Matplotlib-devel mailing list Matplotlib-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-devel
[matplotlib-devel] GNU/Hurd support
Hi, we applied 40_hurd.patch for building matplotlib on Debian GNU/Hurd. Additional attached the 10_build_fix.patch. This patch does two things. First it enables matplotlib on all Debian architectures. The second things is that it removes /usr/local from the basedir. It would be nice if you can provide a configure flag for disabling the /usr/local directory from the basedir. Then we can drop this patch. -- Benjamin Drung Ubuntu Developer (www.ubuntu.com) | Debian Maintainer (www.debian.org) --- a/setupext.py +++ b/setupext.py @@ -72,6 +72,7 @@ 'gnukfreebsd7' : ['/usr'], 'gnukfreebsd8' : ['/usr'], 'aix5' : ['/usr/local'], +'gnu0' : ['/usr'], } import sys, os, stat Description: Fixes path for build on Debian Forwarded: no Author: Sandro Tosi Last-Update: 2010-02-06 --- matplotlib-0.99.1.2.orig/setupext.py +++ matplotlib-0.99.1.2/setupext.py @@ -47,8 +47,12 @@ import subprocess basedir = { 'win32' : ['win32_static',], -'linux2' : ['/usr/local', '/usr'], -'linux' : ['/usr/local', '/usr',], +'linux2-alpha' : ['/usr'], +'linux2-hppa' : ['/usr'], +'linux2-mips' : ['/usr'], +'linux2-sparc' : ['/usr'], +'linux2' : ['/usr'], +'linux' : ['/usr',], 'cygwin' : ['/usr/local', '/usr',], '_darwin' : ['/sw/lib/freetype2', '/sw/lib/freetype219', '/usr/local', '/usr', '/sw'], @@ -63,9 +67,12 @@ basedir = { 'freebsd5' : ['/usr/local', '/usr'], 'freebsd6' : ['/usr/local', '/usr'], 'sunos5' : [os.getenv('MPLIB_BASE') or '/usr/local',], -'gnukfreebsd5' : ['/usr/local', '/usr'], -'gnukfreebsd6' : ['/usr/local', '/usr'], +'gnukfreebsd5' : ['/usr'], +'gnukfreebsd6' : ['/usr'], +'gnukfreebsd7' : ['/usr'], +'gnukfreebsd8' : ['/usr'], 'aix5' : ['/usr/local'], +'gnu0' : ['/usr'], } import sys, os, stat signature.asc Description: Dies ist ein digital signierter Nachrichtenteil -- The Planet: dedicated and managed hosting, cloud storage, colocation Stay online with enterprise data centers and the best network in the business Choose flexible plans and management services without long-term contracts Personal 24x7 support from experience hosting pros just a phone call away. http://p.sf.net/sfu/theplanet-com___ Matplotlib-devel mailing list Matplotlib-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-devel
Re: [matplotlib-devel] colorbar issue
I just committed the changes. Regards, -JJ On Wed, Jan 27, 2010 at 2:31 PM, Eric Firing wrote: > Jae-Joon Lee wrote: >> >> On Mon, Jan 25, 2010 at 7:19 PM, Jae-Joon Lee >> wrote: >>> >>> Adding a "set_ticks" method seems reasonable. >> >> A patch is attached. > > It looks like exactly what I had in mind with respect to set_ticks. I > wasn't thinking about set_ticklabels; my sense is that manually setting > ticklabels tends to be tricky and error-prone, and should be discouraged. > Maybe it should be permitted only when a FixedLocator is already in use. > >> It does some refactoring and introduces three new methods, set_ticks, >> set_ticklabels and update_ticks, on the colorbar class. >> So, now one can do >> >> imshow(np.arange(100).reshape((10,10))) >> cb = colorbar() >> cb.set_ticks([0, 40, 80]) >> >> Issuing a warning when user try to call Axis.set_ticks (or others) >> directly seems not straight forward as the axes can be created >> externally (i.e., when *cax* is provided). > > Attached patch against svn (without your patch) shows how this can be done > for the Axes methods. I would be more difficult (but not impossible) for > the Axis methods, because we need to use them. I think that handling the > Axes methods *may* be worthwhile (marginal), but handling the Axis methods > is more trouble than it is worth. > > Eric > >> >> I'll wait for response for a few more days and will commit the change. >> Regards, >> >> -JJ > > -- The Planet: dedicated and managed hosting, cloud storage, colocation Stay online with enterprise data centers and the best network in the business Choose flexible plans and management services without long-term contracts Personal 24x7 support from experience hosting pros just a phone call away. http://p.sf.net/sfu/theplanet-com ___ Matplotlib-devel mailing list Matplotlib-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-devel
Re: [matplotlib-devel] GNU/Hurd support
Benjamin Drung wrote: > Hi, > > we applied 40_hurd.patch for building matplotlib on Debian GNU/Hurd. > > Additional attached the 10_build_fix.patch. This patch does two things. > First it enables matplotlib on all Debian architectures. The second > things is that it removes /usr/local from the basedir. > > It would be nice if you can provide a configure flag for disabling > the /usr/local directory from the basedir. Then we can drop this patch. > Sorry, I dropped this the last time you brought it up. I have now added gnu0 as a platform, and added a "basedirlist" option to setup.cfg. See svn r8113 and 8115. The linux2-alpha etc platforms were already there. Eric -- The Planet: dedicated and managed hosting, cloud storage, colocation Stay online with enterprise data centers and the best network in the business Choose flexible plans and management services without long-term contracts Personal 24x7 support from experience hosting pros just a phone call away. http://p.sf.net/sfu/theplanet-com ___ Matplotlib-devel mailing list Matplotlib-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-devel