1123 lines (1061 with data), 91.6 kB
@header@
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="heading">
<tr bgcolor="#7799ee">
<td valign=bottom> <br>
<font color="#ffffff" face="helvetica, arial"> <br><big><big><strong><a href="matplotlib.html"><font color="#ffffff">matplotlib</font></a>.mlab</strong></big></big></font></td
><td align=right valign=bottom
><font color="#ffffff" face="helvetica, arial"><a href=".">index</a><br><a href="file:/home/jdhunter/dev/lib64/python2.5/site-packages/matplotlib/mlab.py">/home/jdhunter/dev/lib64/python2.5/site-packages/matplotlib/mlab.py</a></font></td></tr></table>
<p><tt>Numerical python functions written for compatability with matlab(TM)<br>
commands with the same names.<br>
<br>
Matlab(TM) compatible functions:<br>
<br>
* cohere - Coherence (normalized cross spectral density)<br>
<br>
* csd - Cross spectral density uing Welch's average periodogram<br>
<br>
* detrend -- Remove the mean or best fit line from an array<br>
<br>
* find - Return the indices where some condition is true;<br>
numpy.nonzero is similar but more general.<br>
<br>
* griddata - interpolate irregularly distributed data to a<br>
regular grid.<br>
<br>
* prctile - find the percentiles of a sequence<br>
<br>
* prepca - Principal Component Analysis<br>
<br>
* psd - Power spectral density uing Welch's average periodogram<br>
<br>
* rk4 - A 4th order runge kutta integrator for 1D or ND systems<br>
<br>
<br>
Functions that don't exist in matlab(TM), but are useful anyway:<br>
<br>
* cohere_pairs - Coherence over all pairs. This is not a matlab<br>
function, but we compute coherence a lot in my lab, and we<br>
compute it for a lot of pairs. This function is optimized to do<br>
this efficiently by caching the direct FFTs.<br>
<br>
= record array helper functions =<br>
* rec2txt : pretty print a record array<br>
* rec2csv : store record array in CSV file<br>
* csv2rec : import record array from CSV file with type inspection<br>
* rec_append_fields: adds field(s)/array(s) to record array<br>
* rec_drop_fields : drop fields from record array<br>
* rec_join : join two record arrays on sequence of fields<br>
* rec_groupby : summarize data by groups (similar to SQL GROUP BY)<br>
* rec_summarize : helper code to filter rec array fields into new fields<br>
<br>
For the rec viewer functions(e rec2csv), there are a bunch of Format<br>
objects you can pass into the functions that will do things like color<br>
negative values red, set percent formatting and scaling, etc.<br>
<br>
<br>
Example usage:<br>
<br>
r = <a href="#-csv2rec">csv2rec</a>('somefile.csv', checkrows=0)<br>
<br>
formatd = dict(<br>
weight = <a href="#FormatFloat">FormatFloat</a>(2),<br>
change = <a href="#FormatPercent">FormatPercent</a>(2),<br>
cost = <a href="#FormatThousands">FormatThousands</a>(2),<br>
)<br>
<br>
<br>
rec2excel(r, 'test.xls', formatd=formatd)<br>
<a href="#-rec2csv">rec2csv</a>(r, 'test.csv', formatd=formatd)<br>
scroll = rec2gtk(r, formatd=formatd)<br>
<br>
win = gtk.Window()<br>
win.set_size_request(600,800)<br>
win.add(scroll)<br>
win.show_all()<br>
gtk.main()</tt></p>
<p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#aa55cc">
<td colspan=3 valign=bottom> <br>
<font color="#fffff" face="helvetica, arial"><big><strong>Modules</strong></big></font></td></tr>
<tr><td bgcolor="#aa55cc"><tt> </tt></td><td> </td>
<td width="100%"><table width="100%" summary="list"><tr><td width="25%" valign=top><a href="matplotlib.cbook.html">matplotlib.cbook</a><br>
<a href="copy.html">copy</a><br>
<a href="csv.html">csv</a><br>
</td><td width="25%" valign=top><a href="math.html">math</a><br>
<a href="numpy.html">numpy</a><br>
<a href="matplotlib.nxutils.html">matplotlib.nxutils</a><br>
</td><td width="25%" valign=top><a href="operator.html">operator</a><br>
<a href="os.html">os</a><br>
<a href="warnings.html">warnings</a><br>
</td><td width="25%" valign=top></td></tr></table></td></tr></table><p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ee77aa">
<td colspan=3 valign=bottom> <br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Classes</strong></big></font></td></tr>
<tr><td bgcolor="#ee77aa"><tt> </tt></td><td> </td>
<td width="100%"><dl>
<dt><font face="helvetica, arial"><a href="matplotlib.mlab.html#FIFOBuffer">FIFOBuffer</a>
</font></dt><dt><font face="helvetica, arial"><a href="matplotlib.mlab.html#FormatObj">FormatObj</a>
</font></dt><dd>
<dl>
<dt><font face="helvetica, arial"><a href="matplotlib.mlab.html#FormatBool">FormatBool</a>
</font></dt><dt><font face="helvetica, arial"><a href="matplotlib.mlab.html#FormatDate">FormatDate</a>
</font></dt><dd>
<dl>
<dt><font face="helvetica, arial"><a href="matplotlib.mlab.html#FormatDatetime">FormatDatetime</a>
</font></dt></dl>
</dd>
<dt><font face="helvetica, arial"><a href="matplotlib.mlab.html#FormatFormatStr">FormatFormatStr</a>
</font></dt><dd>
<dl>
<dt><font face="helvetica, arial"><a href="matplotlib.mlab.html#FormatFloat">FormatFloat</a>
</font></dt><dd>
<dl>
<dt><font face="helvetica, arial"><a href="matplotlib.mlab.html#FormatMillions">FormatMillions</a>
</font></dt><dt><font face="helvetica, arial"><a href="matplotlib.mlab.html#FormatPercent">FormatPercent</a>
</font></dt><dt><font face="helvetica, arial"><a href="matplotlib.mlab.html#FormatThousands">FormatThousands</a>
</font></dt></dl>
</dd>
</dl>
</dd>
<dt><font face="helvetica, arial"><a href="matplotlib.mlab.html#FormatInt">FormatInt</a>
</font></dt><dt><font face="helvetica, arial"><a href="matplotlib.mlab.html#FormatString">FormatString</a>
</font></dt></dl>
</dd>
</dl>
<p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ffc8d8">
<td colspan=3 valign=bottom> <br>
<font color="#000000" face="helvetica, arial"><a name="FIFOBuffer">class <strong>FIFOBuffer</strong></a></font></td></tr>
<tr bgcolor="#ffc8d8"><td rowspan=2><tt> </tt></td>
<td colspan=2><tt>A FIFO queue to hold incoming x, y data in a rotating buffer using<br>
numpy arrays under the hood. It is assumed that you will call<br>
asarrays much less frequently than you add data to the queue --<br>
otherwise another data structure will be faster<br>
<br>
This can be used to support plots where data is added from a real<br>
time feed and the plot object wants grab data from the buffer and<br>
plot it to screen less freqeuently than the incoming<br>
<br>
If you set the dataLim attr to a matplotlib BBox (eg ax.dataLim),<br>
the dataLim will be updated as new data come in<br>
<br>
TODI: add a grow method that will extend nmax<br>
<br>
mlab seems like the wrong place for this class.<br> </tt></td></tr>
<tr><td> </td>
<td width="100%">Methods defined here:<br>
<dl><dt><a name="FIFOBuffer-__init__"><strong>__init__</strong></a>(self, nmax)</dt><dd><tt>buffer up to nmax points</tt></dd></dl>
<dl><dt><a name="FIFOBuffer-add"><strong>add</strong></a>(self, x, y)</dt><dd><tt>add scalar x and y to the queue</tt></dd></dl>
<dl><dt><a name="FIFOBuffer-asarrays"><strong>asarrays</strong></a>(self)</dt><dd><tt>return x and y as arrays; their length will be the len of data<br>
added or nmax</tt></dd></dl>
<dl><dt><a name="FIFOBuffer-last"><strong>last</strong></a>(self)</dt><dd><tt>get the last x, y or None, None if no data set</tt></dd></dl>
<dl><dt><a name="FIFOBuffer-register"><strong>register</strong></a>(self, func, N)</dt><dd><tt>call func everytime N events are passed; func signature is func(fifo)</tt></dd></dl>
<dl><dt><a name="FIFOBuffer-update_datalim_to_current"><strong>update_datalim_to_current</strong></a>(self)</dt><dd><tt>update the datalim in the current data in the fifo</tt></dd></dl>
</td></tr></table> <p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ffc8d8">
<td colspan=3 valign=bottom> <br>
<font color="#000000" face="helvetica, arial"><a name="FormatBool">class <strong>FormatBool</strong></a>(<a href="matplotlib.mlab.html#FormatObj">FormatObj</a>)</font></td></tr>
<tr><td bgcolor="#ffc8d8"><tt> </tt></td><td> </td>
<td width="100%">Methods defined here:<br>
<dl><dt><a name="FormatBool-fromstr"><strong>fromstr</strong></a>(self, s)</dt></dl>
<dl><dt><a name="FormatBool-toval"><strong>toval</strong></a>(self, x)</dt></dl>
<hr>
Methods inherited from <a href="matplotlib.mlab.html#FormatObj">FormatObj</a>:<br>
<dl><dt><a name="FormatBool-tostr"><strong>tostr</strong></a>(self, x)</dt></dl>
</td></tr></table> <p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ffc8d8">
<td colspan=3 valign=bottom> <br>
<font color="#000000" face="helvetica, arial"><a name="FormatDate">class <strong>FormatDate</strong></a>(<a href="matplotlib.mlab.html#FormatObj">FormatObj</a>)</font></td></tr>
<tr><td bgcolor="#ffc8d8"><tt> </tt></td><td> </td>
<td width="100%">Methods defined here:<br>
<dl><dt><a name="FormatDate-__init__"><strong>__init__</strong></a>(self, fmt)</dt></dl>
<dl><dt><a name="FormatDate-fromstr"><strong>fromstr</strong></a>(self, x)</dt></dl>
<dl><dt><a name="FormatDate-toval"><strong>toval</strong></a>(self, x)</dt></dl>
<hr>
Methods inherited from <a href="matplotlib.mlab.html#FormatObj">FormatObj</a>:<br>
<dl><dt><a name="FormatDate-tostr"><strong>tostr</strong></a>(self, x)</dt></dl>
</td></tr></table> <p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ffc8d8">
<td colspan=3 valign=bottom> <br>
<font color="#000000" face="helvetica, arial"><a name="FormatDatetime">class <strong>FormatDatetime</strong></a>(<a href="matplotlib.mlab.html#FormatDate">FormatDate</a>)</font></td></tr>
<tr><td bgcolor="#ffc8d8"><tt> </tt></td><td> </td>
<td width="100%"><dl><dt>Method resolution order:</dt>
<dd><a href="matplotlib.mlab.html#FormatDatetime">FormatDatetime</a></dd>
<dd><a href="matplotlib.mlab.html#FormatDate">FormatDate</a></dd>
<dd><a href="matplotlib.mlab.html#FormatObj">FormatObj</a></dd>
</dl>
<hr>
Methods defined here:<br>
<dl><dt><a name="FormatDatetime-__init__"><strong>__init__</strong></a>(self, fmt<font color="#909090">='%Y-%m-%d %H:%M:%S'</font>)</dt></dl>
<dl><dt><a name="FormatDatetime-fromstr"><strong>fromstr</strong></a>(self, x)</dt></dl>
<hr>
Methods inherited from <a href="matplotlib.mlab.html#FormatDate">FormatDate</a>:<br>
<dl><dt><a name="FormatDatetime-toval"><strong>toval</strong></a>(self, x)</dt></dl>
<hr>
Methods inherited from <a href="matplotlib.mlab.html#FormatObj">FormatObj</a>:<br>
<dl><dt><a name="FormatDatetime-tostr"><strong>tostr</strong></a>(self, x)</dt></dl>
</td></tr></table> <p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ffc8d8">
<td colspan=3 valign=bottom> <br>
<font color="#000000" face="helvetica, arial"><a name="FormatFloat">class <strong>FormatFloat</strong></a>(<a href="matplotlib.mlab.html#FormatFormatStr">FormatFormatStr</a>)</font></td></tr>
<tr><td bgcolor="#ffc8d8"><tt> </tt></td><td> </td>
<td width="100%"><dl><dt>Method resolution order:</dt>
<dd><a href="matplotlib.mlab.html#FormatFloat">FormatFloat</a></dd>
<dd><a href="matplotlib.mlab.html#FormatFormatStr">FormatFormatStr</a></dd>
<dd><a href="matplotlib.mlab.html#FormatObj">FormatObj</a></dd>
</dl>
<hr>
Methods defined here:<br>
<dl><dt><a name="FormatFloat-__init__"><strong>__init__</strong></a>(self, precision<font color="#909090">=4</font>, scale<font color="#909090">=1.0</font>)</dt></dl>
<dl><dt><a name="FormatFloat-fromstr"><strong>fromstr</strong></a>(self, s)</dt></dl>
<dl><dt><a name="FormatFloat-toval"><strong>toval</strong></a>(self, x)</dt></dl>
<hr>
Methods inherited from <a href="matplotlib.mlab.html#FormatFormatStr">FormatFormatStr</a>:<br>
<dl><dt><a name="FormatFloat-tostr"><strong>tostr</strong></a>(self, x)</dt></dl>
</td></tr></table> <p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ffc8d8">
<td colspan=3 valign=bottom> <br>
<font color="#000000" face="helvetica, arial"><a name="FormatFormatStr">class <strong>FormatFormatStr</strong></a>(<a href="matplotlib.mlab.html#FormatObj">FormatObj</a>)</font></td></tr>
<tr><td bgcolor="#ffc8d8"><tt> </tt></td><td> </td>
<td width="100%">Methods defined here:<br>
<dl><dt><a name="FormatFormatStr-__init__"><strong>__init__</strong></a>(self, fmt)</dt></dl>
<dl><dt><a name="FormatFormatStr-tostr"><strong>tostr</strong></a>(self, x)</dt></dl>
<hr>
Methods inherited from <a href="matplotlib.mlab.html#FormatObj">FormatObj</a>:<br>
<dl><dt><a name="FormatFormatStr-fromstr"><strong>fromstr</strong></a>(self, s)</dt></dl>
<dl><dt><a name="FormatFormatStr-toval"><strong>toval</strong></a>(self, x)</dt></dl>
</td></tr></table> <p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ffc8d8">
<td colspan=3 valign=bottom> <br>
<font color="#000000" face="helvetica, arial"><a name="FormatInt">class <strong>FormatInt</strong></a>(<a href="matplotlib.mlab.html#FormatObj">FormatObj</a>)</font></td></tr>
<tr><td bgcolor="#ffc8d8"><tt> </tt></td><td> </td>
<td width="100%">Methods defined here:<br>
<dl><dt><a name="FormatInt-fromstr"><strong>fromstr</strong></a>(self, s)</dt></dl>
<dl><dt><a name="FormatInt-toval"><strong>toval</strong></a>(self, x)</dt></dl>
<hr>
Methods inherited from <a href="matplotlib.mlab.html#FormatObj">FormatObj</a>:<br>
<dl><dt><a name="FormatInt-tostr"><strong>tostr</strong></a>(self, x)</dt></dl>
</td></tr></table> <p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ffc8d8">
<td colspan=3 valign=bottom> <br>
<font color="#000000" face="helvetica, arial"><a name="FormatMillions">class <strong>FormatMillions</strong></a>(<a href="matplotlib.mlab.html#FormatFloat">FormatFloat</a>)</font></td></tr>
<tr><td bgcolor="#ffc8d8"><tt> </tt></td><td> </td>
<td width="100%"><dl><dt>Method resolution order:</dt>
<dd><a href="matplotlib.mlab.html#FormatMillions">FormatMillions</a></dd>
<dd><a href="matplotlib.mlab.html#FormatFloat">FormatFloat</a></dd>
<dd><a href="matplotlib.mlab.html#FormatFormatStr">FormatFormatStr</a></dd>
<dd><a href="matplotlib.mlab.html#FormatObj">FormatObj</a></dd>
</dl>
<hr>
Methods defined here:<br>
<dl><dt><a name="FormatMillions-__init__"><strong>__init__</strong></a>(self, precision<font color="#909090">=4</font>)</dt></dl>
<hr>
Methods inherited from <a href="matplotlib.mlab.html#FormatFloat">FormatFloat</a>:<br>
<dl><dt><a name="FormatMillions-fromstr"><strong>fromstr</strong></a>(self, s)</dt></dl>
<dl><dt><a name="FormatMillions-toval"><strong>toval</strong></a>(self, x)</dt></dl>
<hr>
Methods inherited from <a href="matplotlib.mlab.html#FormatFormatStr">FormatFormatStr</a>:<br>
<dl><dt><a name="FormatMillions-tostr"><strong>tostr</strong></a>(self, x)</dt></dl>
</td></tr></table> <p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ffc8d8">
<td colspan=3 valign=bottom> <br>
<font color="#000000" face="helvetica, arial"><a name="FormatObj">class <strong>FormatObj</strong></a></font></td></tr>
<tr bgcolor="#ffc8d8"><td rowspan=2><tt> </tt></td>
<td colspan=2><tt># a series of classes for describing the format intentions of various rec views<br> </tt></td></tr>
<tr><td> </td>
<td width="100%">Methods defined here:<br>
<dl><dt><a name="FormatObj-fromstr"><strong>fromstr</strong></a>(self, s)</dt></dl>
<dl><dt><a name="FormatObj-tostr"><strong>tostr</strong></a>(self, x)</dt></dl>
<dl><dt><a name="FormatObj-toval"><strong>toval</strong></a>(self, x)</dt></dl>
</td></tr></table> <p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ffc8d8">
<td colspan=3 valign=bottom> <br>
<font color="#000000" face="helvetica, arial"><a name="FormatPercent">class <strong>FormatPercent</strong></a>(<a href="matplotlib.mlab.html#FormatFloat">FormatFloat</a>)</font></td></tr>
<tr><td bgcolor="#ffc8d8"><tt> </tt></td><td> </td>
<td width="100%"><dl><dt>Method resolution order:</dt>
<dd><a href="matplotlib.mlab.html#FormatPercent">FormatPercent</a></dd>
<dd><a href="matplotlib.mlab.html#FormatFloat">FormatFloat</a></dd>
<dd><a href="matplotlib.mlab.html#FormatFormatStr">FormatFormatStr</a></dd>
<dd><a href="matplotlib.mlab.html#FormatObj">FormatObj</a></dd>
</dl>
<hr>
Methods defined here:<br>
<dl><dt><a name="FormatPercent-__init__"><strong>__init__</strong></a>(self, precision<font color="#909090">=4</font>)</dt></dl>
<hr>
Methods inherited from <a href="matplotlib.mlab.html#FormatFloat">FormatFloat</a>:<br>
<dl><dt><a name="FormatPercent-fromstr"><strong>fromstr</strong></a>(self, s)</dt></dl>
<dl><dt><a name="FormatPercent-toval"><strong>toval</strong></a>(self, x)</dt></dl>
<hr>
Methods inherited from <a href="matplotlib.mlab.html#FormatFormatStr">FormatFormatStr</a>:<br>
<dl><dt><a name="FormatPercent-tostr"><strong>tostr</strong></a>(self, x)</dt></dl>
</td></tr></table> <p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ffc8d8">
<td colspan=3 valign=bottom> <br>
<font color="#000000" face="helvetica, arial"><a name="FormatString">class <strong>FormatString</strong></a>(<a href="matplotlib.mlab.html#FormatObj">FormatObj</a>)</font></td></tr>
<tr><td bgcolor="#ffc8d8"><tt> </tt></td><td> </td>
<td width="100%">Methods defined here:<br>
<dl><dt><a name="FormatString-tostr"><strong>tostr</strong></a>(self, x)</dt></dl>
<hr>
Methods inherited from <a href="matplotlib.mlab.html#FormatObj">FormatObj</a>:<br>
<dl><dt><a name="FormatString-fromstr"><strong>fromstr</strong></a>(self, s)</dt></dl>
<dl><dt><a name="FormatString-toval"><strong>toval</strong></a>(self, x)</dt></dl>
</td></tr></table> <p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ffc8d8">
<td colspan=3 valign=bottom> <br>
<font color="#000000" face="helvetica, arial"><a name="FormatThousands">class <strong>FormatThousands</strong></a>(<a href="matplotlib.mlab.html#FormatFloat">FormatFloat</a>)</font></td></tr>
<tr><td bgcolor="#ffc8d8"><tt> </tt></td><td> </td>
<td width="100%"><dl><dt>Method resolution order:</dt>
<dd><a href="matplotlib.mlab.html#FormatThousands">FormatThousands</a></dd>
<dd><a href="matplotlib.mlab.html#FormatFloat">FormatFloat</a></dd>
<dd><a href="matplotlib.mlab.html#FormatFormatStr">FormatFormatStr</a></dd>
<dd><a href="matplotlib.mlab.html#FormatObj">FormatObj</a></dd>
</dl>
<hr>
Methods defined here:<br>
<dl><dt><a name="FormatThousands-__init__"><strong>__init__</strong></a>(self, precision<font color="#909090">=4</font>)</dt></dl>
<hr>
Methods inherited from <a href="matplotlib.mlab.html#FormatFloat">FormatFloat</a>:<br>
<dl><dt><a name="FormatThousands-fromstr"><strong>fromstr</strong></a>(self, s)</dt></dl>
<dl><dt><a name="FormatThousands-toval"><strong>toval</strong></a>(self, x)</dt></dl>
<hr>
Methods inherited from <a href="matplotlib.mlab.html#FormatFormatStr">FormatFormatStr</a>:<br>
<dl><dt><a name="FormatThousands-tostr"><strong>tostr</strong></a>(self, x)</dt></dl>
</td></tr></table></td></tr></table><p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#eeaa77">
<td colspan=3 valign=bottom> <br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Functions</strong></big></font></td></tr>
<tr><td bgcolor="#eeaa77"><tt> </tt></td><td> </td>
<td width="100%"><dl><dt><a name="-amap"><strong>amap</strong></a>(fn, *args)</dt><dd><tt><a href="#-amap">amap</a>(function, sequence[, sequence, ...]) -> array.<br>
<br>
Works like map(), but it returns an array. This is just a convenient<br>
shorthand for numpy.array(map(...))</tt></dd></dl>
<dl><dt><a name="-approx_real"><strong>approx_real</strong></a>(x)</dt><dd><tt>Deprecated - needs clean room implementation</tt></dd></dl>
<dl><dt><a name="-base_repr"><strong>base_repr</strong></a>(number, base<font color="#909090">=2</font>, padding<font color="#909090">=0</font>)</dt><dd><tt>Return the representation of a number in any given base.</tt></dd></dl>
<dl><dt><a name="-binary_repr"><strong>binary_repr</strong></a>(number, max_length<font color="#909090">=1025</font>)</dt><dd><tt>Return the binary representation of the input number as a string.<br>
<br>
This is more efficient than using base_repr with base 2.<br>
<br>
Increase the value of max_length for very large numbers. Note that on<br>
32-bit machines, 2**1023 is the largest integer power of 2 which can be<br>
converted to a Python float.</tt></dd></dl>
<dl><dt><a name="-bivariate_normal"><strong>bivariate_normal</strong></a>(X, Y, sigmax<font color="#909090">=1.0</font>, sigmay<font color="#909090">=1.0</font>, mux<font color="#909090">=0.0</font>, muy<font color="#909090">=0.0</font>, sigmaxy<font color="#909090">=0.0</font>)</dt><dd><tt>Bivariate gaussan distribution for equal shape X, Y<br>
<br>
<a href="http://mathworld.wolfram.com/BivariateNormalDistribution.html">http://mathworld.wolfram.com/BivariateNormalDistribution.html</a></tt></dd></dl>
<dl><dt><a name="-center_matrix"><strong>center_matrix</strong></a>(M, dim<font color="#909090">=0</font>)</dt><dd><tt>Return the matrix M with each row having zero mean and unit std<br>
<br>
if dim=1 operate on columns instead of rows. (dim is opposite<br>
to the numpy axis kwarg.)</tt></dd></dl>
<dl><dt><a name="-cohere"><strong>cohere</strong></a>(x, y, NFFT<font color="#909090">=256</font>, Fs<font color="#909090">=2</font>, detrend<font color="#909090">=<function detrend_none at 0x252f320></font>, window<font color="#909090">=<function window_hanning at 0x252b2a8></font>, noverlap<font color="#909090">=0</font>)</dt><dd><tt>The coherence between x and y. Coherence is the normalized<br>
cross spectral density<br>
<br>
Cxy = |Pxy|^2/(Pxx*Pyy)<br>
<br>
The return value is (Cxy, f), where f are the frequencies of the<br>
coherence vector. See the docs for psd and csd for information<br>
about the function arguments NFFT, detrend, window, noverlap, as<br>
well as the methods used to compute Pxy, Pxx and Pyy.<br>
<br>
Returns the tuple Cxy, freqs</tt></dd></dl>
<dl><dt><a name="-cohere_pairs"><strong>cohere_pairs</strong></a>(X, ij, NFFT<font color="#909090">=256</font>, Fs<font color="#909090">=2</font>, detrend<font color="#909090">=<function detrend_none at 0x252f320></font>, window<font color="#909090">=<function window_hanning at 0x252b2a8></font>, noverlap<font color="#909090">=0</font>, preferSpeedOverMemory<font color="#909090">=True</font>, progressCallback<font color="#909090">=<function donothing_callback at 0x252f7d0></font>, returnPxx<font color="#909090">=False</font>)</dt><dd><tt>Cxy, Phase, freqs = <a href="#-cohere_pairs">cohere_pairs</a>( X, ij, ...)<br>
<br>
Compute the coherence for all pairs in ij. X is a<br>
numSamples,numCols numpy array. ij is a list of tuples (i,j).<br>
Each tuple is a pair of indexes into the columns of X for which<br>
you want to compute coherence. For example, if X has 64 columns,<br>
and you want to compute all nonredundant pairs, define ij as<br>
<br>
ij = []<br>
for i in range(64):<br>
for j in range(i+1,64):<br>
ij.append( (i,j) )<br>
<br>
The other function arguments, except for 'preferSpeedOverMemory'<br>
(see below), are explained in the help string of 'psd'.<br>
<br>
Return value is a tuple (Cxy, Phase, freqs).<br>
<br>
Cxy -- a dictionary of (i,j) tuples -> coherence vector for that<br>
pair. Ie, Cxy[(i,j) = <a href="#-cohere">cohere</a>(X[:,i], X[:,j]). Number of<br>
dictionary keys is len(ij)<br>
<br>
Phase -- a dictionary of phases of the cross spectral density at<br>
each frequency for each pair. keys are (i,j).<br>
<br>
freqs -- a vector of frequencies, equal in length to either the<br>
coherence or phase vectors for any i,j key. Eg, to make a coherence<br>
Bode plot:<br>
<br>
subplot(211)<br>
plot( freqs, Cxy[(12,19)])<br>
subplot(212)<br>
plot( freqs, Phase[(12,19)])<br>
<br>
For a large number of pairs, cohere_pairs can be much more<br>
efficient than just calling cohere for each pair, because it<br>
caches most of the intensive computations. If N is the number of<br>
pairs, this function is O(N) for most of the heavy lifting,<br>
whereas calling cohere for each pair is O(N^2). However, because<br>
of the caching, it is also more memory intensive, making 2<br>
additional complex arrays with approximately the same number of<br>
elements as X.<br>
<br>
The parameter 'preferSpeedOverMemory', if false, limits the<br>
caching by only making one, rather than two, complex cache arrays.<br>
This is useful if memory becomes critical. Even when<br>
preferSpeedOverMemory is false, cohere_pairs will still give<br>
significant performace gains over calling cohere for each pair,<br>
and will use subtantially less memory than if<br>
preferSpeedOverMemory is true. In my tests with a 43000,64 array<br>
over all nonredundant pairs, preferSpeedOverMemory=1 delivered a<br>
33% performace boost on a 1.7GHZ Athlon with 512MB RAM compared<br>
with preferSpeedOverMemory=0. But both solutions were more than<br>
10x faster than naievly crunching all possible pairs through<br>
cohere.<br>
<br>
See test/cohere_pairs_test.py in the src tree for an example<br>
script that shows that this cohere_pairs and cohere give the same<br>
results for a given pair.</tt></dd></dl>
<dl><dt><a name="-conv"><strong>conv</strong></a>(x, y, mode<font color="#909090">=2</font>)</dt><dd><tt>convolve x with y</tt></dd></dl>
<dl><dt><a name="-corrcoef"><strong>corrcoef</strong></a>(*args)</dt><dd><tt><a href="#-corrcoef">corrcoef</a>(X) where X is a matrix returns a matrix of correlation<br>
coefficients for the columns of X.<br>
<br>
<a href="#-corrcoef">corrcoef</a>(x,y) where x and y are vectors returns the matrix of<br>
correlation coefficients for x and y.<br>
<br>
Numpy arrays can be real or complex<br>
<br>
The correlation matrix is defined from the covariance matrix C as<br>
<br>
r(i,j) = C[i,j] / sqrt(C[i,i]*C[j,j])</tt></dd></dl>
<dl><dt><a name="-csd"><strong>csd</strong></a>(x, y, NFFT<font color="#909090">=256</font>, Fs<font color="#909090">=2</font>, detrend<font color="#909090">=<function detrend_none at 0x252f320></font>, window<font color="#909090">=<function window_hanning at 0x252b2a8></font>, noverlap<font color="#909090">=0</font>)</dt><dd><tt>The cross spectral density Pxy by Welches average periodogram<br>
method. The vectors x and y are divided into NFFT length<br>
segments. Each segment is detrended by function detrend and<br>
windowed by function window. noverlap gives the length of the<br>
overlap between segments. The product of the direct FFTs of x and<br>
y are averaged over each segment to compute Pxy, with a scaling to<br>
correct for power loss due to windowing. Fs is the sampling<br>
frequency.<br>
<br>
NFFT must be even; a power of 2 is most efficient<br>
<br>
window can be a function or a vector of length NFFT. To create<br>
window vectors see numpy.blackman, numpy.hamming, numpy.bartlett,<br>
scipy.signal, scipy.signal.get_window etc.<br>
<br>
Returns the tuple Pxy, freqs<br>
<br>
Refs:<br>
Bendat & Piersol -- Random Data: Analysis and Measurement<br>
Procedures, John Wiley & Sons (1986)</tt></dd></dl>
<dl><dt><a name="-csv2rec"><strong>csv2rec</strong></a>(fname, comments<font color="#909090">='#'</font>, skiprows<font color="#909090">=0</font>, checkrows<font color="#909090">=0</font>, delimiter<font color="#909090">=','</font>, converterd<font color="#909090">=None</font>, names<font color="#909090">=None</font>, missing<font color="#909090">=''</font>, missingd<font color="#909090">=None</font>)</dt><dd><tt>Load data from comma/space/tab delimited file in fname into a<br>
numpy (m)record array and return the record array.<br>
<br>
If names is None, a header row is required to automatically assign<br>
the recarray names. The headers will be lower cased, spaces will<br>
be converted to underscores, and illegal attribute name characters<br>
removed. If names is not None, it is a sequence of names to use<br>
for the column names. In this case, it is assumed there is no header row.<br>
<br>
<br>
fname - can be a filename or a file handle. Support for gzipped<br>
files is automatic, if the filename ends in .gz<br>
<br>
comments - the character used to indicate the start of a comment<br>
in the file<br>
<br>
skiprows - is the number of rows from the top to skip<br>
<br>
checkrows - is the number of rows to check to validate the column<br>
data type. When set to zero all rows are validated.<br>
<br>
converterd, if not None, is a dictionary mapping column number or<br>
munged column name to a converter function.<br>
<br>
names, if not None, is a list of header names. In this case, no<br>
header will be read from the file<br>
<br>
missingd - is a dictionary mapping munged column names to field values<br>
which signify that the field does not contain actual data and should<br>
be masked, e.g. '0000-00-00' or 'unused'<br>
<br>
missing - a string whose value signals a missing field regardless of<br>
the column it appears in, e.g. 'unused'<br>
<br>
if no rows are found, None is returned -- see examples/loadrec.py</tt></dd></dl>
<dl><dt><a name="-csvformat_factory"><strong>csvformat_factory</strong></a>(format)</dt></dl>
<dl><dt><a name="-demean"><strong>demean</strong></a>(x, axis<font color="#909090">=0</font>)</dt><dd><tt>Return x minus its mean along the specified axis</tt></dd></dl>
<dl><dt><a name="-detrend"><strong>detrend</strong></a>(x, key<font color="#909090">=None</font>)</dt></dl>
<dl><dt><a name="-detrend_linear"><strong>detrend_linear</strong></a>(y)</dt><dd><tt>Return y minus best fit line; 'linear' detrending</tt></dd></dl>
<dl><dt><a name="-detrend_mean"><strong>detrend_mean</strong></a>(x)</dt><dd><tt>Return x minus the <a href="#-mean">mean</a>(x)</tt></dd></dl>
<dl><dt><a name="-detrend_none"><strong>detrend_none</strong></a>(x)</dt><dd><tt>Return x: no detrending</tt></dd></dl>
<dl><dt><a name="-diagonal_matrix"><strong>diagonal_matrix</strong></a>(diag)</dt><dd><tt>Return square diagonal matrix whose non-zero elements are given by the<br>
input array.</tt></dd></dl>
<dl><dt><a name="-dist"><strong>dist</strong></a>(x, y)</dt><dd><tt>return the distance between two points</tt></dd></dl>
<dl><dt><a name="-dist_point_to_segment"><strong>dist_point_to_segment</strong></a>(p, s0, s1)</dt><dd><tt>get the distance of a point to a segment.<br>
<br>
p, s0, s1 are xy sequences<br>
<br>
This algorithm from<br>
<a href="http://softsurfer.com/Archive/algorithm_0102/algorithm_0102.htm#Distance%20to%20Ray%20or%20Segment">http://softsurfer.com/Archive/algorithm_0102/algorithm_0102.htm#Distance%20to%20Ray%20or%20Segment</a></tt></dd></dl>
<dl><dt><a name="-donothing_callback"><strong>donothing_callback</strong></a>(*args)</dt></dl>
<dl><dt><a name="-entropy"><strong>entropy</strong></a>(y, bins)</dt><dd><tt>Return the entropy of the data in y<br>
<br>
\sum p_i <a href="#-log2">log2</a>(p_i) where p_i is the probability of observing y in<br>
the ith bin of bins. bins can be a number of bins or a range of<br>
bins; see numpy.histogram<br>
<br>
Compare S with analytic calculation for a Gaussian<br>
x = mu + sigma*randn(200000)<br>
Sanalytic = 0.5 * ( 1.0 + log(2*pi*sigma**2.0) )</tt></dd></dl>
<dl><dt><a name="-exp_safe"><strong>exp_safe</strong></a>(x)</dt><dd><tt>Compute exponentials which safely underflow to zero.<br>
<br>
Slow but convenient to use. Note that numpy provides proper<br>
floating point exception handling with access to the underlying<br>
hardware.</tt></dd></dl>
<dl><dt><a name="-fftsurr"><strong>fftsurr</strong></a>(x, detrend<font color="#909090">=<function detrend_none at 0x252f320></font>, window<font color="#909090">=<function window_none at 0x252b8c0></font>)</dt><dd><tt>Compute an FFT phase randomized surrogate of x</tt></dd></dl>
<dl><dt><a name="-find"><strong>find</strong></a>(condition)</dt><dd><tt>Return the indices where ravel(condition) is true</tt></dd></dl>
<dl><dt><a name="-frange"><strong>frange</strong></a>(xini, xfin<font color="#909090">=None</font>, delta<font color="#909090">=None</font>, **kw)</dt><dd><tt><a href="#-frange">frange</a>([start,] stop[, step, keywords]) -> array of floats<br>
<br>
Return a numpy ndarray containing a progression of floats. Similar to<br>
arange(), but defaults to a closed interval.<br>
<br>
<a href="#-frange">frange</a>(x0, x1) returns [x0, x0+1, x0+2, ..., x1]; start defaults to 0, and<br>
the endpoint *is included*. This behavior is different from that of<br>
range() and arange(). This is deliberate, since frange will probably be<br>
more useful for generating lists of points for function evaluation, and<br>
endpoints are often desired in this use. The usual behavior of range() can<br>
be obtained by setting the keyword 'closed=0', in this case <a href="#-frange">frange</a>()<br>
basically becomes arange().<br>
<br>
When step is given, it specifies the increment (or decrement). All<br>
arguments can be floating point numbers.<br>
<br>
<a href="#-frange">frange</a>(x0,x1,d) returns [x0,x0+d,x0+2d,...,xfin] where xfin<=x1.<br>
<br>
frange can also be called with the keyword 'npts'. This sets the number of<br>
points the list should contain (and overrides the value 'step' might have<br>
been given). arange() doesn't offer this option.<br>
<br>
Examples:<br>
>>> <a href="#-frange">frange</a>(3)<br>
array([ 0., 1., 2., 3.])<br>
>>> <a href="#-frange">frange</a>(3,closed=0)<br>
array([ 0., 1., 2.])<br>
>>> <a href="#-frange">frange</a>(1,6,2)<br>
array([1, 3, 5]) or 1,3,5,7, depending on floating point vagueries<br>
>>> <a href="#-frange">frange</a>(1,6.5,npts=5)<br>
array([ 1. , 2.375, 3.75 , 5.125, 6.5 ])</tt></dd></dl>
<dl><dt><a name="-fromfunction_kw"><strong>fromfunction_kw</strong></a>(function, dimensions, **kwargs)</dt><dd><tt>Drop-in replacement for fromfunction() from numpy<br>
<br>
Allows passing keyword arguments to the desired function.<br>
<br>
Call it as (keywords are optional):<br>
<a href="#-fromfunction_kw">fromfunction_kw</a>(MyFunction, dimensions, keywords)<br>
<br>
The function MyFunction() is responsible for handling the dictionary of<br>
keywords it will receive.</tt></dd></dl>
<dl><dt><a name="-get_formatd"><strong>get_formatd</strong></a>(r, formatd<font color="#909090">=None</font>)</dt><dd><tt>build a formatd guaranteed to have a key for every dtype name</tt></dd></dl>
<dl><dt><a name="-get_sparse_matrix"><strong>get_sparse_matrix</strong></a>(M, N, frac<font color="#909090">=0.10000000000000001</font>)</dt><dd><tt>return a MxN sparse matrix with frac elements randomly filled</tt></dd></dl>
<dl><dt><a name="-get_xyz_where"><strong>get_xyz_where</strong></a>(Z, Cond)</dt><dd><tt>Z and Cond are MxN matrices. Z are data and Cond is a boolean<br>
matrix where some condition is satisfied. Return value is x,y,z<br>
where x and y are the indices into Z and z are the values of Z at<br>
those indices. x,y,z are 1D arrays</tt></dd></dl>
<dl><dt><a name="-griddata"><strong>griddata</strong></a>(x, y, z, xi, yi)</dt><dd><tt>zi = <a href="#-griddata">griddata</a>(x,y,z,xi,yi) fits a surface of the form z = f(x,y)<br>
to the data in the (usually) nonuniformly spaced vectors (x,y,z).<br>
griddata interpolates this surface at the points specified by (xi,yi)<br>
to produce zi. xi and yi must describe a regular grid, can be<br>
either 1D or 2D, but must be monotonically increasing.<br>
<br>
A masked array is returned if any grid points are outside convex<br>
hull defined by input data (no extrapolation is done).<br>
<br>
Uses natural neighbor interpolation based on Delaunay triangulation.<br>
By default, this algorithm is provided by the matplotlib.delaunay<br>
package, written by Robert Kern. The triangulation algorithm in this<br>
package is known to fail on some nearly pathological cases. For<br>
this reason, a separate toolkit (mpl_tookits.natgrid) has been created<br>
that provides a more robust algorithm fof triangulation and interpolation.<br>
This toolkit is based on the NCAR natgrid library, which contains code<br>
that is not redistributable under a BSD-compatible license. When installed,<br>
this function will use the mpl_toolkits.natgrid algorithm, otherwise it<br>
will use the built-in matplotlib.delaunay package.<br>
<br>
The natgrid matplotlib toolkit can be downloaded from<br>
<a href="http://sourceforge.net/project/showfiles.php?group_id=80706&package_id=142792">http://sourceforge.net/project/showfiles.php?group_id=80706&package_id=142792</a></tt></dd></dl>
<dl><dt><a name="-hist"><strong>hist</strong></a>(y, bins<font color="#909090">=10</font>, normed<font color="#909090">=0</font>)</dt><dd><tt>Return the histogram of y with bins equally sized bins. If bins<br>
is an array, use the bins. Return value is<br>
(n,x) where n is the count for each bin in x<br>
<br>
If normed is False, return the counts in the first element of the<br>
return tuple. If normed is True, return the probability density<br>
n/(len(y)*dbin)<br>
<br>
If y has rank>1, it will be raveled. If y is masked, only<br>
the unmasked values will be used.<br>
Credits: the Numeric 22 documentation</tt></dd></dl>
<dl><dt><a name="-identity"><strong>identity</strong></a>(n, rank<font color="#909090">=2</font>, dtype<font color="#909090">='l'</font>, typecode<font color="#909090">=None</font>)</dt><dd><tt><a href="#-identity">identity</a>(n,r) returns the identity matrix of shape (n,n,...,n) (rank r).<br>
<br>
For ranks higher than 2, this object is simply a multi-index Kronecker<br>
delta:<br>
/ 1 if i0=i1=...=iR,<br>
id[i0,i1,...,iR] = -|<br>
\ 0 otherwise.<br>
<br>
Optionally a dtype (or typecode) may be given (it defaults to 'l').<br>
<br>
Since rank defaults to 2, this function behaves in the default case (when<br>
only n is given) like numpy.<a href="#-identity">identity</a>(n)--but surprisingly, it is<br>
much faster.</tt></dd></dl>
<dl><dt><a name="-inside_poly"><strong>inside_poly</strong></a>(points, verts)</dt><dd><tt>points is a sequence of x,y points<br>
verts is a sequence of x,y vertices of a poygon<br>
<br>
return value is a sequence of indices into points for the points<br>
that are inside the polygon</tt></dd></dl>
<dl><dt><a name="-ispower2"><strong>ispower2</strong></a>(n)</dt><dd><tt>Returns the log base 2 of n if n is a power of 2, zero otherwise.<br>
<br>
Note the potential ambiguity if n==1: 2**0==1, interpret accordingly.</tt></dd></dl>
<dl><dt><a name="-l1norm"><strong>l1norm</strong></a>(a)</dt><dd><tt>Return the l1 norm of a, flattened out.<br>
<br>
Implemented as a separate function (not a call to <a href="#-norm">norm</a>() for speed).</tt></dd></dl>
<dl><dt><a name="-l2norm"><strong>l2norm</strong></a>(a)</dt><dd><tt>Return the l2 norm of a, flattened out.<br>
<br>
Implemented as a separate function (not a call to <a href="#-norm">norm</a>() for speed).</tt></dd></dl>
<dl><dt><a name="-levypdf"><strong>levypdf</strong></a>(x, gamma, alpha)</dt><dd><tt>Returm the levy pdf evaluated at x for params gamma, alpha</tt></dd></dl>
<dl><dt><a name="-liaupunov"><strong>liaupunov</strong></a>(x, fprime)</dt><dd><tt>x is a very long trajectory from a map, and fprime returns the<br>
derivative of x. Return lambda = 1/n\sum ln|fprime(x_i)|. See Sec<br>
10.5 Strogatz (1994)"Nonlinear Dynamics and Chaos".<br>
See also <a href="http://en.wikipedia.org/wiki/Lyapunov_exponent">http://en.wikipedia.org/wiki/Lyapunov_exponent</a>.<br>
What the function here calculates may not be what you really want;<br>
caveat emptor.<br>
It also seems that this function's name is badly misspelled.</tt></dd></dl>
<dl><dt><a name="-linspace"><strong>linspace</strong></a>(*args, **kw)</dt></dl>
<dl><dt><a name="-load"><strong>load</strong></a>(fname, comments<font color="#909090">='#'</font>, delimiter<font color="#909090">=None</font>, converters<font color="#909090">=None</font>, skiprows<font color="#909090">=0</font>, usecols<font color="#909090">=None</font>, unpack<font color="#909090">=False</font>, dtype<font color="#909090">=<type 'numpy.float64'></font>)</dt><dd><tt>Load ASCII data from fname into an array and return the array.<br>
<br>
The data must be regular, same number of values in every row<br>
<br>
fname can be a filename or a file handle. Support for gzipped files is<br>
automatic, if the filename ends in .gz<br>
<br>
matfile data is not supported; use scipy.io.mio module<br>
<br>
Example usage:<br>
<br>
X = <a href="#-load">load</a>('test.dat') # data in two columns<br>
t = X[:,0]<br>
y = X[:,1]<br>
<br>
Alternatively, you can do the same with "unpack"; see below<br>
<br>
X = <a href="#-load">load</a>('test.dat') # a matrix of data<br>
x = <a href="#-load">load</a>('test.dat') # a single column of data<br>
<br>
comments - the character used to indicate the start of a comment<br>
in the file<br>
<br>
delimiter is a string-like character used to seperate values in the<br>
file. If delimiter is unspecified or none, any whitespace string is<br>
a separator.<br>
<br>
converters, if not None, is a dictionary mapping column number to<br>
a function that will convert that column to a float (or the optional<br>
dtype if specified). Eg, if column 0 is a date string:<br>
converters={0:datestr2num}<br>
<br>
skiprows is the number of rows from the top to skip<br>
<br>
usecols, if not None, is a sequence of integer column indexes to<br>
extract where 0 is the first column, eg usecols=[1,4,5] to extract<br>
just the 2nd, 5th and 6th columns<br>
<br>
unpack, if True, will transpose the matrix allowing you to unpack<br>
into named arguments on the left hand side<br>
<br>
t,y = <a href="#-load">load</a>('test.dat', unpack=True) # for two column data<br>
x,y,z = <a href="#-load">load</a>('somefile.dat', usecols=[3,5,7], unpack=True)<br>
<br>
dtype, the array will have this dtype. default: numpy.float_<br>
<br>
See examples/load_demo.py which exeercises many of these options.</tt></dd></dl>
<dl><dt><a name="-log2"><strong>log2</strong></a>(x, ln2<font color="#909090">=0.69314718055994529</font>)</dt><dd><tt>Return the log(x) in base 2.<br>
<br>
This is a _slow_ function but which is guaranteed to return the correct<br>
integer value if the input is an integer exact power of 2.</tt></dd></dl>
<dl><dt><a name="-logspace"><strong>logspace</strong></a>(xmin, xmax, N)</dt></dl>
<dl><dt><a name="-longest_contiguous_ones"><strong>longest_contiguous_ones</strong></a>(x)</dt><dd><tt>return the indices of the longest stretch of contiguous ones in x,<br>
assuming x is a vector of zeros and ones.<br>
If there are two equally long stretches, pick the first</tt></dd></dl>
<dl><dt><a name="-longest_ones"><strong>longest_ones</strong></a>(x)</dt><dd><tt>alias for longest_contiguous_ones</tt></dd></dl>
<dl><dt><a name="-mean"><strong>mean</strong></a>(x, dim<font color="#909090">=None</font>)</dt></dl>
<dl><dt><a name="-mean_flat"><strong>mean_flat</strong></a>(a)</dt><dd><tt>Return the mean of all the elements of a, flattened out.</tt></dd></dl>
<dl><dt><a name="-meshgrid"><strong>meshgrid</strong></a>(x, y)</dt></dl>
<dl><dt><a name="-mfuncC"><strong>mfuncC</strong></a>(f, x)</dt><dd><tt>Deprecated</tt></dd></dl>
<dl><dt><a name="-movavg"><strong>movavg</strong></a>(x, n)</dt><dd><tt>compute the len(n) moving average of x</tt></dd></dl>
<dl><dt><a name="-norm"><strong>norm</strong></a>(x, y<font color="#909090">=2</font>)</dt><dd><tt>Deprecated - see numpy.linalg.norm</tt></dd></dl>
<dl><dt><a name="-norm_flat"><strong>norm_flat</strong></a>(a, p<font color="#909090">=2</font>)</dt><dd><tt><a href="#-norm">norm</a>(a,p=2) -> l-p norm of a.flat<br>
<br>
Return the l-p norm of a, considered as a flat array. This is NOT a true<br>
matrix norm, since arrays of arbitrary rank are always flattened.<br>
<br>
p can be a number or the string 'Infinity' to get the L-infinity norm.</tt></dd></dl>
<dl><dt><a name="-normpdf"><strong>normpdf</strong></a>(x, *args)</dt><dd><tt>Return the normal pdf evaluated at x; args provides mu, sigma</tt></dd></dl>
<dl><dt><a name="-orth"><strong>orth</strong></a>(A)</dt><dd><tt>Deprecated - needs clean room implementation</tt></dd></dl>
<dl><dt><a name="-poly_below"><strong>poly_below</strong></a>(xmin, xs, ys)</dt><dd><tt>given a sequence of xs and ys, return the vertices of a polygon<br>
that has a horzontal base at xmin and an upper bound at the ys.<br>
xmin is a scalar.<br>
<br>
intended for use with Axes.fill, eg<br>
xv, yv = <a href="#-poly_below">poly_below</a>(0, x, y)<br>
ax.fill(xv, yv)</tt></dd></dl>
<dl><dt><a name="-poly_between"><strong>poly_between</strong></a>(x, ylower, yupper)</dt><dd><tt>given a sequence of x, ylower and yupper, return the polygon that<br>
fills the regions between them. ylower or yupper can be scalar or<br>
iterable. If they are iterable, they must be equal in length to x<br>
<br>
return value is x, y arrays for use with Axes.fill</tt></dd></dl>
<dl><dt><a name="-polyfit"><strong>polyfit</strong></a>(*args, **kwargs)</dt><dd><tt>def <a href="#-polyfit">polyfit</a>(x,y,N)<br>
<br>
Do a best fit polynomial of order N of y to x. Return value is a<br>
vector of polynomial coefficients [pk ... p1 p0]. Eg, for N=2<br>
<br>
p2*x0^2 + p1*x0 + p0 = y1<br>
p2*x1^2 + p1*x1 + p0 = y1<br>
p2*x2^2 + p1*x2 + p0 = y2<br>
.....<br>
p2*xk^2 + p1*xk + p0 = yk<br>
<br>
<br>
Method: if X is a the Vandermonde Matrix computed from x (see<br>
<a href="http://mathworld.wolfram.com/VandermondeMatrix.html">http://mathworld.wolfram.com/VandermondeMatrix.html</a>), then the<br>
polynomial least squares solution is given by the 'p' in<br>
<br>
X*p = y<br>
<br>
where X is a len(x) x N+1 matrix, p is a N+1 length vector, and y<br>
is a len(x) x 1 vector<br>
<br>
This equation can be solved as<br>
<br>
p = (XT*X)^-1 * XT * y<br>
<br>
where XT is the transpose of X and -1 denotes the inverse.<br>
Numerically, however, this is not a good method, so we use<br>
numpy.linalg.lstsq.<br>
<br>
For more info, see<br>
<a href="http://mathworld.wolfram.com/LeastSquaresFittingPolynomial.html">http://mathworld.wolfram.com/LeastSquaresFittingPolynomial.html</a>,<br>
but note that the k's and n's in the superscripts and subscripts<br>
on that page. The linear algebra is correct, however.<br>
<br>
See also polyval</tt></dd></dl>
<dl><dt><a name="-polyval"><strong>polyval</strong></a>(*args, **kwargs)</dt><dd><tt>y = <a href="#-polyval">polyval</a>(p,x)<br>
<br>
p is a vector of polynomial coeffients and y is the polynomial<br>
evaluated at x.<br>
<br>
Example code to remove a polynomial (quadratic) trend from y:<br>
<br>
p = <a href="#-polyfit">polyfit</a>(x, y, 2)<br>
trend = <a href="#-polyval">polyval</a>(p, x)<br>
resid = y - trend<br>
<br>
See also polyfit</tt></dd></dl>
<dl><dt><a name="-prctile"><strong>prctile</strong></a>(x, p<font color="#909090">=(0.0, 25.0, 50.0, 75.0, 100.0)</font>)</dt><dd><tt>Return the percentiles of x. p can either be a sequence of<br>
percentile values or a scalar. If p is a sequence the i-th element<br>
of the return sequence is the p(i)-th percentile of x.<br>
If p is a scalar, the largest value of x less than or equal<br>
to the p percentage point in the sequence is returned.</tt></dd></dl>
<dl><dt><a name="-prctile_rank"><strong>prctile_rank</strong></a>(x, p)</dt><dd><tt>return the for each element in x, return the rank 0..len(p) . Eg<br>
if p=(25, 50, 75), the return value will be a len(x) array with<br>
values in [0,1,2,3] where 0 indicates the value is less than the<br>
25th percentile, 1 indicates the value is >= the 25th and < 50th<br>
percentile, ... and 3 indicates the value is above the 75th<br>
percentile cutoff<br>
<br>
p is either an array of percentiles in [0..100] or a scalar which<br>
indicates how many quantiles of data you want ranked</tt></dd></dl>
<dl><dt><a name="-prepca"><strong>prepca</strong></a>(P, frac<font color="#909090">=0</font>)</dt><dd><tt>Compute the principal components of P. P is a numVars x<br>
numObs array. frac is the minimum fraction of<br>
variance that a component must contain to be included.<br>
<br>
Return value are<br>
Pcomponents : a numVars x numObs array<br>
Trans : the weights matrix, ie, Pcomponents = Trans*P<br>
fracVar : the fraction of the variance accounted for by each<br>
component returned<br>
<br>
A similar function of the same name was in the Matlab (TM)<br>
R13 Neural Network Toolbox but is not found in later versions;<br>
its successor seems to be called "processpcs".</tt></dd></dl>
<dl><dt><a name="-psd"><strong>psd</strong></a>(x, NFFT<font color="#909090">=256</font>, Fs<font color="#909090">=2</font>, detrend<font color="#909090">=<function detrend_none at 0x252f320></font>, window<font color="#909090">=<function window_hanning at 0x252b2a8></font>, noverlap<font color="#909090">=0</font>)</dt><dd><tt>The power spectral density by Welches average periodogram method.<br>
The vector x is divided into NFFT length segments. Each segment<br>
is detrended by function detrend and windowed by function window.<br>
noperlap gives the length of the overlap between segments. The<br>
absolute(fft(segment))**2 of each segment are averaged to compute Pxx,<br>
with a scaling to correct for power loss due to windowing.<br>
<br>
Fs is the sampling frequency (samples per time unit). It is used<br>
to calculate the Fourier frequencies, freqs, in cycles per time<br>
unit.<br>
<br>
-- NFFT must be even; a power 2 is most efficient.<br>
-- detrend is a functions, unlike in matlab where it is a vector.<br>
-- window can be a function or a vector of length NFFT. To create window<br>
vectors see numpy.blackman, numpy.hamming, numpy.bartlett,<br>
scipy.signal, scipy.signal.get_window etc.<br>
-- if length x < NFFT, it will be zero padded to NFFT<br>
<br>
<br>
Returns the tuple Pxx, freqs<br>
<br>
Refs:<br>
Bendat & Piersol -- Random Data: Analysis and Measurement<br>
Procedures, John Wiley & Sons (1986)</tt></dd></dl>
<dl><dt><a name="-rank"><strong>rank</strong></a>(x)</dt><dd><tt>Deprecated - see numpy.rank</tt></dd></dl>
<dl><dt><a name="-rec2csv"><strong>rec2csv</strong></a>(r, fname, delimiter<font color="#909090">=','</font>, formatd<font color="#909090">=None</font>, missing<font color="#909090">=''</font>, missingd<font color="#909090">=None</font>)</dt><dd><tt>Save the data from numpy (m)recarray r into a comma/space/tab<br>
delimited file. The record array dtype names will be used for<br>
column headers.<br>
<br>
<br>
fname - can be a filename or a file handle. Support for gzipped<br>
files is automatic, if the filename ends in .gz<br>
<br>
See csv2rec and rec2csv for information about missing and<br>
missingd, which can be used to fill in masked values into your CSV<br>
file.</tt></dd></dl>
<dl><dt><a name="-rec2txt"><strong>rec2txt</strong></a>(r, header<font color="#909090">=None</font>, padding<font color="#909090">=3</font>, precision<font color="#909090">=3</font>)</dt><dd><tt>Returns a textual representation of a record array.<br>
<br>
r - numpy recarray<br>
<br>
header - list of column headers<br>
<br>
padding - space between each column<br>
<br>
precision - number of decimal places to use for floats.<br>
Set to an integer to apply to all floats. Set to a<br>
list of integers to apply precision individually.<br>
Precision for non-floats is simply ignored.<br>
<br>
Example:<br>
precision=[0,2,3]<br>
Output:<br>
ID Price Return<br>
ABC 12.54 0.234<br>
XYZ 6.32 -0.076</tt></dd></dl>
<dl><dt><a name="-rec_append_field"><strong>rec_append_field</strong></a>(rec, name, arr, dtype<font color="#909090">=None</font>)</dt><dd><tt>return a new record array with field name populated with data from array arr.<br>
This function is Depreacted. Please use rec_append_fields.</tt></dd></dl>
<dl><dt><a name="-rec_append_fields"><strong>rec_append_fields</strong></a>(rec, names, arrs, dtypes<font color="#909090">=None</font>)</dt><dd><tt>return a new record array with field names populated with data<br>
from arrays in arrs. If appending a single field then names, arrs<br>
and dtypes do not have to be lists. They can just be the values themselves.</tt></dd></dl>
<dl><dt><a name="-rec_drop_fields"><strong>rec_drop_fields</strong></a>(rec, names)</dt><dd><tt>return a new numpy record array with fields in names dropped</tt></dd></dl>
<dl><dt><a name="-rec_groupby"><strong>rec_groupby</strong></a>(r, groupby, stats)</dt><dd><tt>r is a numpy record array<br>
<br>
groupby is a sequence of record array attribute names that<br>
together form the grouping key. eg ('date', 'productcode')<br>
<br>
stats is a sequence of (attr, func, outname) which will call x =<br>
func(attr) and assign x to the record array output with attribute<br>
outname.<br>
Eg, stats = ( ('sales', len, 'numsales'), ('sales', np.mean, 'avgsale') )<br>
<br>
return record array has dtype names for each attribute name in in<br>
the the 'groupby' argument, with the associated group values, and<br>
for each outname name in the stats argument, with the associated<br>
stat summary output</tt></dd></dl>
<dl><dt><a name="-rec_join"><strong>rec_join</strong></a>(key, r1, r2, jointype<font color="#909090">='inner'</font>, defaults<font color="#909090">=None</font>)</dt><dd><tt>join record arrays r1 and r2 on key; key is a tuple of field<br>
names. If r1 and r2 have equal values on all the keys in the key<br>
tuple, then their fields will be merged into a new record array<br>
containing the intersection of the fields of r1 and r2.<br>
<br>
r1 (also r2) must not have any duplicate keys.<br>
<br>
The jointype keyword can be 'inner', 'outer', 'leftouter'.<br>
To do a rightouter join just reverse r1 and r2.<br>
<br>
The defaults keyword is a dictionary filled with<br>
{column_name:default_value} pairs.</tt></dd></dl>
<dl><dt><a name="-rec_summarize"><strong>rec_summarize</strong></a>(r, summaryfuncs)</dt><dd><tt>r is a numpy record array<br>
<br>
summaryfuncs is a list of (attr, func, outname) which will<br>
apply codefunc to the the array r[attr] and assign the output<br>
to a new attribute name outname. The returned record array is<br>
identical to r, with extra arrays for each element in summaryfuncs</tt></dd></dl>
<dl><dt><a name="-rem"><strong>rem</strong></a>(x, y)</dt><dd><tt>Deprecated - see numpy.remainder</tt></dd></dl>
<dl><dt><a name="-rk4"><strong>rk4</strong></a>(derivs, y0, t)</dt><dd><tt>Integrate 1D or ND system of ODEs from initial state y0 at sample<br>
times t. derivs returns the derivative of the system and has the<br>
signature<br>
<br>
dy = derivs(yi, ti)<br>
<br>
Example 1 :<br>
<br>
## 2D system<br>
<br>
def derivs6(x,t):<br>
d1 = x[0] + 2*x[1]<br>
d2 = -3*x[0] + 4*x[1]<br>
return (d1, d2)<br>
dt = 0.0005<br>
t = arange(0.0, 2.0, dt)<br>
y0 = (1,2)<br>
yout = <a href="#-rk4">rk4</a>(derivs6, y0, t)<br>
<br>
Example 2:<br>
<br>
## 1D system<br>
alpha = 2<br>
def derivs(x,t):<br>
return -alpha*x + exp(-t)<br>
<br>
y0 = 1<br>
yout = <a href="#-rk4">rk4</a>(derivs, y0, t)<br>
<br>
<br>
If you have access to scipy, you should probably be using the<br>
scipy.integrate tools rather than this function.</tt></dd></dl>
<dl><dt><a name="-rms_flat"><strong>rms_flat</strong></a>(a)</dt><dd><tt>Return the root mean square of all the elements of a, flattened out.</tt></dd></dl>
<dl><dt><a name="-safe_isinf"><strong>safe_isinf</strong></a>(x)</dt><dd><tt>isnan for arbitrary types</tt></dd></dl>
<dl><dt><a name="-safe_isnan"><strong>safe_isnan</strong></a>(x)</dt><dd><tt>isnan for arbitrary types</tt></dd></dl>
<dl><dt><a name="-save"><strong>save</strong></a>(fname, X, fmt<font color="#909090">='%.18e'</font>, delimiter<font color="#909090">=' '</font>)</dt><dd><tt>Save the data in X to file fname using fmt string to convert the<br>
data to strings<br>
<br>
fname can be a filename or a file handle. If the filename ends in .gz,<br>
the file is automatically saved in compressed gzip format. The <a href="#-load">load</a>()<br>
command understands gzipped files transparently.<br>
<br>
Example usage:<br>
<br>
<a href="#-save">save</a>('test.out', X) # X is an array<br>
<a href="#-save">save</a>('test1.out', (x,y,z)) # x,y,z equal sized 1D arrays<br>
<a href="#-save">save</a>('test2.out', x) # x is 1D<br>
<a href="#-save">save</a>('test3.out', x, fmt='%1.4e') # use exponential notation<br>
<br>
delimiter is used to separate the fields, eg delimiter ',' for<br>
comma-separated values</tt></dd></dl>
<dl><dt><a name="-segments_intersect"><strong>segments_intersect</strong></a>(s1, s2)</dt><dd><tt>Return True if s1 and s2 intersect.<br>
s1 and s2 are defined as<br>
<br>
s1: (x1, y1), (x2, y2)<br>
s2: (x3, y3), (x4, y4)</tt></dd></dl>
<dl><dt><a name="-slopes"><strong>slopes</strong></a>(x, y)</dt><dd><tt>SLOPES calculate the slope y'(x) Given data vectors X and Y SLOPES<br>
calculates Y'(X), i.e the slope of a curve Y(X). The slope is<br>
estimated using the slope obtained from that of a parabola through<br>
any three consecutive points.<br>
<br>
This method should be superior to that described in the appendix<br>
of A CONSISTENTLY WELL BEHAVED METHOD OF INTERPOLATION by Russel<br>
W. Stineman (Creative Computing July 1980) in at least one aspect:<br>
<br>
Circles for interpolation demand a known aspect ratio between x-<br>
and y-values. For many functions, however, the abscissa are given<br>
in different dimensions, so an aspect ratio is completely<br>
arbitrary.<br>
<br>
The parabola method gives very similar results to the circle<br>
method for most regular cases but behaves much better in special<br>
cases<br>
<br>
Norbert Nemec, Institute of Theoretical Physics, University or<br>
Regensburg, April 2006 Norbert.Nemec at physik.uni-regensburg.de<br>
<br>
(inspired by a original implementation by Halldor Bjornsson,<br>
Icelandic Meteorological Office, March 2006 halldor at vedur.is)</tt></dd></dl>
<dl><dt><a name="-specgram"><strong>specgram</strong></a>(x, NFFT<font color="#909090">=256</font>, Fs<font color="#909090">=2</font>, detrend<font color="#909090">=<function detrend_none at 0x252f320></font>, window<font color="#909090">=<function window_hanning at 0x252b2a8></font>, noverlap<font color="#909090">=128</font>)</dt><dd><tt>Compute a spectrogram of data in x. Data are split into NFFT<br>
length segements and the PSD of each section is computed. The<br>
windowing function window is applied to each segment, and the<br>
amount of overlap of each segment is specified with noverlap.<br>
<br>
window can be a function or a vector of length NFFT. To create<br>
window vectors see numpy.blackman, numpy.hamming, numpy.bartlett,<br>
scipy.signal, scipy.signal.get_window etc.<br>
<br>
See psd for more info. (psd differs in the default overlap;<br>
in returning the mean of the segment periodograms; and in not<br>
returning times.)<br>
<br>
If x is real (i.e. non-Complex) only the positive spectrum is<br>
given. If x is Complex then the complete spectrum is given.<br>
<br>
returns:<br>
Pxx - 2-D array, columns are the periodograms of<br>
successive segments<br>
freqs - 1-D array of frequencies corresponding to<br>
the rows in Pxx<br>
t - 1-D array of times corresponding to midpoints of<br>
segments.</tt></dd></dl>
<dl><dt><a name="-sqrtm"><strong>sqrtm</strong></a>(x)</dt><dd><tt>Deprecated - needs clean room implementation</tt></dd></dl>
<dl><dt><a name="-stineman_interp"><strong>stineman_interp</strong></a>(xi, x, y, yp<font color="#909090">=None</font>)</dt><dd><tt>STINEMAN_INTERP Well behaved data interpolation. Given data<br>
vectors X and Y, the slope vector YP and a new abscissa vector XI<br>
the function <a href="#-stineman_interp">stineman_interp</a>(xi,x,y,yp) uses Stineman<br>
interpolation to calculate a vector YI corresponding to XI.<br>
<br>
Here's an example that generates a coarse sine curve, then<br>
interpolates over a finer abscissa:<br>
<br>
x = np.<a href="#-linspace">linspace</a>(0,2*pi,20); y = sin(x); yp = cos(x)<br>
xi = np.<a href="#-linspace">linspace</a>(0,2*pi,40);<br>
yi = <a href="#-stineman_interp">stineman_interp</a>(xi,x,y,yp);<br>
plot(x,y,'o',xi,yi)<br>
<br>
The interpolation method is described in the article A<br>
CONSISTENTLY WELL BEHAVED METHOD OF INTERPOLATION by Russell<br>
W. Stineman. The article appeared in the July 1980 issue of<br>
Creative Computing with a note from the editor stating that while<br>
they were<br>
<br>
not an academic journal but once in a while something serious<br>
and original comes in adding that this was<br>
"apparently a real solution" to a well known problem.<br>
<br>
For yp=None, the routine automatically determines the slopes using<br>
the "slopes" routine.<br>
<br>
X is assumed to be sorted in increasing order<br>
<br>
For values xi[j] < x[0] or xi[j] > x[-1], the routine tries a<br>
extrapolation. The relevance of the data obtained from this, of<br>
course, questionable...<br>
<br>
original implementation by Halldor Bjornsson, Icelandic<br>
Meteorolocial Office, March 2006 halldor at vedur.is<br>
<br>
completely reworked and optimized for Python by Norbert Nemec,<br>
Institute of Theoretical Physics, University or Regensburg, April<br>
2006 Norbert.Nemec at physik.uni-regensburg.de</tt></dd></dl>
<dl><dt><a name="-sum_flat"><strong>sum_flat</strong></a>(a)</dt><dd><tt>Return the sum of all the elements of a, flattened out.<br>
<br>
It uses a.flat, and if a is not contiguous, a call to ravel(a) is made.</tt></dd></dl>
<dl><dt><a name="-trapz"><strong>trapz</strong></a>(x, y)</dt><dd><tt>Trapezoidal integral of y(x).</tt></dd></dl>
<dl><dt><a name="-vander"><strong>vander</strong></a>(*args, **kwargs)</dt><dd><tt>X = <a href="#-vander">vander</a>(x,N=None)<br>
<br>
The Vandermonde matrix of vector x. The i-th column of X is the<br>
the i-th power of x. N is the maximum power to compute; if N is<br>
None it defaults to len(x).</tt></dd></dl>
<dl><dt><a name="-window_hanning"><strong>window_hanning</strong></a>(x)</dt><dd><tt>return x times the hanning window of len(x)</tt></dd></dl>
<dl><dt><a name="-window_none"><strong>window_none</strong></a>(x)</dt><dd><tt>No window function; simply return x</tt></dd></dl>
<dl><dt><a name="-zeros_like"><strong>zeros_like</strong></a>(a)</dt><dd><tt>Return an array of zeros of the shape and typecode of a.</tt></dd></dl>
</td></tr></table><p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#55aa55">
<td colspan=3 valign=bottom> <br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Data</strong></big></font></td></tr>
<tr><td bgcolor="#55aa55"><tt> </tt></td><td> </td>
<td width="100%"><strong>defaultformatd</strong> = {<type 'numpy.bool_'>: <matplotlib.mlab.FormatBool instance at 0x251e518>, <type 'numpy.int16'>: <matplotlib.mlab.FormatInt instance at 0x251e560>, <type 'numpy.int32'>: <matplotlib.mlab.FormatInt instance at 0x251e6c8>, <type 'numpy.int64'>: <matplotlib.mlab.FormatInt instance at 0x251e878>, <type 'numpy.float32'>: <matplotlib.mlab.FormatFloat instance at 0x251ed88>, <type 'numpy.float64'>: <matplotlib.mlab.FormatFloat instance at 0x252e368>, <type 'numpy.object_'>: <matplotlib.mlab.FormatObj instance at 0x252e3b0>, <type 'numpy.string_'>: <matplotlib.mlab.FormatString instance at 0x252e3f8>}<br>
<strong>division</strong> = _Feature((2, 2, 0, 'alpha', 2), (3, 0, 0, 'alpha', 0), 8192)<br>
<strong>exp_safe_MAX</strong> = 1.7976931348623157e+308<br>
<strong>exp_safe_MIN</strong> = -708.39641853226408<br>
<strong>verbose</strong> = <matplotlib.Verbose instance at 0x24e6200></td></tr></table>
@footer@