Export Module#

The export module provides functions to save array configurations, patterns, and analysis results in various formats for use with other software tools.

Pattern Export#

phased_array.export_pattern_csv(angles, pattern_dB, filename=None, angle_label='angle_deg', pattern_label='pattern_dB', include_header=True, metadata=None)[source]#

Export 1D pattern data to CSV format.

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

  • pattern_dB (ndarray) – Pattern values in dB

  • filename (str, optional) – If provided, write to file. Otherwise return string.

  • angle_label (str) – Column label for angles

  • pattern_label (str) – Column label for pattern

  • include_header (bool) – Whether to include column headers

  • metadata (dict, optional) – Additional metadata to include as comments

Returns:

csv_string – CSV formatted string (also written to file if filename provided)

Return type:

str

Examples

Export a pattern cut to CSV:

>>> import numpy as np
>>> import phased_array as pa
>>> geom = pa.create_rectangular_array(8, 8, dx=0.5, dy=0.5)
>>> k = pa.wavelength_to_k(1.0)
>>> weights = pa.steering_vector(k, geom.x, geom.y, theta0_deg=0, phi0_deg=0)
>>> theta_deg, E_plane, H_plane = pa.compute_pattern_cuts(
...     geom.x, geom.y, weights, k
... )
>>> csv_str = pa.export_pattern_csv(
...     theta_deg, E_plane,
...     angle_label='theta_deg',
...     pattern_label='E_plane_dB',
...     metadata={'array_size': '8x8', 'scan_angle': '0 deg'}
... )

Save to file:

>>> # pa.export_pattern_csv(theta_deg, E_plane, filename='pattern.csv')
phased_array.export_pattern_2d_csv(theta, phi, pattern_dB, filename=None, include_header=True, metadata=None)[source]#

Export 2D pattern data to CSV format.

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

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

  • pattern_dB (ndarray) – 2D pattern in dB

  • filename (str, optional) – If provided, write to file

  • include_header (bool) – Whether to include column headers

  • metadata (dict, optional) – Additional metadata as comments

Returns:

csv_string – CSV formatted string

Return type:

str

phased_array.export_uv_pattern_csv(u, v, pattern_dB, filename=None, include_header=True, metadata=None)[source]#

Export UV-space pattern data to CSV format.

Parameters:
  • u (ndarray) – U direction cosine values

  • v (ndarray) – V direction cosine values

  • pattern_dB (ndarray) – 2D pattern in dB

  • filename (str, optional) – If provided, write to file

  • include_header (bool) – Whether to include column headers

  • metadata (dict, optional) – Additional metadata

Returns:

csv_string – CSV formatted string

Return type:

str

phased_array.export_pattern_npz(filename, angles=None, e_plane=None, h_plane=None, theta=None, phi=None, pattern_2d=None, u=None, v=None, pattern_uv=None, weights=None, geometry_x=None, geometry_y=None, metadata=None)[source]#

Export pattern data to compressed NumPy format.

Parameters:
  • filename (str) – Output filename (should end in .npz)

  • angles (ndarray, optional) – 1D cut angles

  • e_plane (ndarray, optional) – E-plane pattern

  • h_plane (ndarray, optional) – H-plane pattern

  • theta (ndarray, optional) – 2D grid coordinates

  • phi (ndarray, optional) – 2D grid coordinates

  • pattern_2d (ndarray, optional) – Full 2D pattern

  • u (ndarray, optional) – UV-space coordinates

  • v (ndarray, optional) – UV-space coordinates

  • pattern_uv (ndarray, optional) – UV-space pattern

  • weights (ndarray, optional) – Complex element weights

  • geometry_x (ndarray, optional) – Element positions

  • geometry_y (ndarray, optional) – Element positions

  • metadata (dict, optional) – Additional metadata (converted to string for storage)

phased_array.load_pattern_npz(filename)[source]#

Load pattern data from NumPy format.

Parameters:

filename (str) – Input filename

Returns:

data – Dictionary with loaded arrays and metadata

Return type:

dict

Array Configuration#

phased_array.export_weights_csv(geometry, weights, filename=None, include_header=True, metadata=None)[source]#

Export element weights to CSV format.

Parameters:
  • geometry (ArrayGeometry) – Array geometry with element positions

  • weights (ndarray) – Complex element weights

  • filename (str, optional) – If provided, write to file

  • include_header (bool) – Whether to include column headers

  • metadata (dict, optional) – Additional metadata

Returns:

csv_string – CSV formatted string with columns: element, x, y, weight_real, weight_imag, weight_mag, weight_phase_deg

Return type:

str

phased_array.export_geometry_csv(geometry, filename=None, include_header=True, metadata=None)[source]#

Export array geometry to CSV format.

Parameters:
  • geometry (ArrayGeometry) – Array geometry with element positions

  • filename (str, optional) – If provided, write to file

  • include_header (bool) – Whether to include column headers

  • metadata (dict, optional) – Additional metadata

Returns:

csv_string – CSV formatted string

Return type:

str

phased_array.export_array_config_json(geometry, weights=None, array_params=None, steering=None, taper_info=None, filename=None)[source]#

Export full array configuration to JSON format.

Parameters:
  • geometry (ArrayGeometry) – Array geometry

  • weights (ndarray, optional) – Complex weights (exported as mag/phase)

  • array_params (dict, optional) – Array parameters (type, spacing, etc.)

  • steering (dict, optional) – Steering direction (theta, phi)

  • taper_info (dict, optional) – Taper information

  • filename (str, optional) – If provided, write to file

Returns:

json_string – JSON formatted string

Return type:

str

phased_array.export_coupling_matrix_csv(coupling_matrix, filename=None, format='magnitude_phase', metadata=None)[source]#

Export mutual coupling matrix to CSV format.

Parameters:
  • coupling_matrix (ndarray) – Complex N x N coupling matrix

  • filename (str, optional) – If provided, write to file

  • format (str) – ‘magnitude_phase’ - two columns per element (mag, phase_deg) ‘real_imag’ - two columns per element (real, imag) ‘magnitude’ - magnitude only ‘dB’ - magnitude in dB only

  • metadata (dict, optional) – Additional metadata

Returns:

csv_string – CSV formatted string

Return type:

str

Reports#

phased_array.export_summary_report(geometry, weights, pattern_metrics, array_params=None, steering=None, filename=None)[source]#

Generate a human-readable summary report.

Parameters:
  • geometry (ArrayGeometry) – Array geometry

  • weights (ndarray) – Complex weights

  • pattern_metrics (dict) – Dictionary with metrics like HPBW, SLL, directivity, etc.

  • array_params (dict, optional) – Array configuration parameters

  • steering (dict, optional) – Steering direction

  • filename (str, optional) – If provided, write to file

Returns:

report – Formatted text report

Return type:

str