Revision: 6395
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6395&view=rev
Author: ryanmay
Date: 2008-11-11 20:34:25 +0000 (Tue, 11 Nov 2008)
Log Message:
-----------
Update cohere() in mlab and Axes method to match new psd() and csd()
parameters. Update docs.
Modified Paths:
--------------
trunk/matplotlib/CHANGELOG
trunk/matplotlib/lib/matplotlib/axes.py
trunk/matplotlib/lib/matplotlib/mlab.py
Modified: trunk/matplotlib/CHANGELOG
===================================================================
--- trunk/matplotlib/CHANGELOG 2008-11-11 20:20:27 UTC (rev 6394)
+++ trunk/matplotlib/CHANGELOG 2008-11-11 20:34:25 UTC (rev 6395)
@@ -1,15 +1,8 @@
-2008-11-11 Update the axes.csd() to match the new options added to
- mlab.csd(). Move some of the docs from axes.psd() to
- the common place in mlab. - RM
+2008-11-11 Update the psd(), csd(), and cohere() methods of Axes
+ and the csd() and cohere() functions in mlab to be in
+ sync with the changes to psd(). In fact, under the
+ hood, mlab.psd() now calls mlab.csd(). - RM
-2008-11-11 Update the mlab.csd() to match the new options added to
- mlab.psd(). Factor out the keyword argument docs so that
- they can be shared between the two functions. - RM
-
-2008-11-11 Update the axes.psd() method to reflect the new options
- available in mlab.psd. Add an example to show how the
- options change things. - RM
-
2008-11-11 Add 'pad_to' and 'sides' parameters to mlab.psd() to
allow controlling of zero padding and returning of
negative frequency components, respecitively. These are
Modified: trunk/matplotlib/lib/matplotlib/axes.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/axes.py 2008-11-11 20:20:27 UTC (rev
6394)
+++ trunk/matplotlib/lib/matplotlib/axes.py 2008-11-11 20:34:25 UTC (rev
6395)
@@ -6663,15 +6663,16 @@
return pxy, freqs
csd.__doc__ = cbook.dedent(csd.__doc__) % psd_doc_dict
- del psd_doc_dict #So that this does not become an Axes attribute
def cohere(self, x, y, NFFT=256, Fs=2, Fc=0, detrend=mlab.detrend_none,
- window=mlab.window_hanning, noverlap=0, **kwargs):
+ window=mlab.window_hanning, noverlap=0, pad_to=None,
+ sides='default', **kwargs):
"""
call signature::
cohere(x, y, NFFT=256, Fs=2, Fc=0, detrend = mlab.detrend_none,
- window = mlab.window_hanning, noverlap=0, **kwargs)
+ window = mlab.window_hanning, noverlap=0, pad_to=None,
+ sides='default', **kwargs)
cohere the coherence between *x* and *y*. Coherence is the normalized
cross spectral density:
@@ -6680,6 +6681,14 @@
C_{xy} = \\frac{|P_{xy}|^2}{P_{xx}P_{yy}}
+ %(PSD)s
+
+ *Fc*: integer
+ The center frequency of *x* (defaults to 0), which offsets
+ the x extents of the plot to reflect the frequency range used
+ when a signal is acquired and then filtered and downsampled to
+ baseband.
+
The return value is a tuple (*Cxy*, *f*), where *f* are the
frequencies of the coherence vector.
@@ -6698,10 +6707,6 @@
**Example:**
.. plot:: mpl_examples/pylab_examples/cohere_demo.py
-
- .. seealso:
- :meth:`psd`
- For a description of the optional parameters.
"""
if not self._hold: self.cla()
cxy, freqs = mlab.cohere(x, y, NFFT, Fs, detrend, window, noverlap)
@@ -6713,7 +6718,8 @@
self.grid(True)
return cxy, freqs
- cohere.__doc__ = cbook.dedent(cohere.__doc__) % martist.kwdocd
+ cohere.__doc__ = cbook.dedent(cohere.__doc__) % psd_doc_dict
+ del psd_doc_dict #So that this does not become an Axes attribute
def specgram(self, x, NFFT=256, Fs=2, Fc=0, detrend=mlab.detrend_none,
window=mlab.window_hanning, noverlap=128,
Modified: trunk/matplotlib/lib/matplotlib/mlab.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/mlab.py 2008-11-11 20:20:27 UTC (rev
6394)
+++ trunk/matplotlib/lib/matplotlib/mlab.py 2008-11-11 20:34:25 UTC (rev
6395)
@@ -313,7 +313,7 @@
Specifies which sides of the PSD to return. Default gives the
default behavior, which returns one-sided for real data and both
for complex data. 'one' forces the return of a one-sided PSD, while
- 'both' forces two-sided.
+ 'both' forces two-sided.
"""
psd.__doc__ = psd.__doc__ % kwdocd
@@ -494,13 +494,11 @@
return Pxx, freqs, t
-
-
_coh_error = """Coherence is calculated by averaging over *NFFT*
length segments. Your signal is too short for your choice of *NFFT*.
"""
def cohere(x, y, NFFT=256, Fs=2, detrend=detrend_none,
- window=window_hanning, noverlap=0):
+ window=window_hanning, noverlap=0, pad_to=None, sides='default'):
"""
The coherence between *x* and *y*. Coherence is the normalized
cross spectral density:
@@ -509,27 +507,30 @@
C_{xy} = \\frac{|P_{xy}|^2}{P_{xx}P_{yy}}
+ *x*, *y*
+ Array or sequence containing the data
+ %(PSD)s
The return value is the tuple (*Cxy*, *f*), where *f* are the
frequencies of the coherence vector.
.. seealso::
:func:`psd` and :func:`csd`:
- For information about the function arguments *NFFT*,
- *detrend*, *window*, *noverlap*, as well as the methods
- used to compute :math:`P_{xy}`, :math:`P_{xx}` and
- :math:`P_{yy}`.
+ For information about the methods used to compute
+ :math:`P_{xy}`, :math:`P_{xx}` and :math:`P_{yy}`.
"""
if len(x)<2*NFFT:
raise ValueError(_coh_error)
- Pxx, f = psd(x, NFFT, Fs, detrend, window, noverlap)
- Pyy, f = psd(y, NFFT, Fs, detrend, window, noverlap)
- Pxy, f = csd(x, y, NFFT, Fs, detrend, window, noverlap)
+ Pxx, f = psd(x, NFFT, Fs, detrend, window, noverlap, pad_to, sides)
+ Pyy, f = psd(y, NFFT, Fs, detrend, window, noverlap, pad_to, sides)
+ Pxy, f = csd(x, y, NFFT, Fs, detrend, window, noverlap, pad_to, sides)
Cxy = np.divide(np.absolute(Pxy)**2, Pxx*Pyy)
Cxy.shape = (len(f),)
return Cxy, f
+cohere.__doc__ = cohere.__doc__ % kwdocd
+
def corrcoef(*args):
"""
corrcoef(*X*) where *X* is a matrix returns a matrix of correlation
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Matplotlib-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins