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 degrees

  • pattern_dB (ndarray) – Pattern values in dB

  • title (str) – Plot title

  • xlabel (str) – Axis labels

  • ylabel (str) – Axis labels

  • min_dB (float) – Minimum dB level to display

  • figsize (tuple) – Figure size (width, height)

  • ax (matplotlib axis, optional) – Existing axis to plot on

  • label (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:
  • angles_deg (ndarray) – Angle values in degrees

  • pattern_dB (ndarray) – Pattern values in dB (normalized)

  • title (str) – Plot title

  • min_dB (float) – Minimum dB level (becomes r=0)

  • figsize (tuple) – Figure size

  • ax (matplotlib polar axis, optional) – Existing axis

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 title

  • min_dB (float) – Minimum dB level

  • levels (int) – Number of contour levels

  • figsize (tuple) – Figure size

  • cmap (str) – Colormap name

  • ax (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 geometry

  • weights (ndarray, optional) – Element weights (color by magnitude)

  • title (str) – Plot title

  • show_indices (bool) – Show element index numbers

  • figsize (tuple) – Figure size

  • ax (matplotlib axis, optional) – Existing axis

Returns:

ax

Return type:

matplotlib axis

phased_array.plot_comparison_patterns(angles_deg, patterns_dB, title='Pattern Comparison', min_dB=-50.0, figsize=(12, 6))[source]#

Plot multiple patterns for comparison.

Parameters:
  • angles_deg (ndarray) – Angle values

  • patterns_dB (dict) – Dictionary of {label: pattern_dB}

  • title (str) – Plot title

  • min_dB (float) – Minimum dB

  • figsize (tuple) – Figure size

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:
  • geometry (ArrayGeometry) – Array geometry

  • weights (ndarray) – Element weights

  • k (float) – Wavenumber

  • n_u (int) – Number of points in u and v

  • n_v (int) – Number of points in u and v

  • u_range (tuple) – Range for u and v

  • v_range (tuple) – Range for u and v

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:

Tuple[ndarray, ndarray, ndarray]

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 title

  • min_dB (float) – Minimum dB level

  • show_visible_region (bool) – Show unit circle (visible space boundary)

  • show_grating_circles (bool) – Show grating lobe circles

  • dx_wavelengths (float, optional) – Element spacing for grating lobe calculation

  • dy_wavelengths (float, optional) – Element spacing for grating lobe calculation

  • figsize (tuple) – Figure size

  • cmap (str) – Colormap

  • ax (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 title

  • min_dB (float) – Minimum dB level

  • colorscale (str) – Plotly colorscale name

  • surface_type (str) – ‘spherical’ - radius proportional to gain ‘cartesian’ - theta/phi/gain surface

Returns:

fig

Return type:

plotly.graph_objects.Figure

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.

Parameters:
  • theta_deg (ndarray) – Theta values in degrees (1D)

  • phi_deg (ndarray) – Phi values in degrees (1D)

  • pattern_dB (ndarray) – Pattern in dB (2D)

  • title (str) – Plot title

  • min_dB (float) – Minimum dB

  • colorscale (str) – Colorscale name

Returns:

fig

Return type:

plotly Figure

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 normals

  • weights (ndarray, optional) – Element weights for coloring

  • title (str) – Plot title

  • show_normals (bool) – Show element normal vectors

  • normal_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:
  • u (ndarray) – Direction cosines (1D)

  • v (ndarray) – Direction cosines (1D)

  • pattern_dB (ndarray) – Pattern in dB (2D)

  • title (str) – Plot title

  • min_dB (float) – Minimum dB

  • colorscale (str) – Colorscale

  • show_visible_circle (bool) – Show visible region boundary

Returns:

fig

Return type:

plotly Figure

phased_array.create_pattern_animation_plotly(theta, phi, patterns_dB, frame_labels, title='Pattern Animation', min_dB=-40.0, colorscale='Jet')[source]#

Create animated pattern plot (e.g., beam scanning).

Parameters:
  • theta (ndarray) – Theta values (1D)

  • phi (ndarray) – Phi values (1D)

  • patterns_dB (list of ndarray) – List of 2D patterns for each frame

  • frame_labels (list of str) – Label for each frame

  • title (str) – Plot title

  • min_dB (float) – Minimum dB

  • colorscale (str) – Colorscale

Returns:

fig

Return type:

plotly Figure with animation

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.

Parameters:
  • frequencies (ndarray) – Frequency values in Hz

  • squint_data (dict) – Dictionary of {mode_name: squint_array} in degrees

  • center_frequency (float) – Center frequency in Hz (for normalization)

  • title (str) – Plot title

  • figsize (tuple) – Figure size

Returns:

ax

Return type:

matplotlib axis

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 degrees

  • frequencies (ndarray) – Frequency values in Hz

  • patterns (ndarray) – 2D array (n_freq x n_angles) of patterns in dB

  • center_frequency (float) – Center frequency for labeling

  • title (str) – Plot title

  • min_dB (float) – Minimum dB for colormap

  • figsize (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.

Parameters:
  • angles (ndarray) – Angle values in degrees

  • frequencies (ndarray) – Frequency values in Hz

  • patterns (ndarray) – 2D array (n_freq x n_angles) in dB

  • center_frequency (float) – Center frequency

  • title (str) – Plot title

  • min_dB (float) – Minimum dB

Returns:

fig

Return type:

plotly Figure

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 centers

  • delays (ndarray) – Time delay for each subarray in seconds

  • title (str) – Plot title

  • figsize (tuple) – Figure size

Returns:

ax

Return type:

matplotlib axis