sriyakotta/PA_Antenna_Program
0
1import os2os.system("pip install matplotlib")3os.system("pip install scipy")4 5import streamlit as st6import math7import numpy as np8import pandas as pd9import matplotlib.pyplot as plt10from scipy.special import jv11from scipy.signal import find_peaks12 13# Radiating Element Dictionary14radiating_element_dict = {15 "High-efficiency Multimode Horn": 63,16 "Potter Horn": 70,17 "Corrugated Horn": 75,18 "Cup-dipole Radiating Element": 58,19 "Dominant-mode Square Horn": 55,20 "High-efficiency Square/Rectangular Horn": 52,21 "Patch": 58,22 "Dipole": 5823}24 25# Function to calculate scan loss26def calc_scan_loss(max_sm, spacing, radiating_element):27 if spacing < 1:28 scan_loss = -10 * math.log10((math.cos(math.radians(max_sm)))**1.5)29 else:30 half_power_beamwidth = radiating_element * (1 / spacing)31 scan_loss = 3 * (max_sm / (0.5 * half_power_beamwidth))**232 return scan_loss33 34# Function to calculate phased array antenna design35def calculate_antenna_design(frequency, max_sm, gain, element_efficiency, T_illumination,36 illimination_taper_loss, antenna_loss, gain_loss, loss_beam_diameter,37 implementation_margin, radiating_element_name):38 39 frequency = float(frequency)40 max_sm = float(max_sm)41 gain = float(gain)42 element_efficiency = float(element_efficiency)43 T_illumination = float(T_illumination)44 illimination_taper_loss = float(illimination_taper_loss)45 antenna_loss = float(antenna_loss)46 gain_loss = float(gain_loss)47 loss_beam_diameter = float(loss_beam_diameter)48 implementation_margin = float(implementation_margin)49 pi = np.pi50 radiating_element = radiating_element_dict.get(radiating_element_name, 0)51 52 # Wavelength calculation53 wavelength = 0.299792458 / frequency54 meters_to_in = 39.3755 56 # Array Efficiency Calculation57 T = 10 ** (T_illumination / 20)58 array_efficiency = 75 * ((1 + T) ** 2 / (1 + T + T ** 2))59 60 # Required directivity at boresight61 additional_loss = (illimination_taper_loss + antenna_loss + gain_loss +62 loss_beam_diameter + implementation_margin)63 directivity_boresight = (gain + additional_loss) / (array_efficiency * 0.01)64 65 # Directivity Calculation66 D = (10 ** (directivity_boresight / 10)) / 0.967 D = math.sqrt(D) / pi * wavelength68 69 # Beamwidth70 theta_3db = radiating_element * (wavelength / D)71 theta3atScanEdge = theta_3db/(math.sqrt(np.cos(np.radians(max_sm))**1.2))72 73 grating_lobe_calculated = max_sm + 1.5*theta3atScanEdge74 if grating_lobe_calculated > 90:75 grating_lobe = 9076 grating_lobe_limited = True77 else:78 grating_lobe = grating_lobe_calculated79 grating_lobe_limited = False80 81 #Calculating spacing, element directivity, and scan loss82 square_spacing = 1/ ((math.sin(math.radians(max_sm)))+(math.sin(math.radians(grating_lobe))))83 hexagon_spacing = 1.1547/ ((math.sin(math.radians(max_sm)))+(math.sin(math.radians(grating_lobe))))84 square_spacing_meters = square_spacing * wavelength85 hexagon_spacing_meters = hexagon_spacing * wavelength86 square_spacing_in = square_spacing_meters * meters_to_in87 hexagon_spacing_in = hexagon_spacing_meters * meters_to_in88 89 element_directivity_square = 10*math.log10(0.01*element_efficiency*4*pi*(square_spacing**2))90 element_directivity_hexagon = 10*math.log10(0.01*element_efficiency*4*pi*(hexagon_spacing**2))91 92 scan_loss_sq = calc_scan_loss(max_sm, square_spacing, radiating_element)93 scan_loss_hx = calc_scan_loss(max_sm, hexagon_spacing, radiating_element)94 95 #calculating directivity from user inputed gain96 additional_loss = illimination_taper_loss + antenna_loss + gain_loss + loss_beam_diameter + implementation_margin97 directivity_sq = (gain + additional_loss + scan_loss_sq) / (array_efficiency*0.01)98 directivity_hx = (gain + additional_loss + scan_loss_hx) / (array_efficiency*0.01)99 100 #calculating number of elements101 Num_elements_square = 10**(0.1*directivity_sq - 0.1*element_directivity_square)102 Num_elements_hexagon = 10**(0.1*directivity_hx - 0.1*element_directivity_hexagon)103 104 #calculating directivity based on Number of elements105 d1 = (0.01 * array_efficiency) * (math.ceil(Num_elements_square)) * (0.01*element_efficiency*4*pi*(square_spacing**2))106 D_p_square = 10* math.log10(d1)107 D_p_square_sm = D_p_square - scan_loss_sq108 109 d2 = (0.01 * array_efficiency) * (math.ceil(Num_elements_hexagon)) * (0.01*element_efficiency*4*pi*(hexagon_spacing**2))110 D_p_hexagon = 10* math.log10(d2)111 D_p_hexagon_sm = D_p_hexagon - scan_loss_hx112 113 #Calculating boresight grating lobe location114 if 1/square_spacing < 1:115 boresight_grating_lobe_sq = np.degrees(np.arcsin(1/square_spacing))116 else:117 boresight_grating_lobe_sq = 90118 119 scan_angle_grating_lobe_sq = np.degrees(np.arcsin(1 / square_spacing - np.sin(np.radians(max_sm))))120 121 122 if 1.1547/hexagon_spacing < 1.1547:123 boresight_grating_lobe_hx = np.degrees(np.arcsin(1.1547/hexagon_spacing))124 else:125 boresight_grating_lobe_hx = 90126 127 scan_angle_grating_lobe_hx = np.degrees(np.arcsin(1.1547 / hexagon_spacing - np.sin(np.radians(max_sm))))128 129 130 131 # Creating DataFrames132 input_table = pd.DataFrame([133 ('Wavelength (mm)', round(wavelength * 1000, 2)),134 ('Maximum Scan Angle (°)', round(max_sm, 2)),135 ('Grating Lobe Location (°)', round(grating_lobe_calculated, 2)),136 ('Desired Max Gain (dBi)', gain),137 ('Required Peak Directivity (dBi)', round(directivity_boresight, 2)),138 ('Array Efficiency (%)', round(array_efficiency, 2))139 ], columns=["Parameter", "Value"])140 141 142 def peaks_sinc(sinc_function, peak_directivity):143 peaks, _ = find_peaks(sinc_function)144 for i in range(len(peaks)):145 if sinc_function[peaks[i]] == peak_directivity:146 side_lobe_location = in_array[peaks[i+1]]147 side_lobe_level_dbi = sinc_function[peaks[i+1]]148 side_lobe_level = -1*(peak_directivity - side_lobe_level_dbi)149 break150 return side_lobe_location, side_lobe_level151 152 def peaks_bessel(bessel_function, peak_directivity):153 peaks, _ = find_peaks(bessel_function)154 for i in range(len(peaks)-1):155 if round(bessel_function[peaks[i]],2) == round(bessel_function[peaks[i+1]],2):156 side_lobe_location = in_array[peaks[i+1]]157 side_lobe_level_dbi = bessel_function[peaks[i+1]]158 side_lobe_level = -1* (peak_directivity - side_lobe_level_dbi)159 break160 return side_lobe_location, side_lobe_level161 162 #Creating directivity pattern163 num_elements_square_x = math.ceil(math.sqrt(Num_elements_square))164 num_elements_hexagon_x = math.ceil(math.sqrt(Num_elements_hexagon))165 L_sq= num_elements_square_x*square_spacing166 L_hx= num_elements_hexagon_x*hexagon_spacing167 plot_angle=50168 smooth_f=10169 in_array = np.linspace(-plot_angle, plot_angle, 2*plot_angle*smooth_f+1)170 t = 3.14*(in_array/180)171 172 sinc_sq = D_p_square + 10*np.log10((np.sinc(L_sq*t))**2)173 sinc_hx = D_p_hexagon + 10*np.log10((np.sinc(L_hx*t))**2)174 175 bessel_trail_sq = pi*L_sq*np.sin(t)176 bessel_sq = D_p_square + 10*np.log10(( 2*jv(1, bessel_trail_sq) / bessel_trail_sq )**2)177 178 bessel_trail_hx = pi*L_hx*np.sin(t)179 bessel_hx = D_p_hexagon + 10*np.log10(( 2*jv(1, bessel_trail_hx) / bessel_trail_hx )**2)180 181 sl_loc_sinc_sq, sl_lev_sinc_sq = peaks_sinc(sinc_sq, D_p_square)182 sl_loc_sinc_hx, sl_lev_sinc_hx = peaks_sinc(sinc_hx, D_p_hexagon)183 sl_loc_bess_sq, sl_lev_bess_sq = peaks_bessel(bessel_sq, D_p_square)184 sl_loc_bess_hx, sl_lev_bess_hx = peaks_bessel(bessel_hx, D_p_hexagon)185 186 # Design Table187 design_table = pd.DataFrame([188 ('Element Spacing (d/λ)', round(square_spacing, 2), round(hexagon_spacing, 2)),189 ('Element Spacing (mm)', round(1000 * square_spacing_meters, 2), round(1000 * hexagon_spacing_meters, 2)),190 ('Element Spacing (in)', round(square_spacing_in, 2), round(hexagon_spacing_in, 2)),191 ('Element Directivity (dBi)', round(element_directivity_square, 2), round(element_directivity_hexagon, 2)),192 ('Number of Elements', math.ceil(Num_elements_square), math.ceil(Num_elements_hexagon)),193 ('Peak Directivity (dBi)', round(D_p_square, 2), round(D_p_hexagon, 2)),194 ("Directivity at " + str(max_sm) + "° (dBi)", round(D_p_square_sm, 2), round(D_p_hexagon_sm, 2)),195 ('Half Power Beamwidth', round(theta_3db, 2), round(theta_3db, 2)),196 ('Grating Lobe Location at Boresight (°)', round(boresight_grating_lobe_sq, 2), round(boresight_grating_lobe_hx, 2)),197 ('Grating Lobe Location at scan angle (°)', round(scan_angle_grating_lobe_sq, 2), round(scan_angle_grating_lobe_hx, 2))198 ], columns=["Parameter", "Square Lattice", "Hexagon Lattice"])199 200 # Sidelobe Data Table201 sidelobe_table = pd.DataFrame([202 ('Square Aperture: Sidelobe Location (°)', round(sl_loc_sinc_sq, 2), round(sl_loc_sinc_hx, 2)),203 ('Square Aperture: Sidelobe Level Relative to Main Beam (dB)', round(sl_lev_sinc_sq, 2), round(sl_lev_sinc_hx, 2)),204 ('Circular Aperture: Sidelobe Location (°)', round(sl_loc_bess_sq, 2), round(sl_loc_bess_hx, 2)),205 ('Circular Aperture: Sidelobe Level Relative to Main Beam (dB)', round(sl_lev_bess_sq, 2), round(sl_lev_bess_hx, 2))206 ], columns=["Parameter", "Square Lattice", "Hexagon Lattice"])207 208 def directivity_pattern(in_array, y_output, plot_title):209 fig, ax = plt.subplots(figsize=(5, 4))210 ax.plot(in_array, y_output)211 ax.set_xlabel('θ')212 ax.set_ylabel('Directivity (dBi)')213 ax.set_title(plot_title)214 return fig215 216 plot1 = directivity_pattern(in_array, sinc_sq, 'Square Lattice (Square Aperture)')217 plot2 = directivity_pattern(in_array, sinc_hx, 'Hexagon Lattice (Square Aperture)')218 plot3 = directivity_pattern(in_array, bessel_sq, 'Square Lattice (Circular Aperture)')219 plot4 = directivity_pattern(in_array, bessel_hx, 'Hexagon Lattice (Circular Aperture)')220 221 def plot_square_lattice(num_elements_square_x, square_spacing_in, plot_title):222 w = np.zeros(num_elements_square_x)223 for i in range(num_elements_square_x):224 w[i] = i * square_spacing_in225 226 x = np.repeat(w, num_elements_square_x)227 y = np.tile(w, num_elements_square_x)228 229 fig, ax = plt.subplots(figsize=(4, 3.75))230 ax.set_aspect('equal')231 for i in range(num_elements_square_x**2):232 circle = plt.Circle((x[i], y[i]), radius=square_spacing_in/2, fill=True)233 ax.add_patch(circle)234 ax.scatter(x, y)235 ax.set_xlabel('Element Spacing (in)')236 ax.set_ylabel('Element Spacing (in)')237 ax.set_title(plot_title)238 ax.set_ylim([-square_spacing_in, num_elements_square_x * square_spacing_in])239 return fig240 241 242 def plot_hexagonal_lattice(Num_elements_hexagon, hexagon_spacing_in, plot_title):243 depth = 0244 total = 1245 for i in range(0, int(Num_elements_hexagon)):246 total = total + 6 * i247 depth = depth + 1248 i += total249 if total >= Num_elements_hexagon:250 break251 252 def hexit_60(n_max):253 pairs = []254 if n_max >= 0:255 pairs.append(np.zeros(2, dtype=int)[:, None])256 if n_max >= 1:257 seq = [1, 0, -1]258 p0 = np.hstack((seq, seq[::-1]))259 N = len(p0)260 p1 = np.hstack((p0[N-2:], p0[:N-2]))261 pairs.append(np.stack((p0, p1), axis=0))262 for n in range(2, n_max+1):263 seq = np.arange(n, -n-1, -1, dtype=int)264 p0 = np.hstack((seq, (n-1)*[-n], seq[::-1], (n-1)*[n]))265 N = len(p0)266 p1 = np.hstack((p0[N-2*n:], p0[:N-2*n]))267 pairs.append(np.stack((p0, p1), axis=0))268 if len(pairs) > 0:269 pairs = np.hstack(pairs)270 else:271 pairs = None272 return pairs273 274 def get_points(a, n_max):275 vecs = a * np.array([[1.0, 0.0], [0.5, 0.5*np.sqrt(3)]])276 pairs = hexit_60(n_max=n_max)277 if isinstance(pairs, np.ndarray):278 points = (pairs[:, None] * vecs[..., None]).sum(axis=0)279 else:280 points = None281 return points282 283 fig, ax = plt.subplots(figsize=(4, 3.75))284 ax.set_aspect('equal')285 ax.set_title(plot_title)286 ax.set_ylabel("Element Spacing (in)")287 ax.set_xlabel('Element Spacing (in)')288 ax.set_ylim([-depth * hexagon_spacing_in, depth * hexagon_spacing_in])289 ax.set_xlim([-depth * hexagon_spacing_in, depth * hexagon_spacing_in])290 291 points = get_points(a=hexagon_spacing_in, n_max=depth-1)292 if isinstance(points, np.ndarray):293 x, y = points294 ax.scatter(x, y)295 for i in range(total):296 circle = plt.Circle((x[i], y[i]), radius=hexagon_spacing_in/2, fill=True)297 ax.add_patch(circle)298 return fig299 300 square_lattice = plot_square_lattice(num_elements_square_x, square_spacing_in, 'Square Lattice Configuration')301 hexagon_lattice = plot_hexagonal_lattice(Num_elements_hexagon, hexagon_spacing_in, 'Hexagon Lattice Configuration')302 303 304 def num_elements_vs_directivity_graph(num_elements,spacing, element_efficiency, scan_loss, lattice_name):305 in_array = np.linspace(num_elements * 0.5, num_elements * 1.5)306 y = 10 * np.log10(in_array) + 10 * np.log10(0.01 * element_efficiency * 4 * np.pi * (spacing**2))307 y_scan_angle = y - scan_loss308 309 fig, ax = plt.subplots(figsize=(5, 4))310 ax.plot(in_array, y, label="Directivity: Boresight")311 ax.plot(in_array, y_scan_angle, label="Directivity: Scan Angle")312 ax.set_xlabel("Number of Elements")313 ax.set_ylabel("Directivity (dBi)")314 ax.set_title(lattice_name + ": Element Spacing (d/λ) = " + str(round(spacing, 2)))315 ax.legend()316 return fig 317 318 num_elements_directivity_sqaure = num_elements_vs_directivity_graph(Num_elements_square, square_spacing, element_efficiency, scan_loss_sq, 'Square Lattice')319 num_elements_directivity_hexagon = num_elements_vs_directivity_graph(Num_elements_hexagon, hexagon_spacing, element_efficiency, scan_loss_hx, 'Hexagon Lattice')320 321 # Function to plot Directivity and Grating Lobe Graph322 def directivity_gratinglobe_graph(graph_title, spacing, num_elements, radiating_element, spacing_constant, col_number, col_span):323 x = np.linspace(0.7 * spacing, 1.3 * spacing)324 325 boresight_directivity = 10 * np.log10(num_elements) + 10 * np.log10(0.01 * element_efficiency * 4 * pi * x**2)326 327 if spacing < 1:328 scan_angle_directivity = boresight_directivity - (-1 * 10 * np.log10((np.cos(np.radians(max_sm))) ** 1.5))329 else:330 scan_angle_directivity = boresight_directivity - 3 * (max_sm / (0.5 * radiating_element * (1.0 / x))) ** 2331 332 color_directivity = "#1f77b4"333 color_grating_lobe = "#ff7f0e"334 335 # Grating lobe calculations336 boresight_grating_lobe = np.full_like(x, 90.0)337 mask = x > spacing_constant338 boresight_grating_lobe[mask] = np.degrees(np.arcsin(spacing_constant / x[mask]))339 340 scan_angle_grating_lobe = spacing_constant / x - np.sin(np.radians(max_sm))341 with np.errstate(invalid='ignore'):342 scan_angle_grating_lobe = np.degrees(np.arcsin(scan_angle_grating_lobe))343 scan_angle_grating_lobe = np.where(np.isfinite(scan_angle_grating_lobe), scan_angle_grating_lobe, 90)344 345 346 fig, ax1 = plt.subplots(figsize=(3, 2.500))347 ax1.tick_params(axis='both', labelsize=8)348 fig.tight_layout()349 350 ax1.plot(x, boresight_directivity, label="Boresight", color=color_directivity)351 ax1.plot(x, scan_angle_directivity, '--', label=f"{max_sm}° Scan", color=color_directivity)352 ax1.set_title(graph_title, fontsize = 8)353 ax1.set_xlabel("Element Spacing (d/λ)", fontsize = 8)354 ax1.set_ylabel("Directivity (dBi)", color=color_directivity, fontsize = 8)355 ax1.tick_params(axis="y", labelcolor=color_directivity)356 ax1.legend(loc="upper left", fontsize=6)357 358 ax2 = ax1.twinx()359 ax2.plot(x, boresight_grating_lobe, label="Boresight", color=color_grating_lobe)360 ax2.plot(x, scan_angle_grating_lobe, '--', label=f"{max_sm}° Scan", color=color_grating_lobe)361 ax2.set_ylabel("Grating Lobe Location (°)", color=color_grating_lobe, fontsize = 8)362 ax2.tick_params(axis="y", labelcolor=color_grating_lobe, labelsize=8)363 ax2.legend(loc="upper right", fontsize=6)364 365 fig.tight_layout() 366 367 return fig368 369 directivity_gratinglobe_square = directivity_gratinglobe_graph("Square Lattice", square_spacing, Num_elements_square, radiating_element, 1, max_sm, element_efficiency)370 directivity_gratinglobe_hexagon = directivity_gratinglobe_graph("Hexagonal Lattice", hexagon_spacing, Num_elements_hexagon, radiating_element, 1.1547, max_sm, element_efficiency)371 372 def efficiency_vs_taper_graph():373 x = np.linspace(1, 20)374 x_1 = 10 ** (-x / 20)375 array_efficiency_output = 75 * ((1 + x_1)**2 / (1 + x_1 + x_1**2))376 377 fig, ax = plt.subplots(figsize=(5, 4))378 ax.plot(x, array_efficiency_output)379 ax.set_xlabel("Illumination Taper (dB)")380 ax.set_ylabel("Efficiency (%)")381 ax.set_title("Efficiency vs Illumination Taper")382 383 return fig384 385 efficiency_vs_taper = efficiency_vs_taper_graph()386 387 388 def normalized_gain_patterns(t, num_elements, spacing):389 lambda_D = num_elements * spacing390 theta_3 = (0.58 * t**2 + 0.171 * t + 58.44) / lambda_D391 sidelobe_levels = -0.037 * t**2 - 0.376 * t - 17.6392 e = np.e393 x = np.linspace(0, 90, 9000)394 y_1 = 10 * np.log10(e ** ((np.log(0.5) * ((x * 2 / theta_3) ** 2))))395 396 for i in range(len(y_1)):397 if round(y_1[i]) < sidelobe_levels:398 theta_SLL = x[i]399 break400 401 for i in range(len(y_1)):402 if round(y_1[i]) < -3:403 three_db = x[i] * 2404 value = y_1[i]405 break406 407 x_1 = np.linspace(0, theta_SLL)408 x_2 = np.linspace(theta_SLL, 3 * theta_SLL)409 x_3 = np.linspace(3 * theta_SLL, 5 * theta_SLL)410 411 y_1 = 10 * np.log10(e ** ((np.log(0.5) * ((x_1 * 2 / theta_3) ** 2))))412 y_2 = x_2 * 0 + sidelobe_levels413 y_3 = sidelobe_levels - 20 * np.log10((x_3 / (3 * theta_SLL)))414 415 fig, ax = plt.subplots(figsize=(5, 4))416 ax.plot(x_1, y_1, label=f'T = {t}')417 ax.plot(x_2, y_2)418 ax.plot(x_3, y_3)419 ax.set_xlabel('θ')420 ax.set_ylabel('Normalized Gain (dBi)')421 ax.set_title(f'Normalized Gain Pattern for T = {t}')422 ax.legend()423 424 return fig425 426 gain_pattern_0 = normalized_gain_patterns(0, num_elements_square_x, square_spacing)427 gain_pattern_5 = normalized_gain_patterns(5, num_elements_square_x, square_spacing)428 gain_pattern_10 = normalized_gain_patterns(10, num_elements_square_x, square_spacing)429 if num_elements_square_x * square_spacing > 6:430 gain_pattern_last = normalized_gain_patterns(20, num_elements_square_x, square_spacing)431 else:432 gain_pattern_last = normalized_gain_patterns(10, Num_elements_square, square_spacing)433 434 435 return input_table, design_table, sidelobe_table, grating_lobe_limited, plot1, plot2, plot3, plot4, square_lattice, hexagon_lattice, num_elements_directivity_sqaure, num_elements_directivity_hexagon, directivity_gratinglobe_square, directivity_gratinglobe_hexagon, efficiency_vs_taper, gain_pattern_0, gain_pattern_5, gain_pattern_10, gain_pattern_last436 437# Streamlit UI438st.title("Phased Array Antenna Configurations")439 440# Sidebar Inputs441with st.sidebar:442 st.header("Input Parameters")443 frequency = st.number_input("Frequency (GHz)", min_value=0.1, value=10.0)444 max_sm = st.number_input("Max Scan Angle (Degrees)", min_value=0.0, max_value=90.0, value=20.0)445 gain = st.number_input("Desired Maximum Array Gain (dBi)", min_value=0.0, value=30.0)446 element_efficiency = st.number_input("Element Efficiency (%)", min_value=0.0, max_value=100.0, value=90.0)447 T_illumination = st.number_input("Edge Illumination Taper (dB)", min_value=0.0, value=0.0)448 illimination_taper_loss = st.number_input("Illumination Taper Loss (dB)", min_value=0.0, value=0.0)449 antenna_loss = st.number_input("Antenna Loss (dB)", min_value=0.0, value=0.0)450 gain_loss = st.number_input("Pointing Error Loss (dB)", min_value=0.0, value=0.0)451 loss_beam_diameter = st.number_input("Loss over Beam Diameter (dB)", min_value=0.0, value=0.0)452 implementation_margin = st.number_input("Implementation Margin (dB)", min_value=0.0, value=0.0)453 radiating_element_name = st.selectbox("Type of Radiating Element", list(radiating_element_dict.keys()), index=2)454 455# Run calculations when button is pressed456if st.button("Run Antenna Design"):457 (458 input_table, design_table, sidelobe_table, grating_lobe_limited, plot1, plot2, plot3, plot4, 459 square_lattice, hexagon_lattice, num_elements_directivity_sqaure, 460 num_elements_directivity_hexagon, directivity_gratinglobe_square, 461 directivity_gratinglobe_hexagon, efficiency_vs_taper, gain_pattern_0, 462 gain_pattern_5, gain_pattern_10, gain_pattern_20463 ) = calculate_antenna_design(464 frequency, max_sm, gain, element_efficiency, T_illumination,465 illimination_taper_loss, antenna_loss, gain_loss, loss_beam_diameter,466 implementation_margin, radiating_element_name467 )468 469 # Display Data470 st.subheader("Input Data")471 st.dataframe(input_table)472 if grating_lobe_limited:473 st.warning("Grating Lobe has been limited to 90 degrees.")474 st.subheader("Design Data")475 st.dataframe(design_table)476 st.subheader("Sidelobe Data")477 st.dataframe(sidelobe_table)478 479 st.subheader("Directivity Patterns")480 # Create a 2x2 grid layout481 col1, col2 = st.columns(2)482 with col1:483 st.pyplot(plot1) # Square Lattice (Square Aperture)484 st.pyplot(plot3) # Square Lattice (Circular Aperture)485 with col2:486 st.pyplot(plot2) # Hexagonal Lattice (Square Aperture)487 st.pyplot(plot4) # Hexagonal Lattice (Circular Aperture)488 489 490 st.subheader("Lattice Configurations")491 # Create a 2x2 grid layout492 col1, col2 = st.columns(2)493 with col1:494 st.pyplot(square_lattice)495 with col2:496 st.pyplot(hexagon_lattice)497 498 st.subheader("Number of Elements vs Directivity")499 col1, col2 = st.columns(2)500 with col1:501 st.pyplot(num_elements_directivity_sqaure)502 with col2:503 st.pyplot(num_elements_directivity_hexagon)504 505 st.subheader("Directivity and Grating Lobe as a Funtion of Spacing")506 col1, col2 = st.columns(2)507 with col1:508 st.pyplot(directivity_gratinglobe_square)509 with col2:510 st.pyplot(directivity_gratinglobe_hexagon)511 512 st.subheader("Efficiency vs Illumination Taper")513 st.pyplot(efficiency_vs_taper)514 515 st.subheader("Gain Patterns for T = 0, 5, 10, 20")516 col1, col2 = st.columns(2)517 with col1:518 st.pyplot(gain_pattern_0)519 st.pyplot(gain_pattern_10)520 with col2:521 st.pyplot(gain_pattern_5)522 st.pyplot(gain_pattern_20)523 524 