I have to plot antenna response pattern in a spherical polar plot.
I first create the theta(t) and phi(p) values. Then there is F_c and F_s that has to calculated for each theta[i] and phi[i].
t=np.linspace(-math.pi/2, math.pi/2, num=x)
p=np.linspace(-math.pi, math.pi, num=x)
for k in xrange(x):
for j in xrange(x):
for i in xrange(n):
F_c=F_c_F_s.F_c(theta[i],phi[i],t[j],p[k])
F_s=F_c_F_s.F_s(theta[i],phi[i],t[j],p[k])
sum_F_c[j][k]=sum_F_c[j][k]+F_c
sum_F_s[j][k]=sum_F_s[j][k]+F_s
mod_F[j][k]=math.log((math.pow(sum_F_c[j][k],2)+math.pow(sum_F_s[j][k],2)),10)
Now we have a value of mod_F for each t and p. For each value of theta and correspondingly for each value of phi I calculate Cartesian coordinates. Then to make the surface plot I have the following:
fig = p.figure()
ax = Axes3D(fig)
ax.plot_wireframe(x,y,z)
ax.plot_surface(x,y,z,rstride=1,cstride=1,cmap=cm.jet)
p.show()
The problem is, it is incredibly slow! Even for x=10 i.e. a 10 x 10 grid, it take a lot of time. Is there a way to do this in better and faster manner?
F_candF_s. It might be possible to vectorize that triple loop. - ev-brF_candF_sare two components of the pattern. I have to calculate both for alliand sum them. Finally I need thelogof sum of squares of (these summed over i)F_candF_s. The slower part of the code is the plotting part. - Devansh Agarwal