<?xml version="1.0" encoding="ascii"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title>Scientific.IO.ArrayIO</title> <link rel="stylesheet" href="epydoc.css" type="text/css" /> <script type="text/javascript" src="epydoc.js"></script> </head> <body bgcolor="white" text="black" link="blue" vlink="#204080" alink="#204080"> <!-- ==================== NAVIGATION BAR ==================== --> <table class="navbar" border="0" width="100%" cellpadding="0" bgcolor="#a0c0ff" cellspacing="0"> <tr valign="middle"> <!-- Home link --> <th> <a href="Scientific-module.html">Home</a> </th> <!-- Tree link --> <th> <a href="module-tree.html">Trees</a> </th> <!-- Index link --> <th> <a href="identifier-index.html">Indices</a> </th> <!-- Help link --> <th> <a href="help.html">Help</a> </th> <!-- Project homepage --> <th class="navbar" align="right" width="100%"> <table border="0" cellpadding="0" cellspacing="0"> <tr><th class="navbar" align="center" ><a class="navbar" target="_top" href="http://dirac.cnrs-orleans.fr/ScientificPython/">Scientific Python</a></th> </tr></table></th> </tr> </table> <table width="100%" cellpadding="0" cellspacing="0"> <tr valign="top"> <td width="100%"> <span class="breadcrumbs"> <a href="Scientific-module.html">Package Scientific</a> :: <a href="Scientific.IO-module.html">Package IO</a> :: Module ArrayIO </span> </td> <td> <table cellpadding="0" cellspacing="0"> <!-- hide/show private --> <tr><td align="right"><span class="options" >[<a href="frames.html" target="_top">frames</a >] | <a href="Scientific.IO.ArrayIO-module.html" target="_top">no frames</a>]</span></td></tr> </table> </td> </tr> </table> <!-- ==================== MODULE DESCRIPTION ==================== --> <h1 class="epydoc">Module ArrayIO</h1><p class="nomargin-top"></p> <p>Basic support for I/O of one- and two-dimensional numerical arrays to and from plain text files</p> <p>The text file format is very simple and used by many other programs as well:</p> <ul> <li> each line corresponds to one row of the array </li> <li> the numbers within a line are separated by white space </li> <li> lines starting with # are ignored (comment lines) </li> </ul> <p>An array containing only one line or one column is returned as a one-dimensional array on reading. One-dimensional arrays are written as one item per line.</p> <p>Numbers in files to be read must conform to Python/C syntax. For reading files containing Fortran-style double-precision numbers (exponent prefixed by D), use the module <a href="Scientific.IO.FortranFormat-module.html" class="link">Scientific.IO.FortranFormat</a>.</p> <!-- ==================== FUNCTIONS ==================== --> <a name="section-Functions"></a> <table class="summary" border="1" cellpadding="3" cellspacing="0" width="100%" bgcolor="white"> <tr bgcolor="#70b0f0" class="table-header"> <td align="left" colspan="2" class="table-header"> <span class="table-header">Functions</span></td> </tr> <tr> <td width="15%" align="right" valign="top" class="summary"> <span class="summary-type"><code>Numeric.array</code></span> </td><td class="summary"> <table width="100%" cellpadding="0" cellspacing="0" border="0"> <tr> <td><span class="summary-sig"><a href="Scientific.IO.ArrayIO-module.html#readArray" class="summary-sig-name">readArray</a>(<span class="summary-sig-arg">filename</span>)</span><br /> Read array data from a file</td> <td align="right" valign="top"> </td> </tr> </table> </td> </tr> <tr> <td width="15%" align="right" valign="top" class="summary"> <span class="summary-type"><code>Numeric.array</code> of <code>float</code></span> </td><td class="summary"> <table width="100%" cellpadding="0" cellspacing="0" border="0"> <tr> <td><span class="summary-sig"><a href="Scientific.IO.ArrayIO-module.html#readFloatArray" class="summary-sig-name">readFloatArray</a>(<span class="summary-sig-arg">filename</span>)</span><br /> Read array data from a file into an array of floats</td> <td align="right" valign="top"> </td> </tr> </table> </td> </tr> <tr> <td width="15%" align="right" valign="top" class="summary"> <span class="summary-type"><code>Numeric.array</code> of <code>int</code></span> </td><td class="summary"> <table width="100%" cellpadding="0" cellspacing="0" border="0"> <tr> <td><span class="summary-sig"><a href="Scientific.IO.ArrayIO-module.html#readIntegerArray" class="summary-sig-name">readIntegerArray</a>(<span class="summary-sig-arg">filename</span>)</span><br /> Read array data from a file into an array of integers</td> <td align="right" valign="top"> </td> </tr> </table> </td> </tr> <tr> <td width="15%" align="right" valign="top" class="summary"> <span class="summary-type"> </span> </td><td class="summary"> <table width="100%" cellpadding="0" cellspacing="0" border="0"> <tr> <td><span class="summary-sig"><a href="Scientific.IO.ArrayIO-module.html#writeArray" class="summary-sig-name">writeArray</a>(<span class="summary-sig-arg">array</span>, <span class="summary-sig-arg">filename</span>, <span class="summary-sig-arg">mode</span>=<span class="summary-sig-default"><code class="variable-quote">'</code><code class="variable-string">w</code><code class="variable-quote">'</code></span>)</span><br /> Write a text representation of an array to a file.</td> <td align="right" valign="top"> </td> </tr> </table> </td> </tr> <tr> <td width="15%" align="right" valign="top" class="summary"> <span class="summary-type"> </span> </td><td class="summary"> <table width="100%" cellpadding="0" cellspacing="0" border="0"> <tr> <td><span class="summary-sig"><a href="Scientific.IO.ArrayIO-module.html#writeDataSets" class="summary-sig-name">writeDataSets</a>(<span class="summary-sig-arg">datasets</span>, <span class="summary-sig-arg">filename</span>, <span class="summary-sig-arg">separator</span>=<span class="summary-sig-default"><code class="variable-quote">'</code><code class="variable-string"></code><code class="variable-quote">'</code></span>)</span><br /> Write multiple datasets to a text file.</td> <td align="right" valign="top"> </td> </tr> </table> </td> </tr> </table> <!-- ==================== FUNCTION DETAILS ==================== --> <a name="section-FunctionDetails"></a> <table class="details" border="1" cellpadding="3" cellspacing="0" width="100%" bgcolor="white"> <tr bgcolor="#70b0f0" class="table-header"> <td align="left" colspan="2" class="table-header"> <span class="table-header">Function Details</span></td> </tr> </table> <a name="readArray"></a> <div> <table class="details" border="1" cellpadding="3" cellspacing="0" width="100%" bgcolor="white"> <tr><td> <table width="100%" cellpadding="0" cellspacing="0" border="0"> <tr valign="top"><td> <h3 class="epydoc"><span class="sig"><span class="sig-name">readArray</span>(<span class="sig-arg">filename</span>)</span> </h3> </td><td align="right" valign="top" > </td> </tr></table> <p>Read array data from a file</p> <p>This function works for arbitrary data types (every array element can be given by an arbitrary Python expression), but at the price of being slow. For large arrays, use <a href="Scientific.IO.ArrayIO-module.html#readFloatArray" class="link">readFloatArray</a> or <a href="Scientific.IO.ArrayIO-module.html#readIntegerArray" class="link">readIntegerArray</a> if possible.</p> <dl class="fields"> <dt>Parameters:</dt> <dd><ul class="nomargin-top"> <li><strong class="pname"><code>filename</code></strong> (<code>str</code>) - the name of the file to read</li> </ul></dd> <dt>Returns: <code>Numeric.array</code></dt> <dd>an array containing the data from the file</dd> </dl> </td></tr></table> </div> <a name="readFloatArray"></a> <div> <table class="details" border="1" cellpadding="3" cellspacing="0" width="100%" bgcolor="white"> <tr><td> <table width="100%" cellpadding="0" cellspacing="0" border="0"> <tr valign="top"><td> <h3 class="epydoc"><span class="sig"><span class="sig-name">readFloatArray</span>(<span class="sig-arg">filename</span>)</span> </h3> </td><td align="right" valign="top" > </td> </tr></table> <p>Read array data from a file into an array of floats</p> <dl class="fields"> <dt>Parameters:</dt> <dd><ul class="nomargin-top"> <li><strong class="pname"><code>filename</code></strong> (<code>str</code>) - the name of the file to read</li> </ul></dd> <dt>Returns: <code>Numeric.array</code> of <code>float</code></dt> <dd>an array containing the data from the file</dd> </dl> </td></tr></table> </div> <a name="readIntegerArray"></a> <div> <table class="details" border="1" cellpadding="3" cellspacing="0" width="100%" bgcolor="white"> <tr><td> <table width="100%" cellpadding="0" cellspacing="0" border="0"> <tr valign="top"><td> <h3 class="epydoc"><span class="sig"><span class="sig-name">readIntegerArray</span>(<span class="sig-arg">filename</span>)</span> </h3> </td><td align="right" valign="top" > </td> </tr></table> <p>Read array data from a file into an array of integers</p> <dl class="fields"> <dt>Parameters:</dt> <dd><ul class="nomargin-top"> <li><strong class="pname"><code>filename</code></strong> (<code>str</code>) - the name of the file to read</li> </ul></dd> <dt>Returns: <code>Numeric.array</code> of <code>int</code></dt> <dd>an array containing the data from the file</dd> </dl> </td></tr></table> </div> <a name="writeArray"></a> <div> <table class="details" border="1" cellpadding="3" cellspacing="0" width="100%" bgcolor="white"> <tr><td> <table width="100%" cellpadding="0" cellspacing="0" border="0"> <tr valign="top"><td> <h3 class="epydoc"><span class="sig"><span class="sig-name">writeArray</span>(<span class="sig-arg">array</span>, <span class="sig-arg">filename</span>, <span class="sig-arg">mode</span>=<span class="sig-default"><code class="variable-quote">'</code><code class="variable-string">w</code><code class="variable-quote">'</code></span>)</span> </h3> </td><td align="right" valign="top" > </td> </tr></table> <p>Write a text representation of an array to a file.</p> <dl class="fields"> <dt>Parameters:</dt> <dd><ul class="nomargin-top"> <li><strong class="pname"><code>array</code></strong> (<code>Numeric.array</code>) - the array to be written</li> <li><strong class="pname"><code>filename</code></strong> (<code>str</code>) - the name of the output file</li> <li><strong class="pname"><code>mode</code></strong> (<code>str</code>) - the file access mode, 'w' (new file) or 'a' (append)</li> </ul></dd> </dl> </td></tr></table> </div> <a name="writeDataSets"></a> <div> <table class="details" border="1" cellpadding="3" cellspacing="0" width="100%" bgcolor="white"> <tr><td> <table width="100%" cellpadding="0" cellspacing="0" border="0"> <tr valign="top"><td> <h3 class="epydoc"><span class="sig"><span class="sig-name">writeDataSets</span>(<span class="sig-arg">datasets</span>, <span class="sig-arg">filename</span>, <span class="sig-arg">separator</span>=<span class="sig-default"><code class="variable-quote">'</code><code class="variable-string"></code><code class="variable-quote">'</code></span>)</span> </h3> </td><td align="right" valign="top" > </td> </tr></table> <p>Write multiple datasets to a text file.</p> <dl class="fields"> <dt>Parameters:</dt> <dd><ul class="nomargin-top"> <li><strong class="pname"><code>datasets</code></strong> - a sequence of datasets describing a curve to be plotted. Each dataset is either a 1d-array (list of values) or a 2d-array of shape N x 2 (list of (x, y) pairs). Nested lists can be used instead of arrays.</li> <li><strong class="pname"><code>filename</code></strong> (<code>str</code>) - the name of the output file</li> <li><strong class="pname"><code>separator</code></strong> (<code>str</code>) - the contents of the line that is written between two datasets</li> </ul></dd> </dl> </td></tr></table> </div> <br /> <!-- ==================== NAVIGATION BAR ==================== --> <table class="navbar" border="0" width="100%" cellpadding="0" bgcolor="#a0c0ff" cellspacing="0"> <tr valign="middle"> <!-- Home link --> <th> <a href="Scientific-module.html">Home</a> </th> <!-- Tree link --> <th> <a href="module-tree.html">Trees</a> </th> <!-- Index link --> <th> <a href="identifier-index.html">Indices</a> </th> <!-- Help link --> <th> <a href="help.html">Help</a> </th> <!-- Project homepage --> <th class="navbar" align="right" width="100%"> <table border="0" cellpadding="0" cellspacing="0"> <tr><th class="navbar" align="center" ><a class="navbar" target="_top" href="http://dirac.cnrs-orleans.fr/ScientificPython/">Scientific Python</a></th> </tr></table></th> </tr> </table> <table border="0" cellpadding="0" cellspacing="0" width="100%%"> <tr> <td align="left" class="footer"> Generated by Epydoc 3.0.1 on Thu Dec 4 08:05:36 2008 </td> <td align="right" class="footer"> <a target="mainFrame" href="http://epydoc.sourceforge.net" >http://epydoc.sourceforge.net</a> </td> </tr> </table> <script type="text/javascript"> <!-- // Private objects are initially displayed (because if // javascript is turned off then we want them to be // visible); but by default, we want to hide them. So hide // them unless we have a cookie that says to show them. checkCookie(); // --> </script> </body> </html>