Я пытаюсь построить график в matplotlib, используя numpy и meshgrid.
Я хочу сделать область в центре массива заполненной нулями и единицами. Я попытался настроить массив, но цикл for, кажется, никогда не входит (операторы print не печатают внутри для циклов). Есть указатели?
import numpy as np
import pylab as py
from scipy import *
from numpy.fft import fft
import mpl_toolkits.mplot3d.axes3d as p3
def fft2dplot(
type = 'rect', aperature = 16, method = 'transfer',
wavelength = 1, distance = 1000000):
dict = {
'rect' : 'Rectangle', 'circ' : 'Circle',
'transfer' : 'Tranfer Function', 'integral' : 'Integral'}
#Scale is not correct
scale = aperature/(distance*wavelength) #in mm
#Range for aperature,
x = y = arange(-aperature*8,aperature*8, 1)
X,Y = np.meshgrid(x,y)
print len(X)
X = Y = Z = X*0
#These following statements never enter (type == rect passes, but for loop don't)
if type == 'rect':
for u in x[-aperature/2:aperature/2]:
for w in y[-aperature/2:aperature/2]:
Z[u,w] = 1
print "I'm here"
fig = py.figure()
ax = p3.Axes3D(fig)
#ax.contour3D(X,Y,Z)
ax.plot_wireframe(X, Y, Z, rstride=1, cstride=1)
ax.set_xlabel('X')
ax.set_ylabel('Y')
ax.set_zlabel('Z')
py.show()