@@ -4413,7 +4413,7 @@ def imshow(self, I,
44134413 origin=None, extent=None)
44144414
44154415 IMSHOW(I) - plot image I to current axes, resampling to scale to axes
4416- size (I may be numarray/Numeric array or PIL image)
4416+ size (I may be numpy array or PIL image)
44174417
44184418 IMSHOW(I, X, Y) - plot image I to current axes, with
44194419 nonuniform X and Y axes. (I, X and Y may be
@@ -4988,10 +4988,10 @@ def hist(self, x, bins=10, normed=0, bottom=None,
49884988 return n , bins , cbook .silent_list ('Patch' , patches )
49894989 hist .__doc__ = cbook .dedent (hist .__doc__ ) % martist .kwdocd
49904990
4991- def psd (self , x , NFFT = 256 , Fs = 2 , detrend = mlab .detrend_none ,
4991+ def psd (self , x , NFFT = 256 , Fs = 2 , Fc = 0 , detrend = mlab .detrend_none ,
49924992 window = mlab .window_hanning , noverlap = 0 , ** kwargs ):
49934993 """
4994- PSD(x, NFFT=256, Fs=2, detrend=mlab.detrend_none,
4994+ PSD(x, NFFT=256, Fs=2, Fc=0, detrend=mlab.detrend_none,
49954995 window=mlab.window_hanning, noverlap=0, **kwargs)
49964996
49974997 The power spectral density by Welches average periodogram method. The
@@ -5002,22 +5002,27 @@ def psd(self, x, NFFT=256, Fs=2, detrend=mlab.detrend_none,
50025002 with a scaling to correct for power loss due to windowing. Fs is the
50035003 sampling frequency.
50045004
5005- NFFT is the length of the fft segment; must be a power of 2
5005+ * NFFT is the length of the fft segment; must be a power of 2
50065006
5007- Fs is the sampling frequency.
5007+ * Fs is the sampling frequency.
50085008
5009- detrend - the function applied to each segment before fft-ing,
5009+ * Fc is the center frequency of x (defaults to 0), which offsets
5010+ the yextents of the image to reflect the frequency range used
5011+ when a signal is acquired and then filtered and downsampled to
5012+ baseband.
5013+
5014+ * detrend - the function applied to each segment before fft-ing,
50105015 designed to remove the mean or linear trend. Unlike in matlab,
50115016 where the detrend parameter is a vector, in matplotlib is it a
50125017 function. The mlab module defines detrend_none, detrend_mean,
50135018 detrend_linear, but you can use a custom function as well.
50145019
5015- window - the function used to window the segments. window is a
5020+ * window - the function used to window the segments. window is a
50165021 function, unlike in matlab(TM) where it is a vector. mlab defines
50175022 window_none, window_hanning, but you can use a custom function
50185023 as well.
50195024
5020- noverlap gives the length of the overlap between segments.
5025+ * noverlap gives the length of the overlap between segments.
50215026
50225027 Returns the tuple Pxx, freqs
50235028
@@ -5035,6 +5040,7 @@ def psd(self, x, NFFT=256, Fs=2, detrend=mlab.detrend_none,
50355040 if not self ._hold : self .cla ()
50365041 pxx , freqs = mlab .psd (x , NFFT , Fs , detrend , window , noverlap )
50375042 pxx .shape = len (freqs ),
5043+ freqs += Fc
50385044
50395045 self .plot (freqs , 10 * npy .log10 (pxx ), ** kwargs )
50405046 self .set_xlabel ('Frequency' )
@@ -5052,10 +5058,10 @@ def psd(self, x, NFFT=256, Fs=2, detrend=mlab.detrend_none,
50525058 return pxx , freqs
50535059 psd .__doc__ = cbook .dedent (psd .__doc__ ) % martist .kwdocd
50545060
5055- def csd (self , x , y , NFFT = 256 , Fs = 2 , detrend = mlab .detrend_none ,
5061+ def csd (self , x , y , NFFT = 256 , Fs = 2 , Fc = 0 , detrend = mlab .detrend_none ,
50565062 window = mlab .window_hanning , noverlap = 0 , ** kwargs ):
50575063 """
5058- CSD(x, y, NFFT=256, Fs=2, detrend=mlab.detrend_none,
5064+ CSD(x, y, NFFT=256, Fs=2, Fc=0, detrend=mlab.detrend_none,
50595065 window=window_hanning, noverlap=0, **kwargs)
50605066
50615067 The cross spectral density Pxy by Welches average periodogram method.
@@ -5081,6 +5087,7 @@ def csd(self, x, y, NFFT=256, Fs=2, detrend=mlab.detrend_none,
50815087 pxy , freqs = mlab .csd (x , y , NFFT , Fs , detrend , window , noverlap )
50825088 pxy .shape = len (freqs ),
50835089 # pxy is complex
5090+ freqs += Fc
50845091
50855092 self .plot (freqs , 10 * npy .log10 (npy .absolute (pxy )), ** kwargs )
50865093 self .set_xlabel ('Frequency' )
@@ -5097,11 +5104,10 @@ def csd(self, x, y, NFFT=256, Fs=2, detrend=mlab.detrend_none,
50975104 return pxy , freqs
50985105 csd .__doc__ = cbook .dedent (csd .__doc__ ) % martist .kwdocd
50995106
5100- def cohere (self , x , y , NFFT = 256 , Fs = 2 , detrend = mlab .detrend_none ,
5107+ def cohere (self , x , y , NFFT = 256 , Fs = 2 , Fc = 0 , detrend = mlab .detrend_none ,
51015108 window = mlab .window_hanning , noverlap = 0 , ** kwargs ):
51025109 """
5103- COHERE(x, y, NFFT=256, Fs=2,
5104- detrend = mlab.detrend_none,
5110+ COHERE(x, y, NFFT=256, Fs=2, Fc=0, detrend = mlab.detrend_none,
51055111 window = mlab.window_hanning, noverlap=0, **kwargs)
51065112
51075113 cohere the coherence between x and y. Coherence is the normalized
@@ -5126,6 +5132,7 @@ def cohere(self, x, y, NFFT=256, Fs=2, detrend=mlab.detrend_none,
51265132 """
51275133 if not self ._hold : self .cla ()
51285134 cxy , freqs = mlab .cohere (x , y , NFFT , Fs , detrend , window , noverlap )
5135+ freqs += Fc
51295136
51305137 self .plot (freqs , cxy , ** kwargs )
51315138 self .set_xlabel ('Frequency' )
@@ -5135,11 +5142,11 @@ def cohere(self, x, y, NFFT=256, Fs=2, detrend=mlab.detrend_none,
51355142 return cxy , freqs
51365143 cohere .__doc__ = cbook .dedent (cohere .__doc__ ) % martist .kwdocd
51375144
5138- def specgram (self , x , NFFT = 256 , Fs = 2 , detrend = mlab .detrend_none ,
5145+ def specgram (self , x , NFFT = 256 , Fs = 2 , Fc = 0 , detrend = mlab .detrend_none ,
51395146 window = mlab .window_hanning , noverlap = 128 ,
51405147 cmap = None , xextent = None ):
51415148 """
5142- SPECGRAM(x, NFFT=256, Fs=2, detrend=mlab.detrend_none,
5149+ SPECGRAM(x, NFFT=256, Fs=2, Fc=0, detrend=mlab.detrend_none,
51435150 window = mlab.window_hanning, noverlap=128,
51445151 cmap=None, xextent=None)
51455152
@@ -5181,7 +5188,8 @@ def specgram(self, x, NFFT=256, Fs=2, detrend=mlab.detrend_none,
51815188
51825189 if xextent is None : xextent = 0 , npy .amax (bins )
51835190 xmin , xmax = xextent
5184- extent = xmin , xmax , npy .amin (freqs ), npy .amax (freqs )
5191+ freqs += Fc
5192+ extent = xmin , xmax , freqs [0 ], freqs [- 1 ]
51855193 im = self .imshow (Z , cmap , extent = extent )
51865194 self .axis ('auto' )
51875195
0 commit comments