[Numpy-discussion] how-to "put" RAM-based numarray into memmap

Chris Barker Chris.Barker at noaa.gov
Fri Nov 21 09:31:06 EST 2003


Sebastian Haase wrote:
> 
> Hi,
> Suppose I have a 500MB-ram Computer and a 300MB ram-only (standard)
> numarray.
> Now I would like to "save" that onto harddrive (with a small header up
> front

How about:

f = open(filename, 'wb')
f.write(MyHeader)
A.tofile(f)

To read it back in, you need to know where your header ends, by either
parsing it or using one of the same size every time, then you can use
fromfile() to create an array form it.

NOTE: I havn't actaully done this myself, but I've done something bvery
similar with fromstring and tostring with Numeric. I'm very happy that
Numarray has the *file methods, as they don't require an extra copy in
memory.

-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

Chris.Barker at noaa.gov




More information about the NumPy-Discussion mailing list