phased-array-modeling 1.5.0__tar.gz → 1.7.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. {phased_array_modeling-1.5.0 → phased_array_modeling-1.7.0}/PKG-INFO +12 -9
  2. {phased_array_modeling-1.5.0 → phased_array_modeling-1.7.0}/README.md +2 -2
  3. {phased_array_modeling-1.5.0 → phased_array_modeling-1.7.0}/phased_array/__init__.py +14 -7
  4. {phased_array_modeling-1.5.0 → phased_array_modeling-1.7.0}/phased_array/beamforming.py +114 -67
  5. {phased_array_modeling-1.5.0 → phased_array_modeling-1.7.0}/phased_array/coordinates.py +74 -91
  6. {phased_array_modeling-1.5.0 → phased_array_modeling-1.7.0}/phased_array/core.py +384 -98
  7. {phased_array_modeling-1.5.0 → phased_array_modeling-1.7.0}/phased_array/export.py +62 -15
  8. {phased_array_modeling-1.5.0 → phased_array_modeling-1.7.0}/phased_array/geometry.py +130 -102
  9. {phased_array_modeling-1.5.0 → phased_array_modeling-1.7.0}/phased_array/impairments.py +476 -144
  10. {phased_array_modeling-1.5.0 → phased_array_modeling-1.7.0}/phased_array/polarization.py +0 -1
  11. phased_array_modeling-1.7.0/phased_array/py.typed +0 -0
  12. {phased_array_modeling-1.5.0 → phased_array_modeling-1.7.0}/phased_array/utils.py +36 -6
  13. {phased_array_modeling-1.5.0 → phased_array_modeling-1.7.0}/phased_array/vector_patterns.py +42 -11
  14. {phased_array_modeling-1.5.0 → phased_array_modeling-1.7.0}/phased_array/visualization.py +3 -7
  15. {phased_array_modeling-1.5.0 → phased_array_modeling-1.7.0}/phased_array/wideband.py +57 -31
  16. {phased_array_modeling-1.5.0 → phased_array_modeling-1.7.0}/phased_array_modeling.egg-info/PKG-INFO +12 -9
  17. {phased_array_modeling-1.5.0 → phased_array_modeling-1.7.0}/phased_array_modeling.egg-info/SOURCES.txt +4 -0
  18. {phased_array_modeling-1.5.0 → phased_array_modeling-1.7.0}/phased_array_modeling.egg-info/requires.txt +4 -2
  19. {phased_array_modeling-1.5.0 → phased_array_modeling-1.7.0}/pyproject.toml +31 -8
  20. {phased_array_modeling-1.5.0 → phased_array_modeling-1.7.0}/tests/test_beamforming.py +137 -0
  21. {phased_array_modeling-1.5.0 → phased_array_modeling-1.7.0}/tests/test_coordinates.py +47 -0
  22. phased_array_modeling-1.7.0/tests/test_core.py +481 -0
  23. phased_array_modeling-1.7.0/tests/test_docs_snippets.py +103 -0
  24. {phased_array_modeling-1.5.0 → phased_array_modeling-1.7.0}/tests/test_export.py +52 -0
  25. {phased_array_modeling-1.5.0 → phased_array_modeling-1.7.0}/tests/test_geometry.py +121 -0
  26. phased_array_modeling-1.7.0/tests/test_impairments.py +703 -0
  27. phased_array_modeling-1.7.0/tests/test_notebooks.py +39 -0
  28. {phased_array_modeling-1.5.0 → phased_array_modeling-1.7.0}/tests/test_polarization.py +0 -1
  29. phased_array_modeling-1.7.0/tests/test_textbook_benchmarks.py +220 -0
  30. {phased_array_modeling-1.5.0 → phased_array_modeling-1.7.0}/tests/test_utils.py +1 -2
  31. {phased_array_modeling-1.5.0 → phased_array_modeling-1.7.0}/tests/test_vector_patterns.py +31 -0
  32. {phased_array_modeling-1.5.0 → phased_array_modeling-1.7.0}/tests/test_wideband.py +108 -7
  33. phased_array_modeling-1.5.0/tests/test_core.py +0 -264
  34. phased_array_modeling-1.5.0/tests/test_impairments.py +0 -356
  35. {phased_array_modeling-1.5.0 → phased_array_modeling-1.7.0}/LICENSE +0 -0
  36. {phased_array_modeling-1.5.0 → phased_array_modeling-1.7.0}/phased_array_modeling.egg-info/dependency_links.txt +0 -0
  37. {phased_array_modeling-1.5.0 → phased_array_modeling-1.7.0}/phased_array_modeling.egg-info/top_level.txt +0 -0
  38. {phased_array_modeling-1.5.0 → phased_array_modeling-1.7.0}/setup.cfg +0 -0
  39. {phased_array_modeling-1.5.0 → phased_array_modeling-1.7.0}/tests/test_directivity.py +0 -0
  40. {phased_array_modeling-1.5.0 → phased_array_modeling-1.7.0}/tests/test_docstrings.py +0 -0
  41. {phased_array_modeling-1.5.0 → phased_array_modeling-1.7.0}/tests/test_visualization.py +0 -0
