[Numpy-discussion] Meshgrid with Huge Arrays
sicre
hugogilsilva at gmail.com
Thu Oct 7 00:19:08 EDT 2010
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
#3D ARRAY
XArray = np.arange(0, NrHorPixels, 1./sqrt(NrCellsPerPixel))
YArray = np.arange(0, NrVerPixels, 1./sqrt(NrCellsPerPixel))
XArray, YArray = np.meshgrid(XArray, YArray)
Z = np.zeros([len(XArray),len(YArray)])
#Z = np.zeros((len(XArray),len(YArray)),dtype=int16)
#Add Gaussian to Array
Z =
Z+Amplitude*e**-(((XArray-GaussianCenterX)**2/(2*SigmaX**2))+((YArray-GaussianCenterY)**/(2*SigmaY**2)))
#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.
More information about the NumPy-Discussion
mailing list