I am trying to get 3d radiation pattern according to my data. I also use Matlab Antenna Toolbox. I have 2 different result. I accept the matlab's result as true.
import os
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from matplotlib import cm
os.getcwd()
os.listdir()
raw_data = pd.read_excel("data.xlsx")
raw_data.drop(0, inplace=True)
theta_values = raw_data["Theta [deg,]"].values.tolist()
phi_values = raw_data["Phi [deg,]"].values.tolist()
dbi_values = raw_data["Abs(Grlz)[dBi ]"].values.tolist()
theta_array = np.array(theta_values)
phi_array = np.array(phi_values)
dbi_array = np.array(dbi_values)
theta2d = theta_array.reshape([72,37])
phi2d = phi_array.reshape([72,37])
dbi2d = dbi_array.reshape([72,37])
theta = np.deg2rad(theta2d)
phi = np.deg2rad(phi2d)
dbi2d_max = np.max(dbi2d)
n = dbi2d/dbi2d_max
X = n*np.sin(theta)*np.cos(phi)
Y = n*np.sin(theta)*np.sin(phi)
Z = n*np.cos(theta)
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
ax.grid(True)
ax.axis('on')
ax.set_xlabel('X')
ax.set_ylabel('Y')
ax.set_zlabel('Z')
my_col = cm.jet(n)
c = cm.ScalarMappable(cmap=cm.jet)
c.set_array(dbi2d)
fig.colorbar(c, shrink=1)
ax.plot_surface(X, Y, Z, facecolors=my_col, rstride=1, cstride=1,
linewidth=0.5, antialiased=True, alpha=0.5, zorder=0.5)
def draw_circle(theta2, phi2, r=1.1):
THETA2, PHI2 = np.meshgrid(theta2, phi2)
X2 = r * np.sin(THETA2) * np.cos(PHI2)
Y2 = r * np.sin(THETA2) * np.sin(PHI2)
Z2 = r * np.cos(THETA2)
ax.plot_wireframe(X2, Y2, Z2, linewidth=0.5, rstride=20, cstride=20)
draw_circle(np.pi / 2, np.arange(0, 2 * np.pi, np.pi / 180))
draw_circle(np.arange(0, 2 * np.pi, np.pi / 180), 0)
draw_circle(np.arange(0, 2 * np.pi, np.pi / 180), 90)
plt.show()
Python result according to the code: Python Result
The result i expected according to Matlab Antenna Toolbox: Matlab Result
Aucun commentaire:
Enregistrer un commentaire