[Numpy-discussion] Meshgrid with Huge Arrays

sicre hugogilsilva@gmail....
Fri Oct 8 13:10:56 CDT 2010


My program works with
NrHorPixels=10
NrVerPixels=10
NrCellsPerPixel=16

but not with
NrHorPixels=2048
NrVerPixels=2048
NrCellsPerPixel=100

The problem is in the variable Z definition and in the meshgrid, getting
MemoryError and ValueError: dimensions too large.
Is there any solution to avoid such huge arrays since I have 3GB 32bit?

CODE:
"
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt
import numpy as np
from pylab import *

#VARIABLES
NrHorPixels=10
NrVerPixels=10
NrCellsPerPixel=16
GaussianCenterX=5
GaussianCenterY=5
SigmaX=1
SigmaY=1
Amplitude = 150

#3D ARRAY
XArray = np.arange(0, NrHorPixels, 1./sqrt(NrCellsPerPixel),dtype=float32)
YArray = np.arange(0, NrVerPixels, 1./sqrt(NrCellsPerPixel),dtype=float32)
XArray, YArray = np.meshgrid(XArray, YArray)
Z = np.zeros([len(XArray),len(YArray)])

#Add Gaussian to Array
Z =
Z+Amplitude*e**-(((XArray-GaussianCenterX)**2/(2*SigmaX**2))+((YArray-GaussianCenterY)**2/(2*SigmaY**2)))

#Plot 3D
fig = plt.figure()
ax = Axes3D(fig)
ax.plot_surface(XArray, YArray, Z, rstride=1, cstride=1, cmap=cm.jet)
plt.show()
##Plot Heatmap
##pcolormesh(Z)
##colorbar()
##show()
"

-- 
View this message in context: http://old.nabble.com/Meshgrid-with-Huge-Arrays-tp29902859p29917035.html
Sent from the Numpy-discussion mailing list archive at Nabble.com.



More information about the NumPy-Discussion mailing list