@@ -1,9 +1,9 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: phased-array-modeling
3
- Version: 1.5.0
3
+ Version: 1.7.0
4
4
  Summary: Comprehensive Python library for phased array antenna modeling and visualization
5
5
  Author-email: John Hodge <jah70@vt.edu>
6
- License: MIT
6
+ License-Expression: MIT
7
7
  Project-URL: Homepage, https://github.com/jman4162/Phased-Array-Antenna-Model
8
8
  Project-URL: Documentation, https://phased-array-antenna-model.readthedocs.io/
9
9
  Project-URL: Repository, https://github.com/jman4162/Phased-Array-Antenna-Model
@@ -12,21 +12,22 @@ Keywords: phased array,antenna,beamforming,radar,electromagnetics,array factor,r
12
12
  Classifier: Development Status :: 4 - Beta
13
13
  Classifier: Intended Audience :: Science/Research
14
14
  Classifier: Intended Audience :: Education
15
- Classifier: License :: OSI Approved :: MIT License
16
15
  Classifier: Operating System :: OS Independent
17
16
  Classifier: Programming Language :: Python :: 3
18
- Classifier: Programming Language :: Python :: 3.9
19
17
  Classifier: Programming Language :: Python :: 3.10
20
18
  Classifier: Programming Language :: Python :: 3.11
21
19
  Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Programming Language :: Python :: 3.13
21
+ Classifier: Programming Language :: Python :: 3.14
22
22
  Classifier: Topic :: Scientific/Engineering
23
23
  Classifier: Topic :: Scientific/Engineering :: Physics
24
- Requires-Python: >=3.9
24
+ Classifier: Typing :: Typed
25
+ Requires-Python: >=3.10
25
26
  Description-Content-Type: text/markdown
26
27
  License-File: LICENSE
27
- Requires-Dist: numpy>=1.20.0
28
+ Requires-Dist: numpy>=1.21.3
28
29
  Requires-Dist: matplotlib>=3.5.0
29
- Requires-Dist: scipy>=1.7.0
30
+ Requires-Dist: scipy>=1.7.2
30
31
  Provides-Extra: plotting
31
32
  Requires-Dist: plotly>=5.0.0; extra == "plotting"
32
33
  Provides-Extra: full
@@ -37,6 +38,8 @@ Requires-Dist: pytest>=7.0.0; extra == "dev"
37
38
  Requires-Dist: pytest-cov>=4.0.0; extra == "dev"
38
39
  Requires-Dist: plotly>=5.0.0; extra == "dev"
39
40
  Requires-Dist: seaborn>=0.11.0; extra == "dev"
41
+ Requires-Dist: ruff>=0.6.0; extra == "dev"
42
+ Requires-Dist: mypy>=1.10; extra == "dev"
40
43
  Provides-Extra: docs
41
44
  Requires-Dist: sphinx>=7.0.0; extra == "docs"
42
45
  Requires-Dist: pydata-sphinx-theme>=0.14.0; extra == "docs"
