Works for me on Windows 7 64 bit with 32 bit Python. I believe you
simply run out of memory. On a 32 bit Windows OS, Python can only use 2
GB, which it has to share with other all processes.
zeros((300,300,300,4),dtype=float64) requires ~820MB of contiguous
memory, which might not be available even if you have >1 GB free RAM.
Better use a 64 bit OS and Python.
Christoph
On 1/14/2011 11:40 AM, sprobst wrote:
>
> Hi all,
>
> I tried to plot parts of a large 3D array with each 4 float64 entries.
> Loading the array with numpy.fromfile and performing a type conversion
> afterwards ends up in a MemoryError.
>
> The following code reproduces the error:
> ***********************************
> import gc
>
> from os import path
> from numpy import zeros, empty, float32, float64, fromfile
>
> # With the imports of the next three lines a memory error occurs
> #import matplotlib
> #matplotlib.use("AGG")
> #import matplotlib.pylab as plt
>
> _filename = "mt.dat"
>
> if (path.exists(_filename)==False):
> print "Write file ..."
> _mtf = file(_filename, "wb")
> _mtd = zeros( (300,300,300,4),dtype=float64)
> _mtd.tofile(_mtf)
> _mtf.close()
>
> _mtd = empty((0))
> gc.collect();
>
> print "Try to read file ..."
>
> _mtf = file(_filename, "rb")
> # The memory error occurs with the type conversion to float 64,
> # but only if mathplotlib is imported!
> _mtd = fromfile(_mtf,float64).astype(float32)
> _mtf.close()
>
> print "Successful read:",_mtd.shape
>
> # Here some plot stuff would be :)
> ***********************************
>
> If the import of matplotlib is not included, no error occures otherwise it
> will not work. Perhaps anybody can help me (I tested it only on a Windows XP
> 32Bit).
>
> Best regards and thank you
> Stefan
------------------------------------------------------------------------------
Protect Your Site and Customers from Malware Attacks
Learn about various malware tactics and how to avoid them. Understand
malware threats, the impact they can have on your business, and how you
can protect your company and customers by using code signing.
http://p.sf.net/sfu/oracle-sfdevnl
_______________________________________________
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users