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: [email protected] on behalf of sicre Sent: Thu 07-Oct-10 06:19 To: [email protected] 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 [email protected] http://mail.scipy.org/mailman/listinfo/numpy-discussion
<<winmail.dat>>
_______________________________________________ NumPy-Discussion mailing list [email protected] http://mail.scipy.org/mailman/listinfo/numpy-discussion
