On Wed, Nov 14, 2007 at 08:59:15AM -0600, John Hunter wrote:
> Glen, this looks fairly benign (the center frequency bit) so I am
> happy to add it, but could I trouble you to make similar patch the
> other spectral methods as well (eg psd, csd and cohere) for the sake
> of consistency in the API?
Relax, patch attached.
Also, I am getting an error in numerix/__init__.py when it gets imported
by a script that is run by apache. Apparently, sys.argv has length 0,
so "del a" on line 38 fails.
Thanks,
Glen
*** zipsrc/matplotlib-20071114_svn/lib/matplotlib/axes.py 2007-11-14 09:55:34.000000000 -0600
--- src/matplotlib-20071114_svn/lib/matplotlib/axes.py 2007-11-14 10:00:27.000000000 -0600
***************
*** 4888,4897 ****
return n, bins, cbook.silent_list('Patch', patches)
hist.__doc__ = cbook.dedent(hist.__doc__) % martist.kwdocd
! def psd(self, x, NFFT=256, Fs=2, detrend=mlab.detrend_none,
window=mlab.window_hanning, noverlap=0, **kwargs):
"""
! PSD(x, NFFT=256, Fs=2, detrend=mlab.detrend_none,
window=mlab.window_hanning, noverlap=0, **kwargs)
The power spectral density by Welches average periodogram method. The
--- 4888,4897 ----
return n, bins, cbook.silent_list('Patch', patches)
hist.__doc__ = cbook.dedent(hist.__doc__) % martist.kwdocd
! def psd(self, x, NFFT=256, Fs=2, Fc=0, detrend=mlab.detrend_none,
window=mlab.window_hanning, noverlap=0, **kwargs):
"""
! PSD(x, NFFT=256, Fs=2, Fc=0, detrend=mlab.detrend_none,
window=mlab.window_hanning, noverlap=0, **kwargs)
The power spectral density by Welches average periodogram method. The
***************
*** 4902,4923 ****
with a scaling to correct for power loss due to windowing. Fs is the
sampling frequency.
! NFFT is the length of the fft segment; must be a power of 2
! Fs is the sampling frequency.
! detrend - the function applied to each segment before fft-ing,
designed to remove the mean or linear trend. Unlike in matlab,
where the detrend parameter is a vector, in matplotlib is it a
function. The mlab module defines detrend_none, detrend_mean,
detrend_linear, but you can use a custom function as well.
! window - the function used to window the segments. window is a
function, unlike in matlab(TM) where it is a vector. mlab defines
window_none, window_hanning, but you can use a custom function
as well.
! noverlap gives the length of the overlap between segments.
Returns the tuple Pxx, freqs
--- 4902,4928 ----
with a scaling to correct for power loss due to windowing. Fs is the
sampling frequency.
! * NFFT is the length of the fft segment; must be a power of 2
! * Fs is the sampling frequency.
! * Fc is the center frequency of x (defaults to 0), which offsets
! the yextents of the image to reflect the frequency range used
! when a signal is acquired and then filtered and downsampled to
! baseband.
!
! * detrend - the function applied to each segment before fft-ing,
designed to remove the mean or linear trend. Unlike in matlab,
where the detrend parameter is a vector, in matplotlib is it a
function. The mlab module defines detrend_none, detrend_mean,
detrend_linear, but you can use a custom function as well.
! * window - the function used to window the segments. window is a
function, unlike in matlab(TM) where it is a vector. mlab defines
window_none, window_hanning, but you can use a custom function
as well.
! * noverlap gives the length of the overlap between segments.
Returns the tuple Pxx, freqs
***************
*** 4935,4940 ****
--- 4940,4946 ----
if not self._hold: self.cla()
pxx, freqs = mlab.psd(x, NFFT, Fs, detrend, window, noverlap)
pxx.shape = len(freqs),
+ freqs += Fc
self.plot(freqs, 10*npy.log10(pxx), **kwargs)
self.set_xlabel('Frequency')
***************
*** 4952,4961 ****
return pxx, freqs
psd.__doc__ = cbook.dedent(psd.__doc__) % martist.kwdocd
! def csd(self, x, y, NFFT=256, Fs=2, detrend=mlab.detrend_none,
window=mlab.window_hanning, noverlap=0, **kwargs):
"""
! CSD(x, y, NFFT=256, Fs=2, detrend=mlab.detrend_none,
window=window_hanning, noverlap=0, **kwargs)
The cross spectral density Pxy by Welches average periodogram method.
--- 4958,4967 ----
return pxx, freqs
psd.__doc__ = cbook.dedent(psd.__doc__) % martist.kwdocd
! def csd(self, x, y, NFFT=256, Fs=2, Fc=0, detrend=mlab.detrend_none,
window=mlab.window_hanning, noverlap=0, **kwargs):
"""
! CSD(x, y, NFFT=256, Fs=2, Fc=0, detrend=mlab.detrend_none,
window=window_hanning, noverlap=0, **kwargs)
The cross spectral density Pxy by Welches average periodogram method.
***************
*** 4981,4986 ****
--- 4987,4993 ----
pxy, freqs = mlab.csd(x, y, NFFT, Fs, detrend, window, noverlap)
pxy.shape = len(freqs),
# pxy is complex
+ freqs += Fc
self.plot(freqs, 10*npy.log10(npy.absolute(pxy)), **kwargs)
self.set_xlabel('Frequency')
***************
*** 4997,5007 ****
return pxy, freqs
csd.__doc__ = cbook.dedent(csd.__doc__) % martist.kwdocd
! def cohere(self, x, y, NFFT=256, Fs=2, detrend=mlab.detrend_none,
window=mlab.window_hanning, noverlap=0, **kwargs):
"""
! COHERE(x, y, NFFT=256, Fs=2,
! detrend = mlab.detrend_none,
window = mlab.window_hanning, noverlap=0, **kwargs)
cohere the coherence between x and y. Coherence is the normalized
--- 5004,5013 ----
return pxy, freqs
csd.__doc__ = cbook.dedent(csd.__doc__) % martist.kwdocd
! def cohere(self, x, y, NFFT=256, Fs=2, Fc=0, detrend=mlab.detrend_none,
window=mlab.window_hanning, noverlap=0, **kwargs):
"""
! COHERE(x, y, NFFT=256, Fs=2, Fc=0, detrend = mlab.detrend_none,
window = mlab.window_hanning, noverlap=0, **kwargs)
cohere the coherence between x and y. Coherence is the normalized
***************
*** 5026,5031 ****
--- 5032,5038 ----
"""
if not self._hold: self.cla()
cxy, freqs = mlab.cohere(x, y, NFFT, Fs, detrend, window, noverlap)
+ freqs += Fc
self.plot(freqs, cxy, **kwargs)
self.set_xlabel('Frequency')
***************
*** 5035,5045 ****
return cxy, freqs
cohere.__doc__ = cbook.dedent(cohere.__doc__) % martist.kwdocd
! def specgram(self, x, NFFT=256, Fs=2, detrend=mlab.detrend_none,
window=mlab.window_hanning, noverlap=128,
cmap = None, xextent=None):
"""
! SPECGRAM(x, NFFT=256, Fs=2, detrend=mlab.detrend_none,
window = mlab.window_hanning, noverlap=128,
cmap=None, xextent=None)
--- 5042,5052 ----
return cxy, freqs
cohere.__doc__ = cbook.dedent(cohere.__doc__) % martist.kwdocd
! def specgram(self, x, NFFT=256, Fs=2, Fc=0, detrend=mlab.detrend_none,
window=mlab.window_hanning, noverlap=128,
cmap = None, xextent=None):
"""
! SPECGRAM(x, NFFT=256, Fs=2, Fc=0, detrend=mlab.detrend_none,
window = mlab.window_hanning, noverlap=128,
cmap=None, xextent=None)
***************
*** 5081,5087 ****
if xextent is None: xextent = 0, npy.amax(bins)
xmin, xmax = xextent
! extent = xmin, xmax, npy.amin(freqs), npy.amax(freqs)
im = self.imshow(Z, cmap, extent=extent)
self.axis('auto')
--- 5088,5095 ----
if xextent is None: xextent = 0, npy.amax(bins)
xmin, xmax = xextent
! freqs += Fc
! extent = xmin, xmax, freqs[0], freqs[-1]
im = self.imshow(Z, cmap, extent=extent)
self.axis('auto')
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel