Xavier Gnata wrote:
> Hi,
>
> How can I save (and relaod) a matrix into a binary file *with* matrix
> shape and type storage.
> I have a feature request :
> Basically, it would be great to be able to do something like :
>
> X = rand(100,100)
> BSave('foo.dat', X)
> Y = BLoad('foo.dat')
I don't know of an existing function that does this, but it would not be
hard to roll your own. All you need to do is first write the dimensions
and type of the array to the file, then the binary data. To read it back
in, you'd first read in the meta data, then the binary data, and you're
done.
I've enclosed a quickie prototype (using Numeric, I think numarray may
have tofile() and fromfile() methods, and it handles typecode differently.
By the way, there may be something in SciPy for this, and it's also
possible that arrays can be pickled.
This is also a better question for the NumPy list than this list.
-Chris
--
Christopher Barker, Ph.D.
Oceanographer
NOAA/OR&R/HAZMAT (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception
Chr...@no...
|