@@ -4338,7 +4338,7 @@ def imshow(self, X,
43384338 alpha=1.0, vmin=None, vmax=None, origin=None, extent=None)
43394339
43404340 IMSHOW(X) - plot image X to current axes, resampling to scale to axes
4341- size (X may be numarray/Numeric array or PIL image)
4341+ size (X may be numpy array or PIL image)
43424342
43434343 IMSHOW(X, **kwargs) - Use keyword args to control image scaling,
43444344 colormapping etc. See below for details
@@ -4888,10 +4888,10 @@ def hist(self, x, bins=10, normed=0, bottom=None,
48884888 return n , bins , cbook .silent_list ('Patch' , patches )
48894889 hist .__doc__ = cbook .dedent (hist .__doc__ ) % martist .kwdocd
48904890
4891- def psd (self , x , NFFT = 256 , Fs = 2 , detrend = mlab .detrend_none ,
4891+ def psd (self , x , NFFT = 256 , Fs = 2 , Fc = 0 , detrend = mlab .detrend_none ,
48924892 window = mlab .window_hanning , noverlap = 0 , ** kwargs ):
48934893 """
4894- PSD(x, NFFT=256, Fs=2, detrend=mlab.detrend_none,
4894+ PSD(x, NFFT=256, Fs=2, Fc=0, detrend=mlab.detrend_none,
48954895 window=mlab.window_hanning, noverlap=0, **kwargs)
48964896
48974897 The power spectral density by Welches average periodogram method. The
@@ -4902,22 +4902,27 @@ def psd(self, x, NFFT=256, Fs=2, detrend=mlab.detrend_none,
49024902 with a scaling to correct for power loss due to windowing. Fs is the
49034903 sampling frequency.
49044904
4905- NFFT is the length of the fft segment; must be a power of 2
4905+ * NFFT is the length of the fft segment; must be a power of 2
49064906
4907- Fs is the sampling frequency.
4907+ * Fs is the sampling frequency.
49084908
4909- detrend - the function applied to each segment before fft-ing,
4909+ * Fc is the center frequency of x (defaults to 0), which offsets
4910+ the yextents of the image to reflect the frequency range used
4911+ when a signal is acquired and then filtered and downsampled to
4912+ baseband.
4913+
4914+ * detrend - the function applied to each segment before fft-ing,
49104915 designed to remove the mean or linear trend. Unlike in matlab,
49114916 where the detrend parameter is a vector, in matplotlib is it a
49124917 function. The mlab module defines detrend_none, detrend_mean,
49134918 detrend_linear, but you can use a custom function as well.
49144919
4915- window - the function used to window the segments. window is a
4920+ * window - the function used to window the segments. window is a
49164921 function, unlike in matlab(TM) where it is a vector. mlab defines
49174922 window_none, window_hanning, but you can use a custom function
49184923 as well.
49194924
4920- noverlap gives the length of the overlap between segments.
4925+ * noverlap gives the length of the overlap between segments.
49214926
49224927 Returns the tuple Pxx, freqs
49234928
@@ -4935,6 +4940,7 @@ def psd(self, x, NFFT=256, Fs=2, detrend=mlab.detrend_none,
49354940 if not self ._hold : self .cla ()
49364941 pxx , freqs = mlab .psd (x , NFFT , Fs , detrend , window , noverlap )
49374942 pxx .shape = len (freqs ),
4943+ freqs += Fc
49384944
49394945 self .plot (freqs , 10 * npy .log10 (pxx ), ** kwargs )
49404946 self .set_xlabel ('Frequency' )
@@ -4952,10 +4958,10 @@ def psd(self, x, NFFT=256, Fs=2, detrend=mlab.detrend_none,
49524958 return pxx , freqs
49534959 psd .__doc__ = cbook .dedent (psd .__doc__ ) % martist .kwdocd
49544960
4955- def csd (self , x , y , NFFT = 256 , Fs = 2 , detrend = mlab .detrend_none ,
4961+ def csd (self , x , y , NFFT = 256 , Fs = 2 , Fc = 0 , detrend = mlab .detrend_none ,
49564962 window = mlab .window_hanning , noverlap = 0 , ** kwargs ):
49574963 """
4958- CSD(x, y, NFFT=256, Fs=2, detrend=mlab.detrend_none,
4964+ CSD(x, y, NFFT=256, Fs=2, Fc=0, detrend=mlab.detrend_none,
49594965 window=window_hanning, noverlap=0, **kwargs)
49604966
49614967 The cross spectral density Pxy by Welches average periodogram method.
@@ -4981,6 +4987,7 @@ def csd(self, x, y, NFFT=256, Fs=2, detrend=mlab.detrend_none,
49814987 pxy , freqs = mlab .csd (x , y , NFFT , Fs , detrend , window , noverlap )
49824988 pxy .shape = len (freqs ),
49834989 # pxy is complex
4990+ freqs += Fc
49844991
49854992 self .plot (freqs , 10 * npy .log10 (npy .absolute (pxy )), ** kwargs )
49864993 self .set_xlabel ('Frequency' )
@@ -4997,11 +5004,10 @@ def csd(self, x, y, NFFT=256, Fs=2, detrend=mlab.detrend_none,
49975004 return pxy , freqs
49985005 csd .__doc__ = cbook .dedent (csd .__doc__ ) % martist .kwdocd
49995006
5000- def cohere (self , x , y , NFFT = 256 , Fs = 2 , detrend = mlab .detrend_none ,
5007+ def cohere (self , x , y , NFFT = 256 , Fs = 2 , Fc = 0 , detrend = mlab .detrend_none ,
50015008 window = mlab .window_hanning , noverlap = 0 , ** kwargs ):
50025009 """
5003- COHERE(x, y, NFFT=256, Fs=2,
5004- detrend = mlab.detrend_none,
5010+ COHERE(x, y, NFFT=256, Fs=2, Fc=0, detrend = mlab.detrend_none,
50055011 window = mlab.window_hanning, noverlap=0, **kwargs)
50065012
50075013 cohere the coherence between x and y. Coherence is the normalized
@@ -5026,6 +5032,7 @@ def cohere(self, x, y, NFFT=256, Fs=2, detrend=mlab.detrend_none,
50265032 """
50275033 if not self ._hold : self .cla ()
50285034 cxy , freqs = mlab .cohere (x , y , NFFT , Fs , detrend , window , noverlap )
5035+ freqs += Fc
50295036
50305037 self .plot (freqs , cxy , ** kwargs )
50315038 self .set_xlabel ('Frequency' )
@@ -5035,11 +5042,11 @@ def cohere(self, x, y, NFFT=256, Fs=2, detrend=mlab.detrend_none,
50355042 return cxy , freqs
50365043 cohere .__doc__ = cbook .dedent (cohere .__doc__ ) % martist .kwdocd
50375044
5038- def specgram (self , x , NFFT = 256 , Fs = 2 , detrend = mlab .detrend_none ,
5045+ def specgram (self , x , NFFT = 256 , Fs = 2 , Fc = 0 , detrend = mlab .detrend_none ,
50395046 window = mlab .window_hanning , noverlap = 128 ,
50405047 cmap = None , xextent = None ):
50415048 """
5042- SPECGRAM(x, NFFT=256, Fs=2, detrend=mlab.detrend_none,
5049+ SPECGRAM(x, NFFT=256, Fs=2, Fc=0, detrend=mlab.detrend_none,
50435050 window = mlab.window_hanning, noverlap=128,
50445051 cmap=None, xextent=None)
50455052
@@ -5081,7 +5088,8 @@ def specgram(self, x, NFFT=256, Fs=2, detrend=mlab.detrend_none,
50815088
50825089 if xextent is None : xextent = 0 , npy .amax (bins )
50835090 xmin , xmax = xextent
5084- extent = xmin , xmax , npy .amin (freqs ), npy .amax (freqs )
5091+ freqs += Fc
5092+ extent = xmin , xmax , freqs [0 ], freqs [- 1 ]
50855093 im = self .imshow (Z , cmap , extent = extent )
50865094 self .axis ('auto' )
50875095
0 commit comments