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 dBfilename (
str, optional) – If provided, write to file. Otherwise return string.angle_label (
str) – Column label for anglespattern_label (
str) – Column label for patterninclude_header (
bool) – Whether to include column headersmetadata (
dict, optional) – Additional metadata to include as comments
- Returns:
csv_string – CSV formatted string (also written to file if filename provided)
- Return type:
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 dBfilename (
str, optional) – If provided, write to fileinclude_header (
bool) – Whether to include column headersmetadata (
dict, optional) – Additional metadata as comments
- Returns:
csv_string – CSV formatted string
- Return type:
- 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:
- Returns:
csv_string – CSV formatted string
- Return type:
- 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 anglese_plane (
ndarray, optional) – E-plane patternh_plane (
ndarray, optional) – H-plane patterntheta (
ndarray, optional) – 2D grid coordinatesphi (
ndarray, optional) – 2D grid coordinatespattern_2d (
ndarray, optional) – Full 2D patternu (
ndarray, optional) – UV-space coordinatesv (
ndarray, optional) – UV-space coordinatespattern_uv (
ndarray, optional) – UV-space patternweights (
ndarray, optional) – Complex element weightsgeometry_x (
ndarray, optional) – Element positionsgeometry_y (
ndarray, optional) – Element positionsmetadata (
dict, optional) – Additional metadata (converted to string for storage)
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 positionsweights (
ndarray) – Complex element weightsfilename (
str, optional) – If provided, write to fileinclude_header (
bool) – Whether to include column headersmetadata (
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:
- 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 positionsfilename (
str, optional) – If provided, write to fileinclude_header (
bool) – Whether to include column headersmetadata (
dict, optional) – Additional metadata
- Returns:
csv_string – CSV formatted string
- Return type:
- 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 geometryweights (
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 informationfilename (
str, optional) – If provided, write to file
- Returns:
json_string – JSON formatted string
- Return type:
- 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 matrixfilename (
str, optional) – If provided, write to fileformat (
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 onlymetadata (
dict, optional) – Additional metadata
- Returns:
csv_string – CSV formatted string
- Return type:
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 geometryweights (
ndarray) – Complex weightspattern_metrics (
dict) – Dictionary with metrics like HPBW, SLL, directivity, etc.array_params (
dict, optional) – Array configuration parameterssteering (
dict, optional) – Steering directionfilename (
str, optional) – If provided, write to file
- Returns:
report – Formatted text report
- Return type: