Visualization Module#
The visualization module provides functions for creating 2D and 3D plots of radiation patterns, array geometries, and UV-space representations using Matplotlib and Plotly.
2D Matplotlib Plots#
- phased_array.plot_pattern_2d(angles_deg, pattern_dB, title='Radiation Pattern', xlabel='Angle (degrees)', ylabel='Normalized Gain (dB)', min_dB=-50.0, figsize=(10, 6), ax=None, label=None, **plot_kwargs)[source]#
Plot a 1D pattern cut.
- Parameters:
angles_deg (
ndarray) – Angle values in degreespattern_dB (
ndarray) – Pattern values in dBtitle (
str) – Plot titlexlabel (
str) – Axis labelsylabel (
str) – Axis labelsmin_dB (
float) – Minimum dB level to displayfigsize (
tuple) – Figure size (width, height)ax (
matplotlib axis, optional) – Existing axis to plot onlabel (
str, optional) – Legend label**plot_kwargs – Additional arguments for plt.plot()
- Returns:
ax
- Return type:
matplotlib axis
- phased_array.plot_pattern_polar(angles_deg, pattern_dB, title='Radiation Pattern', min_dB=-40.0, figsize=(8, 8), ax=None, **plot_kwargs)[source]#
Plot a 1D pattern cut in polar coordinates.
- Parameters:
- Returns:
ax
- Return type:
matplotlib axis
- phased_array.plot_pattern_contour(theta_deg, phi_deg, pattern_dB, title='Radiation Pattern', min_dB=-40.0, levels=20, figsize=(10, 8), cmap='jet', ax=None)[source]#
Plot 2D pattern as contour plot.
- Parameters:
theta_deg (
ndarray) – Theta values (1D or 2D grid)phi_deg (
ndarray) – Phi values (1D or 2D grid)pattern_dB (
ndarray) – Pattern in dB (2D)title (
str) – Plot titlemin_dB (
float) – Minimum dB levellevels (
int) – Number of contour levelsfigsize (
tuple) – Figure sizecmap (
str) – Colormap nameax (
matplotlib axis, optional) – Existing axis
- Returns:
ax
- Return type:
matplotlib axis
- phased_array.plot_array_geometry(geometry, weights=None, title='Array Geometry', show_indices=False, figsize=(8, 8), ax=None)[source]#
Plot array element positions (2D view).
- Parameters:
geometry (
ArrayGeometry) – Array geometryweights (
ndarray, optional) – Element weights (color by magnitude)title (
str) – Plot titleshow_indices (
bool) – Show element index numbersfigsize (
tuple) – Figure sizeax (
matplotlib axis, optional) – Existing axis
- Returns:
ax
- Return type:
matplotlib axis
UV-Space#
- phased_array.compute_pattern_uv_space(geometry, weights, k, n_u=201, n_v=201, u_range=(-1, 1), v_range=(-1, 1))[source]#
Compute pattern directly in UV-space.
- Parameters:
- Returns:
u (
ndarray) – U values (1D)v (
ndarray) – V values (1D)pattern_dB (
ndarray) – Pattern in dB (2D: n_u x n_v)
- Return type:
- phased_array.plot_pattern_uv_space(u, v, pattern_dB, title='UV-Space Pattern', min_dB=-40.0, show_visible_region=True, show_grating_circles=False, dx_wavelengths=None, dy_wavelengths=None, figsize=(10, 8), cmap='jet', ax=None)[source]#
Plot pattern in UV-space with optional visible region and grating lobe circles.
- Parameters:
u (
ndarray) – Direction cosine values (1D)v (
ndarray) – Direction cosine values (1D)pattern_dB (
ndarray) – Pattern in dB (2D)title (
str) – Plot titlemin_dB (
float) – Minimum dB levelshow_visible_region (
bool) – Show unit circle (visible space boundary)show_grating_circles (
bool) – Show grating lobe circlesdx_wavelengths (
float, optional) – Element spacing for grating lobe calculationdy_wavelengths (
float, optional) – Element spacing for grating lobe calculationfigsize (
tuple) – Figure sizecmap (
str) – Colormapax (
matplotlib axis, optional) – Existing axis
- Returns:
ax
- Return type:
matplotlib axis
3D Plotly (Interactive)#
- phased_array.plot_pattern_3d_plotly(theta, phi, pattern_dB, title='3D Radiation Pattern', min_dB=-40.0, colorscale='Jet', surface_type='spherical')[source]#
Create interactive 3D pattern plot using Plotly.
- Parameters:
theta (
ndarray) – Theta values in radians (1D)phi (
ndarray) – Phi values in radians (1D)pattern_dB (
ndarray) – Pattern in dB (2D: n_theta x n_phi)title (
str) – Plot titlemin_dB (
float) – Minimum dB levelcolorscale (
str) – Plotly colorscale namesurface_type (
str) – ‘spherical’ - radius proportional to gain ‘cartesian’ - theta/phi/gain surface
- Returns:
fig
- Return type:
Examples
Create an interactive 3D pattern plot:
>>> import numpy as np >>> import phased_array as pa >>> geom = pa.create_rectangular_array(16, 16, dx=0.5, dy=0.5) >>> k = pa.wavelength_to_k(1.0) >>> weights = pa.steering_vector(k, geom.x, geom.y, theta0_deg=20, phi0_deg=45) >>> weights *= pa.taylor_taper_2d(16, 16, sidelobe_dB=-30) >>> theta, phi, pattern_dB = pa.compute_full_pattern( ... geom.x, geom.y, weights, k ... ) >>> fig = pa.plot_pattern_3d_plotly( ... theta, phi, pattern_dB, ... title="16x16 Array - Steered to 20 deg", ... min_dB=-40 ... ) >>> # fig.show() # Display in browser
Cartesian projection (theta/phi/gain axes):
>>> fig = pa.plot_pattern_3d_plotly( ... theta, phi, pattern_dB, ... surface_type='cartesian' ... )
- phased_array.plot_pattern_3d_cartesian_plotly(theta_deg, phi_deg, pattern_dB, title='3D Radiation Pattern', min_dB=-40.0, colorscale='Jet')[source]#
Create 3D surface plot with theta/phi/gain axes.
- phased_array.plot_array_geometry_3d_plotly(geometry, weights=None, title='Array Geometry', show_normals=True, normal_scale=0.1)[source]#
Create interactive 3D array geometry plot using Plotly.
- Parameters:
geometry (
ArrayGeometry) – Array geometry with positions and optional normalsweights (
ndarray, optional) – Element weights for coloringtitle (
str) – Plot titleshow_normals (
bool) – Show element normal vectorsnormal_scale (
float) – Scale factor for normal vectors
- Returns:
fig
- Return type:
plotly Figure
- phased_array.plot_pattern_uv_plotly(u, v, pattern_dB, title='UV-Space Pattern', min_dB=-40.0, colorscale='Jet', show_visible_circle=True)[source]#
Interactive UV-space pattern plot using Plotly.
- Parameters:
- Returns:
fig
- Return type:
plotly Figure
Wideband Visualization#
- phased_array.plot_beam_squint(frequencies, squint_data, center_frequency, title='Beam Squint vs Frequency', figsize=(10, 6))[source]#
Plot beam squint comparison for different steering modes.
- phased_array.plot_pattern_vs_frequency(angles, frequencies, patterns, center_frequency, title='Pattern vs Frequency', min_dB=-40.0, figsize=(12, 8))[source]#
Plot radiation patterns at multiple frequencies as a waterfall/heatmap.
- Parameters:
angles (
ndarray) – Angle values in degreesfrequencies (
ndarray) – Frequency values in Hzpatterns (
ndarray) – 2D array (n_freq x n_angles) of patterns in dBcenter_frequency (
float) – Center frequency for labelingtitle (
str) – Plot titlemin_dB (
float) – Minimum dB for colormapfigsize (
tuple) – Figure size
- Returns:
ax
- Return type:
matplotlib axis
- phased_array.plot_pattern_vs_frequency_plotly(angles, frequencies, patterns, center_frequency, title='Pattern vs Frequency', min_dB=-40.0)[source]#
Interactive Plotly plot of patterns vs frequency.
- phased_array.plot_subarray_delays(architecture, delays, title='Subarray Time Delays', figsize=(10, 8))[source]#
Visualize TTD values across subarrays.
- Parameters:
architecture (
SubarrayArchitecture) – Subarray architecture with centersdelays (
ndarray) – Time delay for each subarray in secondstitle (
str) – Plot titlefigsize (
tuple) – Figure size
- Returns:
ax
- Return type:
matplotlib axis