@@ -54,7 +57,7 @@ Dynamic: license-file
54
57
  [![Streamlit App](https://static.streamlit.io/badges/streamlit_badge_black_white.svg)](https://phased-array-antenna-model.streamlit.app/)
55
58
  [![Documentation](https://readthedocs.org/projects/phased-array-antenna-model/badge/?version=latest)](https://phased-array-antenna-model.readthedocs.io/en/latest/)
56
59
 
57
- A comprehensive Python library for computing and visualizing phased array antenna radiation patterns. Features vectorized computations (50-100x faster than naive loops), multiple array geometries, advanced beamforming, and interactive 3D visualization.
60
+ A comprehensive Python library for computing and visualizing phased array antenna radiation patterns. Features vectorized array-factor computation with bounded memory, multiple array geometries, advanced beamforming, and interactive 3D visualization.
58
61
 
59
62
  Full walkthrough of the physics and API:
60
63
  [Modeling phased arrays in Python, from physics to trade study](https://john-hodge.com/blog/modeling-phased-arrays-in-python/).
@@ -63,7 +66,7 @@ What's new in v1.4.0:
63
66
 
64
67
  ## Features
65
68
 
66
- - **High Performance**: Vectorized array factor computation (50-100x faster than naive loops)
69
+ - **High Performance**: Vectorized array factor with bounded memory; on rectangular, triangular and thinned grids the sum factors over x and y (32x32 array on a 181x361 grid: 15x faster than a NumPy loop over elements, 320x faster than pure Python; see `benchmarks/bench_array_factor.py`)
67
70
  - **Multiple Geometries**: Rectangular, triangular, circular, cylindrical, spherical, sparse/thinned arrays
68
71
  - **Beamforming**: Amplitude tapering (Taylor, Chebyshev, etc.), null steering, multi-beam
69
72
  - **Realistic Impairments**: Mutual coupling, phase quantization, element failures, scan blindness
@@ -9,7 +9,7 @@
9
9
  [![Streamlit App](https://static.streamlit.io/badges/streamlit_badge_black_white.svg)](https://phased-array-antenna-model.streamlit.app/)
10
10
  [![Documentation](https://readthedocs.org/projects/phased-array-antenna-model/badge/?version=latest)](https://phased-array-antenna-model.readthedocs.io/en/latest/)
11
11
 
12
- A comprehensive Python library for computing and visualizing phased array antenna radiation patterns. Features vectorized computations (50-100x faster than naive loops), multiple array geometries, advanced beamforming, and interactive 3D visualization.
12
+ A comprehensive Python library for computing and visualizing phased array antenna radiation patterns. Features vectorized array-factor computation with bounded memory, multiple array geometries, advanced beamforming, and interactive 3D visualization.
13
13
 
14
14
  Full walkthrough of the physics and API:
15
15
  [Modeling phased arrays in Python, from physics to trade study](https://john-hodge.com/blog/modeling-phased-arrays-in-python/).
@@ -18,7 +18,7 @@ What's new in v1.4.0:
18
18
 
19
19
  ## Features
20
20
 
21
- - **High Performance**: Vectorized array factor computation (50-100x faster than naive loops)
21
+ - **High Performance**: Vectorized array factor with bounded memory; on rectangular, triangular and thinned grids the sum factors over x and y (32x32 array on a 181x361 grid: 15x faster than a NumPy loop over elements, 320x faster than pure Python; see `benchmarks/bench_array_factor.py`)
22
22
  - **Multiple Geometries**: Rectangular, triangular, circular, cylindrical, spherical, sparse/thinned arrays
23
23
  - **Beamforming**: Amplitude tapering (Taylor, Chebyshev, etc.), null steering, multi-beam
24
24
  - **Realistic Impairments**: Mutual coupling, phase quantization, element failures, scan blindness
@@ -4,7 +4,8 @@ Phased Array Antenna Modeling Package
4
4
  A comprehensive Python library for computing and visualizing phased array
5
5
  antenna radiation patterns, including:
6
6
 
7
- - Vectorized array factor computation (50-100x faster than loops)
7
+ - Vectorized array factor computation with bounded memory and a fast
8
+ path for elements on a rectilinear lattice
8
9
  - FFT-based pattern computation for uniform rectangular arrays
9
10
  - Various array geometries (rectangular, circular, conformal, sparse)
10
11
  - Beamforming techniques (tapering, null steering, multi-beam)
@@ -33,7 +34,7 @@ Example
33
34
  >>> theta, phi, pattern_dB = pa.compute_full_pattern(geom.x, geom.y, weights, k)
34
35
  """
35
36
 
36
- __version__ = "1.5.0"
37
+ __version__ = "1.7.0"
37
38
 
38
39
  # Beamforming functions
39
40
  from .beamforming import ( # Amplitude tapers; Null steering; Multiple beams; Beam spoiling; Adaptive
@@ -55,10 +56,11 @@ from .coordinates import (antenna_to_cone, antenna_to_radar, cone_to_antenna,
55
56
  rotation_matrix_yaw)
56
57
  # Core computation functions
57
58
  from .core import (array_factor_fft, array_factor_uv, array_factor_vectorized,
58
- compute_directivity, compute_full_pattern,
59
+ array_manifold, compute_directivity, compute_full_pattern,
59
60
  compute_half_power_beamwidth, compute_pattern_cuts,
60
- element_pattern, element_pattern_cosine_tapered,
61
- steering_vector, total_pattern)
61
+ compute_peak_sidelobe_level, element_pattern,
62
+ element_pattern_cosine_tapered, steering_vector,
63
+ total_pattern)
62
64
  # Export functions
63
65
  from .export import (export_array_config_json, export_coupling_matrix_csv,
64
66
  export_geometry_csv, export_pattern_2d_csv,
@@ -81,8 +83,9 @@ from .impairments import ( # Mutual coupling; Phase quantization; Element failu
81
83
  active_scan_impedance_matrix, analyze_graceful_degradation,
82
84
  analyze_quantization_effect, apply_mutual_coupling, apply_scan_blindness,
83
85
  compute_scan_loss, mismatch_loss, mutual_coupling_matrix_measured,
84
- mutual_coupling_matrix_theoretical, quantization_rms_error,
85
- quantization_sidelobe_increase, quantize_phase, scan_blindness_model,
86
+ mutual_coupling_matrix_theoretical, quantization_lobes,
87
+ quantization_rms_error, quantization_sidelobe_increase,
88
+ quantization_sidelobe_level, quantize_phase, scan_blindness_model,
86
89
  simulate_element_failures, surface_wave_scan_angle, vswr_vs_scan)
87
90
  # Polarization functions
88
91
  from .polarization import (axial_ratio, co_pol_pattern,
@@ -127,6 +130,7 @@ __all__ = [
127
130
  "__version__",
128
131
  # Core
129
132
  "steering_vector",
133
+ "array_manifold",
130
134
  "array_factor_vectorized",
131
135
  "array_factor_uv",
132
136
  "array_factor_fft",
@@ -137,6 +141,7 @@ __all__ = [
137
141
  "compute_full_pattern",
138
142
  "compute_directivity",
139
143
  "compute_half_power_beamwidth",
144
+ "compute_peak_sidelobe_level",
140
145
  # Utils
141
146
  "deg2rad",
142
147
  "rad2deg",
@@ -218,6 +223,8 @@ __all__ = [
218
223
  "quantize_phase",
219
224
  "quantization_rms_error",
220
225
  "quantization_sidelobe_increase",
226
+ "quantization_sidelobe_level",
227
+ "quantization_lobes",
221
228
  "analyze_quantization_effect",
222
229
  "simulate_element_failures",
223
230
  "analyze_graceful_degradation",
@@ -4,6 +4,7 @@ Beamforming functions for phased arrays.
4
4
  Includes amplitude tapering, null steering, and multiple simultaneous beams.
5
5
  """
6
6
 
7
+ import warnings
7
8
  from typing import List, Optional, Tuple, Union
8
9
 
9
10
  import numpy as np
@@ -30,7 +31,8 @@ def taylor_taper_1d(
30
31
  n : int
31
32
  Number of elements
32
33
  sidelobe_dB : float
33
- Desired peak sidelobe level in dB (negative)
34
+ Desired peak sidelobe level in dB. Either sign is accepted
35
+ (-30 and 30 both mean sidelobes 30 dB below the peak).
34
36
  nbar : int
35
37
  Number of nearly equal-level sidelobes
36
38
 
@@ -38,9 +40,18 @@ def taylor_taper_1d(
38
40
  -------
39
41
  taper : ndarray
40
42
  Amplitude taper weights (n,)
43
+
44
+ Notes
45
+ -----
46
+ The weights sample the continuous Taylor line-source distribution
47
+ (``scipy.signal.windows.taylor``), so the achieved peak sidelobe level
48
+ is close to, but not exactly, the design value. Choose
49
+ ``nbar >= 2*A**2 + 0.5`` with ``A = arccosh(10**(|sidelobe_dB|/20))/pi``
50
+ (about 7 for -40 dB). Small arrays with deep sidelobes fall short:
51
+ N = 16 designed for -40 dB reaches about -39.3 dB with nbar = 7.
41
52
  """
42
53
  # Use scipy's Taylor window
43
- return signal.windows.taylor(n, nbar=nbar, sll=-sidelobe_dB, norm=True)
54
+ return signal.windows.taylor(n, nbar=nbar, sll=abs(sidelobe_dB), norm=True)
44
55
 
45
56
 
46
57
  def taylor_taper_2d(
@@ -107,14 +118,27 @@ def chebyshev_taper_1d(
107
118
  n : int
108
119
  Number of elements
109
120
  sidelobe_dB : float
110
- Desired sidelobe level in dB (negative)
121
+ Desired sidelobe level in dB. Either sign is accepted.
111
122
 
112
123
  Returns
113
124
  -------
114
125
  taper : ndarray
115
126
  Amplitude taper weights
127
+
128
+ Notes
129
+ -----
130
+ For large arrays with modest sidelobe levels the edge elements carry
131
+ noticeably more weight than their neighbors (Haupt Fig. 3.11); prefer
132
+ a Taylor taper there.
116
133
  """
117
- return signal.windows.chebwin(n, at=-sidelobe_dB)
134
+ with warnings.catch_warnings():
135
+ # SciPy warns that chebwin is unsuitable for spectral analysis
136
+ # above -45 dB; that concern does not apply to array tapers.
137
+ warnings.filterwarnings(
138
+ "ignore", message=".*not suitable for spectral analysis.*",
139
+ category=UserWarning,
140
+ )
141
+ return signal.windows.chebwin(n, at=abs(sidelobe_dB))
118
142
 
119
143
 
120
144
  def chebyshev_taper_2d(
@@ -723,13 +747,21 @@ def monopulse_weights(
723
747
  Nominal beam direction phi
724
748
  mode : str
725
749
  'sum' - sum pattern (normal beam)
726
- 'delta_az' - azimuth difference pattern
727
- 'delta_el' - elevation difference pattern
750
+ 'delta_az' - azimuth difference pattern (split in x)
751
+ 'delta_el' - elevation difference pattern (split in y)
728
752
 
729
753
  Returns
730
754
  -------
731
755
  weights : ndarray
732
756
  Complex weights for the specified mode
757
+
758
+ Notes
759
+ -----
760
+ The difference halves are split about the array centroid, and
761
+ elements lying on the split line (the center column or row of an
762
+ odd-sized array) get zero weight, giving an exact boresight null.
763
+ The difference weights are amplitude-uniform; multiply by a taper
764
+ for lower difference-pattern sidelobes.
733
765
  """
734
766
  # Base steering vector
735
767
  sv = steering_vector(
@@ -740,16 +772,22 @@ def monopulse_weights(
740
772
  if mode == 'sum':
741
773
  return sv
742
774
 
743
- elif mode == 'delta_az':
744
- # Difference in azimuth: flip sign for half the array in x
745
- sign = np.sign(geometry.x)
746
- sign[sign == 0] = 1 # Handle elements at x=0
747
- return sv * sign
748
-
749
- elif mode == 'delta_el':
750
- # Difference in elevation: flip sign for half the array in y
751
- sign = np.sign(geometry.y)
752
- sign[sign == 0] = 1
775
+ elif mode in ('delta_az', 'delta_el'):
776
+ # Difference pattern: opposite signs on the two halves of the
777
+ # aperture, split about the array centroid. Elements on the split
778
+ # line get zero weight so the halves cancel exactly on boresight.
779
+ coord = np.asarray(geometry.x if mode == 'delta_az' else geometry.y,
780
+ dtype=float)
781
+ if np.ptp(coord) == 0:
782
+ axis = 'x' if mode == 'delta_az' else 'y'
783
+ raise ValueError(
784
+ f"{mode} needs element positions that vary in {axis}; this "
785
+ "array has no extent in that direction, so it has no "
786
+ "difference pattern in that plane"
787
+ )
788
+ offset = coord - coord.mean()
789
+ tol = 1e-9 * max(float(np.ptp(coord)), 1e-30)
790
+ sign = np.where(np.abs(offset) <= tol, 0.0, np.sign(offset))
753
791
  return sv * sign
754
792
 
755
793
  else:
@@ -1037,8 +1075,10 @@ def adaptive_weights_smi(
1037
1075
  phi_desired_deg : float
1038
1076
  Desired signal direction phi in degrees
1039
1077
  interference_data : ndarray
1040
- Interference-plus-noise data matrix (n_snapshots x n_elements)
1041
- Each row is a snapshot of received signals
1078
+ Interference-plus-noise data matrix (n_snapshots x n_elements).
1079
+ Each row is a snapshot of received signals. A plane wave from
1080
+ direction u contributes ``amplitude * array_manifold(...)``
1081
+ (``exp(+j k r . u)``), not ``steering_vector``.
1042
1082
  diagonal_loading : float
1043
1083
  Diagonal loading factor for robustness.
1044
1084
  Adds diagonal_loading * I to the covariance matrix.
@@ -1046,7 +1086,10 @@ def adaptive_weights_smi(
1046
1086
  Returns
1047
1087
  -------
1048
1088
  weights : ndarray
1049
- Adaptive complex weights
1089
+ Adaptive complex weights, applied without conjugation: the array
1090
+ output is ``weights @ x`` and the pattern is
1091
+ ``array_factor_vectorized(..., weights, ...)``. The look-direction
1092
+ response ``weights @ array_manifold(look)`` equals 1.
1050
1093
 
1051
1094
  Examples
1052
1095
  --------
@@ -1056,8 +1099,9 @@ def adaptive_weights_smi(
1056
1099
  >>> k = pa.wavelength_to_k(1.0)
1057
1100
  >>> # Simulate interference data (normally from receiver)
1058
1101
  >>> n_snapshots = 100
1059
- >>> interference = np.random.randn(n_snapshots, geom.n_elements) + \\
1060
- ... 1j * np.random.randn(n_snapshots, geom.n_elements)
1102
+ >>> rng = np.random.default_rng(0)
1103
+ >>> interference = rng.standard_normal((n_snapshots, geom.n_elements)) + \\
1104
+ ... 1j * rng.standard_normal((n_snapshots, geom.n_elements))
1061
1105
  >>> weights = pa.adaptive_weights_smi(
1062
1106
  ... geom, k, theta_desired_deg=0, phi_desired_deg=0,
1063
1107
  ... interference_data=interference, diagonal_loading=0.01
@@ -1068,9 +1112,12 @@ def adaptive_weights_smi(
1068
1112
  Notes
1069
1113
  -----
1070
1114
  The SMI weight vector is:
1071
- w = R^(-1) @ s / (s^H @ R^(-1) @ s)
1115
+ w = R~^(-1) @ s / (s^H @ R~^(-1) @ s)
1072
1116
 
1073
- where R is the sample covariance matrix and s is the steering vector.
1117
+ where ``s = steering_vector(...)`` and ``R~ = X^H X / K`` for the
1118
+ snapshot matrix X (rows are snapshots). ``R~`` is the conjugate of the
1119
+ usual covariance ``E[x x^H]``, so ``w`` is the conjugate of the
1120
+ textbook MVDR weight and is applied as ``w @ x``.
1074
1121
  Diagonal loading improves robustness when snapshots are limited.
1075
1122
  """
1076
1123
  n = geometry.n_elements
@@ -1115,14 +1162,15 @@ def adaptive_weights_gsc(
1115
1162
  phi_desired_deg: float,
1116
1163
  interference_data: np.ndarray,
1117
1164
  n_blocking_vectors: Optional[int] = None,
1118
- mu: float = 0.01
1165
+ mu: float = 0.1
1119
1166
  ) -> Tuple[np.ndarray, np.ndarray]:
1120
1167
  """
1121
1168
  Compute adaptive weights using Generalized Sidelobe Canceller (GSC).
1122
1169
 
1123
1170
  GSC provides a constrained adaptive filter structure that maintains
1124
1171
  distortionless response in the look direction while minimizing
1125
- interference and noise.
1172
+ interference and noise. The adaptive branch uses normalized LMS
1173
+ (NLMS) over one pass through the snapshots.
1126
1174
 
1127
1175
  Parameters
1128
1176
  ----------
@@ -1135,18 +1183,23 @@ def adaptive_weights_gsc(
1135
1183
  phi_desired_deg : float
1136
1184
  Desired signal direction phi in degrees
1137
1185
  interference_data : ndarray
1138
- Interference-plus-noise data (n_snapshots x n_elements)
1186
+ Interference-plus-noise data (n_snapshots x n_elements). A plane
1187
+ wave from direction u contributes ``amplitude * array_manifold``.
1139
1188
  n_blocking_vectors : int, optional
1140
1189
  Number of blocking matrix columns. Default: n_elements - 1
1141
1190
  mu : float
1142
- Adaptation step size for LMS algorithm
1191
+ Normalized LMS step size, stable for ``0 < mu < 2``. Each update
1192
+ is scaled by ``1 / ||x_b||^2``, so the step does not depend on the
1193
+ input power. Larger values adapt faster with more misadjustment.
1143
1194
 
1144
1195
  Returns
1145
1196
  -------
1146
1197
  weights : ndarray
1147
- Adaptive weights (n_elements,)
1198
+ Adaptive weights (n_elements,), applied without conjugation like
1199
+ :func:`adaptive_weights_smi`; the look-direction response is 1.
1148
1200
  blocking_matrix : ndarray
1149
- Blocking matrix used (n_elements x n_blocking_vectors)
1201
+ Blocking matrix used (n_elements x n_blocking_vectors), with
1202
+ ``B.T @ array_manifold(look) = 0``
1150
1203
 
1151
1204
  Examples
1152
1205
  --------
@@ -1154,8 +1207,9 @@ def adaptive_weights_gsc(
1154
1207
  >>> import phased_array as pa
1155
1208
  >>> geom = pa.create_rectangular_array(8, 8, dx=0.5, dy=0.5)
1156
1209
  >>> k = pa.wavelength_to_k(1.0)
1157
- >>> interference = np.random.randn(50, geom.n_elements) + \\
1158
- ... 1j * np.random.randn(50, geom.n_elements)
1210
+ >>> rng = np.random.default_rng(0)
1211
+ >>> interference = rng.standard_normal((50, geom.n_elements)) + \\
1212
+ ... 1j * rng.standard_normal((50, geom.n_elements))
1159
1213
  >>> weights, B = pa.adaptive_weights_gsc(
1160
1214
  ... geom, k, theta_desired_deg=0, phi_desired_deg=0,
1161
1215
  ... interference_data=interference
@@ -1169,59 +1223,50 @@ def adaptive_weights_gsc(
1169
1223
  w = w_q - B @ w_a
1170
1224
 
1171
1225
  where:
1172
- - w_q is the quiescent (non-adaptive) steering weight
1173
- - B is a blocking matrix orthogonal to the steering vector
1174
- - w_a are adaptive weights that minimize output power
1175
-
1176
- The blocking matrix satisfies: s^H @ B = 0 (nulls the look direction)
1226
+ - ``w_q = s / ||s||^2`` is the quiescent steering weight (unit
1227
+ look-direction response), with ``s = steering_vector(...)``
1228
+ - B is a blocking matrix with ``s^H @ B = 0``, equivalently
1229
+ ``B.T @ a0 = 0`` for the look-direction manifold ``a0``
1230
+ - ``w_a`` minimizes the output power ``|w.T @ x|^2``
1231
+
1232
+ With ``y_q = w_q @ x``, ``x_b = B.T @ x`` and ``e = y_q - w_a @ x_b``,
1233
+ the NLMS update is ``w_a += mu * e * conj(x_b) / (eps + ||x_b||^2)``.
1177
1234
  """
1178
1235
  n = geometry.n_elements
1179
1236
 
1180
1237
  if n_blocking_vectors is None:
1181
1238
  n_blocking_vectors = n - 1
1182
1239
 
1183
- # Quiescent steering vector
1240
+ # Quiescent steering vector, scaled for unit look-direction response
1184
1241
  s = steering_vector(
1185
1242
  k, geometry.x, geometry.y,
1186
1243
  theta_desired_deg, phi_desired_deg, geometry.z
1187
1244
  )
1188
- w_q = s / np.sqrt(np.sum(np.abs(s)**2)) # Normalize
1189
-
1190
- # Construct blocking matrix B orthogonal to s
1191
- # Use SVD of s to get orthogonal complement
1192
- s_normalized = s / np.linalg.norm(s)
1193
- s_col = s_normalized.reshape(-1, 1)
1245
+ w_q = s / np.sum(np.abs(s)**2)
1194
1246
 
1195
- # Create orthonormal basis for null space of s^H
1196
- # Using Householder or Gram-Schmidt
1247
+ # Blocking matrix: orthonormal columns orthogonal to s (s^H B = 0),
1248
+ # which is B.T @ conj(s) = 0, i.e. the look-direction manifold is
1249
+ # rejected by the w.T convention used here.
1250
+ s_col = (s / np.linalg.norm(s)).reshape(-1, 1)
1197
1251
  Q, _ = np.linalg.qr(np.hstack([s_col, np.eye(n)[:, :n_blocking_vectors]]))
1198
- B = Q[:, 1:n_blocking_vectors + 1] # Take columns orthogonal to s
1252
+ B = Q[:, 1:n_blocking_vectors + 1]
1199
1253
 
1200
- # Process data through GSC
1201
1254
  interference_data = np.asarray(interference_data, dtype=complex)
1202
1255
  n_snapshots = interference_data.shape[0]
1203
1256
 
1204
- # Initialize adaptive weights
1205
1257
  w_a = np.zeros(n_blocking_vectors, dtype=complex)
1258
+ eps = 1e-12
1206
1259
 
1207
- # LMS adaptation through data
1260
+ # NLMS adaptation, output y = w.T @ x (no conjugation)
1208
1261
  for snapshot_idx in range(n_snapshots):
1209
1262
  x = interference_data[snapshot_idx, :]
1210
1263
 
1211
- # Upper path output (reference)
1212
- y_q = w_q.conj() @ x
1213
-
1214
- # Lower path (blocking matrix output)
1215
- x_b = B.conj().T @ x
1216
-
1217
- # Error signal
1218
- y_a = w_a.conj() @ x_b
1219
- e = y_q - y_a
1264
+ y_q = w_q @ x # upper (quiescent) branch
1265
+ x_b = B.T @ x # blocked branch
1266
+ e = y_q - w_a @ x_b # GSC output
1220
1267
 
1221
- # LMS update
1222
- w_a = w_a + mu * e.conj() * x_b
1268
+ w_a = w_a + (mu / (eps + np.vdot(x_b, x_b).real)) * e * x_b.conj()
1223
1269
 
1224
- # Final weights
1225
1270
  weights = w_q - B @ w_a
1226
1271
 
1227
1272
  return weights, B
@@ -1300,7 +1345,7 @@ def compute_sinr_improvement(
1300
1345
  phi_s = np.array([[np.deg2rad(signal_direction[1])]])
1301
1346
  AF_signal = array_factor_vectorized(
1302
1347
  theta_s, phi_s,
1303
- geometry.x, geometry.y, weights, k
1348
+ geometry.x, geometry.y, weights, k, geometry.z
1304
1349
  )
1305
1350
  signal_out = signal_power * np.abs(AF_signal.item())**2
1306
1351
 
@@ -1311,7 +1356,7 @@ def compute_sinr_improvement(
1311
1356
  phi_int = np.array([[np.deg2rad(phi_i)]])
1312
1357
  AF_int = array_factor_vectorized(
1313
1358
  theta_int, phi_int,
1314
- geometry.x, geometry.y, weights, k
1359
+ geometry.x, geometry.y, weights, k, geometry.z
1315
1360
  )
1316
1361
  interference_out += power_i * np.abs(AF_int.item())**2
1317
1362
 
@@ -1390,19 +1435,21 @@ def plot_adapted_pattern(
1390
1435
 
1391
1436
  # Compute patterns
1392
1437
  theta = np.linspace(-np.pi/2, np.pi/2, n_points)
1393
- phi = np.full_like(theta, np.deg2rad(phi_cut_deg))
1438
+ # Negative theta is the opposite side of the cut plane (phi + 180)
1439
+ phi = np.where(theta >= 0, np.deg2rad(phi_cut_deg),
1440
+ np.deg2rad(phi_cut_deg) + np.pi)
1394
1441
 
1395
- theta_grid = theta.reshape(-1, 1)
1442
+ theta_grid = np.abs(theta).reshape(-1, 1)
1396
1443
  phi_grid = phi.reshape(-1, 1)
1397
1444
 
1398
1445
  AF_quiescent = array_factor_vectorized(
1399
1446
  theta_grid, phi_grid,
1400
- geometry.x, geometry.y, weights_quiescent, k
1447
+ geometry.x, geometry.y, weights_quiescent, k, geometry.z
1401
1448
  ).ravel()
1402
1449
 
1403
1450
  AF_adapted = array_factor_vectorized(
1404
1451
  theta_grid, phi_grid,
1405
- geometry.x, geometry.y, weights_adapted, k
1452
+ geometry.x, geometry.y, weights_adapted, k, geometry.z
1406
1453
  ).ravel()
1407
1454
 
1408
1455
  # Convert to dB