<br><br><div class="gmail_quote">On Sun, Nov 16, 2008 at 10:37 PM, Catherine Moroney <span dir="ltr"><<a href="mailto:catherine.m.moroney@jpl.nasa.gov">catherine.m.moroney@jpl.nasa.gov</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hello,<br>
<br>
I'm having problems writing a 2-dimensional numpy array out to a binary<br>
file using the "tofile" method.  The call to "tofile" appears to<br>
succeed,<br>
but when I check the length of the binary file I find that it's longer<br>
than what is expected, given the calculation of nrows*ncolumns*nbytes.<br>
</blockquote><div><br>You might find the following attributes useful in debugging this.<br><br><span style="font-family: courier new,monospace;">In [1]: x = ones((2,2))</span><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">In [2]: x.size</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">Out[2]: 4</span><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">In [3]: x.itemsize</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">Out[3]: 8</span><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">In [4]: x.nbytes</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">Out[4]: 32</span><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">In [5]: x.dtype</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">Out[5]: dtype('float64')</span><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">In [6]: x.tofile('foo.dat')</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">In [7]: ls -l foo.dat</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">-rw-rw-r-- 1 charris charris 32 2008-11-16 22:43 foo.da</span>t<br>
 <br></div><div>The file should have the same size as x.nbytes. What operating system are you using?<br><br>Chuck <br></div><br></div><br>