[Numpy-discussion] Meshgrid with Huge Arrays

Nadav Horesh nadavh@visionsense....
Thu Oct 7 01:10:17 CDT 2010


You should avoid meshgrid, as the follows:

...

#3D ARRAY
XArray = np.arange(0, NrHorPixels, 1./sqrt(NrCellsPerPixel))
YArray = np.arange(0, NrVerPixels, 1./sqrt(NrCellsPerPixel))
Z = Amplitude*exp(-(((XArray-GaussianCenterX)**2/(2*SigmaX**2))+((YArray[:,None]-GaussianCenterY)**/(2*SigmaY**2))))
#  Note this                                                              ^
#                                                                         |

   Nadav


-----Original Message-----
From: numpy-discussion-bounces@scipy.org on behalf of sicre
Sent: Thu 07-Oct-10 06:19
To: numpy-discussion@scipy.org
Subject: [Numpy-discussion]  Meshgrid with Huge Arrays
 

I do not have good programming skills, I am trying to create a 2048x2048 3D
pixel array where each pixel has 100 cells.
I am using meshgrid in order to create a 3D array, then adding a gaussian
function to the entire array centered in (1024,1024). I am having three
types of errors:

#FIRST ERROR:
File "/home/sicre/PHASES/Examples/test.py", line 18, in <module>
    XArray, YArray = np.meshgrid(XArray, YArray)
  File "/usr/lib/python2.6/dist-packages/numpy/lib/function_base.py", line
2931, in meshgrid
    X = x.repeat(numRows, axis=0)
ValueError: dimensions too large.

#SECOND ERROR (choosing instead NrCellsPerPixel=36)
Traceback (most recent call last):
  File "/home/sicre/PHASES/Examples/test.py", line 19, in <module>
    Z = np.zeros([len(XArray),len(YArray)])
MemoryError

"from pylab import *
import numpy as np

#VARIABLES
NrHorPixels=2048
NrVerPixels=2048
NrCellsPerPixel=100
GaussianCenterX=1024
GaussianCenterY=1024
SigmaX=1
SigmaY=1
Amplitude = 150


#Z = rand(len(XArray),len(YArray))

#Plot
#pcolormesh(Z)
#colorbar()"

For sure there are better solutions for what i am trying to do. Can anyone
figure it out? I would appreciate it very much, i've been searching a
solution/answer for days.
-- 
View this message in context: http://old.nabble.com/Meshgrid-with-Huge-Arrays-tp29902859p29902859.html
Sent from the Numpy-discussion mailing list archive at Nabble.com.

_______________________________________________
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/ms-tnef
Size: 3706 bytes
Desc: not available
Url : http://mail.scipy.org/pipermail/numpy-discussion/attachments/20101007/96c88158/attachment.bin 


More information about the NumPy-Discussion mailing list