phased-array-modeling 1.4.1__tar.gz → 1.5.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 (35) hide show
  1. {phased_array_modeling-1.4.1 → phased_array_modeling-1.5.0}/PKG-INFO +1 -1
  2. {phased_array_modeling-1.4.1 → phased_array_modeling-1.5.0}/phased_array/__init__.py +1 -1
  3. {phased_array_modeling-1.4.1 → phased_array_modeling-1.5.0}/phased_array/core.py +31 -8
  4. {phased_array_modeling-1.4.1 → phased_array_modeling-1.5.0}/phased_array/geometry.py +5 -1
  5. {phased_array_modeling-1.4.1 → phased_array_modeling-1.5.0}/phased_array_modeling.egg-info/PKG-INFO +1 -1
  6. {phased_array_modeling-1.4.1 → phased_array_modeling-1.5.0}/pyproject.toml +1 -1
  7. {phased_array_modeling-1.4.1 → phased_array_modeling-1.5.0}/tests/test_core.py +42 -3
  8. {phased_array_modeling-1.4.1 → phased_array_modeling-1.5.0}/tests/test_vector_patterns.py +5 -4
  9. {phased_array_modeling-1.4.1 → phased_array_modeling-1.5.0}/LICENSE +0 -0
  10. {phased_array_modeling-1.4.1 → phased_array_modeling-1.5.0}/README.md +0 -0
  11. {phased_array_modeling-1.4.1 → phased_array_modeling-1.5.0}/phased_array/beamforming.py +0 -0
  12. {phased_array_modeling-1.4.1 → phased_array_modeling-1.5.0}/phased_array/coordinates.py +0 -0
  13. {phased_array_modeling-1.4.1 → phased_array_modeling-1.5.0}/phased_array/export.py +0 -0
  14. {phased_array_modeling-1.4.1 → phased_array_modeling-1.5.0}/phased_array/impairments.py +0 -0
  15. {phased_array_modeling-1.4.1 → phased_array_modeling-1.5.0}/phased_array/polarization.py +0 -0
  16. {phased_array_modeling-1.4.1 → phased_array_modeling-1.5.0}/phased_array/utils.py +0 -0
  17. {phased_array_modeling-1.4.1 → phased_array_modeling-1.5.0}/phased_array/vector_patterns.py +0 -0
  18. {phased_array_modeling-1.4.1 → phased_array_modeling-1.5.0}/phased_array/visualization.py +0 -0
  19. {phased_array_modeling-1.4.1 → phased_array_modeling-1.5.0}/phased_array/wideband.py +0 -0
  20. {phased_array_modeling-1.4.1 → phased_array_modeling-1.5.0}/phased_array_modeling.egg-info/SOURCES.txt +0 -0
  21. {phased_array_modeling-1.4.1 → phased_array_modeling-1.5.0}/phased_array_modeling.egg-info/dependency_links.txt +0 -0
  22. {phased_array_modeling-1.4.1 → phased_array_modeling-1.5.0}/phased_array_modeling.egg-info/requires.txt +0 -0
  23. {phased_array_modeling-1.4.1 → phased_array_modeling-1.5.0}/phased_array_modeling.egg-info/top_level.txt +0 -0
  24. {phased_array_modeling-1.4.1 → phased_array_modeling-1.5.0}/setup.cfg +0 -0
  25. {phased_array_modeling-1.4.1 → phased_array_modeling-1.5.0}/tests/test_beamforming.py +0 -0
  26. {phased_array_modeling-1.4.1 → phased_array_modeling-1.5.0}/tests/test_coordinates.py +0 -0
  27. {phased_array_modeling-1.4.1 → phased_array_modeling-1.5.0}/tests/test_directivity.py +0 -0
  28. {phased_array_modeling-1.4.1 → phased_array_modeling-1.5.0}/tests/test_docstrings.py +0 -0
  29. {phased_array_modeling-1.4.1 → phased_array_modeling-1.5.0}/tests/test_export.py +0 -0
  30. {phased_array_modeling-1.4.1 → phased_array_modeling-1.5.0}/tests/test_geometry.py +0 -0
  31. {phased_array_modeling-1.4.1 → phased_array_modeling-1.5.0}/tests/test_impairments.py +0 -0
  32. {phased_array_modeling-1.4.1 → phased_array_modeling-1.5.0}/tests/test_polarization.py +0 -0
  33. {phased_array_modeling-1.4.1 → phased_array_modeling-1.5.0}/tests/test_utils.py +0 -0
  34. {phased_array_modeling-1.4.1 → phased_array_modeling-1.5.0}/tests/test_visualization.py +0 -0
  35. {phased_array_modeling-1.4.1 → phased_array_modeling-1.5.0}/tests/test_wideband.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: phased-array-modeling
3
- Version: 1.4.1
3
+ Version: 1.5.0
4
4
  Summary: Comprehensive Python library for phased array antenna modeling and visualization
5
5
  Author-email: John Hodge <jah70@vt.edu>
6
6
  License: MIT
@@ -33,7 +33,7 @@ Example
33
33
  >>> theta, phi, pattern_dB = pa.compute_full_pattern(geom.x, geom.y, weights, k)
34
34
  """
35
35
 
36
- __version__ = "1.4.1"
36
+ __version__ = "1.5.0"
37
37
 
38
38
  # Beamforming functions
39
39
  from .beamforming import ( # Amplitude tapers; Null steering; Multiple beams; Beam spoiling; Adaptive
@@ -304,6 +304,12 @@ def element_pattern(
304
304
  """
305
305
  Compute element pattern using raised cosine model.
306
306
 
307
+ The model is specified as a power pattern,
308
+ ``G(theta) = G0 * cos(theta)**cos_exp_theta``, but returned as the
309
+ corresponding field amplitude ``sqrt(G(theta))`` so it can be
310
+ multiplied directly into the (field) array factor. Pattern utilities
311
+ then form power as ``|EP * AF|**2``, which recovers ``G(theta)``.
312
+
307
313
  Parameters
308
314
  ----------
309
315
  theta : ndarray
@@ -311,18 +317,31 @@ def element_pattern(
311
317
  phi : ndarray
312
318
  Azimuthal angle in radians (not used; the model is phi-symmetric)
313
319
  cos_exp_theta : float
314
- Cosine exponent for theta dependence (1.0 = simple cosine)
320
+ Cosine exponent of the power pattern (1.0 = cos(theta) power
321
+ roll-off). The returned field uses half this exponent.
315
322
  cos_exp_phi : float
316
323
  Deprecated and unused. The basic model has no phi dependence;
317
324
  for polarized/phi-dependent element models see the v1.4 vector
318
325
  pattern API.
319
326
  max_gain_dBi : float
320
- Peak element gain in dBi
327
+ Peak element gain in dBi, applied as the field scale factor
328
+ ``10**(max_gain_dBi / 20)``.
321
329
 
322
330
  Returns
323
331
  -------
324
332
  pattern : ndarray
325
- Element pattern (linear scale, same shape as theta)
333
+ Element field amplitude (linear scale, same shape as theta). Zero
334
+ behind the element (theta > 90 degrees). Square it to get the
335
+ power pattern.
336
+
337
+ Examples
338
+ --------
339
+ >>> import numpy as np
340
+ >>> import phased_array as pa
341
+ >>> ep = pa.element_pattern(np.array([0.0]), np.array([0.0]),
342
+ ... max_gain_dBi=6.0)
343
+ >>> round(float(10 * np.log10(ep[0] ** 2)), 6)
344
+ 6.0
326
345
  """
327
346
  if cos_exp_phi != 1.0:
328
347
  warnings.warn(
@@ -334,14 +353,17 @@ def element_pattern(
334
353
  stacklevel=2,
335
354
  )
336
355
 
337
- # Convert max gain to linear
338
- max_gain_linear = 10 ** (max_gain_dBi / 10)
356
+ # Peak gain (power) -> peak field amplitude
357
+ max_field_linear = 10 ** (max_gain_dBi / 20)
339
358
 
340
- # Raised cosine pattern (only valid for forward hemisphere)
359
+ # Raised cosine pattern (only valid for forward hemisphere). Clip the
360
+ # base before exponentiating: np.where evaluates both branches, and a
361
+ # negative base with a fractional exponent would emit a NaN warning.
341
362
  cos_theta = np.cos(theta)
363
+ cos_forward = np.clip(cos_theta, 0.0, None)
342
364
  pattern = np.where(
343
365
  cos_theta > 0,
344
- max_gain_linear * (cos_theta ** cos_exp_theta),
366
+ max_field_linear * cos_forward ** (cos_exp_theta / 2.0),
345
367
  0.0
346
368
  )
347
369
 
@@ -376,7 +398,8 @@ def element_pattern_cosine_tapered(
376
398
  Element pattern (linear scale)
377
399
  """
378
400
  # Compute cosine exponent for desired beamwidth
379
- # At theta_3dB, pattern = 0.5 * max
401
+ # At theta_3dB, power pattern = 0.5 * max (element_pattern takes the
402
+ # power exponent and returns the field, so |EP|^2 is -3 dB here)
380
403
  # cos(theta_3dB)^n = 0.5
381
404
  # n = log(0.5) / log(cos(theta_3dB))
382
405
  theta_3dB = np.deg2rad(theta_3dB_deg)
@@ -991,7 +991,11 @@ def array_factor_conformal(
991
991
  k : float
992
992
  Wavenumber
993
993
  element_pattern_func : callable, optional
994
- Element pattern function
994
+ Element pattern function returning a field amplitude, evaluated
995
+ in each element's local frame. When omitted, elements with
996
+ normals use a cos(angle-to-normal) field pattern, which is a
997
+ cos^2 power pattern and matches
998
+ ``element_pattern_func=element_pattern, cos_exp_theta=2.0``.
995
999
  **element_kwargs
996
1000
  Arguments for element pattern function
997
1001
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: phased-array-modeling
3
- Version: 1.4.1
3
+ Version: 1.5.0
4
4
  Summary: Comprehensive Python library for phased array antenna modeling and visualization
5
5
  Author-email: John Hodge <jah70@vt.edu>
6
6
  License: MIT
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "phased-array-modeling"
7
- version = "1.4.1"
7
+ version = "1.5.0"
8
8
  description = "Comprehensive Python library for phased array antenna modeling and visualization"
9
9
  readme = "README.md"
10
10
  license = {text = "MIT"}
@@ -2,6 +2,8 @@
2
2
  Unit tests for phased_array.core module.
3
3
  """
4
4
 
5
+ import warnings
6
+
5
7
  import numpy as np
6
8
  import pytest
7
9
  import phased_array as pa
@@ -165,9 +167,46 @@ class TestElementPattern:
165
167
 
166
168
  pattern = pa.element_pattern(theta, phi, max_gain_dBi=6.0)
167
169
 
168
- # 6 dBi = 10^0.6 ~ 3.98 linear
169
- expected_gain = 10 ** (6.0 / 10)
170
- assert np.isclose(pattern[0], expected_gain)
170
+ # 6 dBi power gain = 10^(6/20) ~ 2.00 field amplitude
171
+ expected_field = 10 ** (6.0 / 20)
172
+ assert np.isclose(pattern[0], expected_field)
173
+ assert np.isclose(10 * np.log10(pattern[0] ** 2), 6.0)
174
+
175
+ def test_element_pattern_power_rolloff(self):
176
+ """cos_exp_theta is the power exponent: cos^1 power is -3 dB at 60 deg."""
177
+ theta = np.deg2rad(np.array([0.0, 60.0]))
178
+ phi = np.zeros_like(theta)
179
+
180
+ pattern = pa.element_pattern(theta, phi, cos_exp_theta=1.0)
181
+
182
+ rel_dB = 10 * np.log10(pattern[1] ** 2 / pattern[0] ** 2)
183
+ assert np.isclose(rel_dB, 10 * np.log10(0.5))
184
+
185
+ def test_element_pattern_rear_hemisphere_no_warning(self):
186
+ """Rear hemisphere is zero and emits no NaN RuntimeWarning."""
187
+ theta = np.linspace(0, np.pi, 181)
188
+ phi = np.zeros_like(theta)
189
+
190
+ with warnings.catch_warnings():
191
+ warnings.simplefilter("error", RuntimeWarning)
192
+ pattern = pa.element_pattern(theta, phi, cos_exp_theta=1.3)
193
+
194
+ assert np.all(np.isfinite(pattern))
195
+ assert np.all(pattern[theta > np.pi / 2] == 0.0)
196
+ # cos(pi/2) is ~6e-17 in floating point, so endfire is ~0, not exact
197
+ assert np.isclose(pattern[90], 0.0, atol=1e-6) # theta[90] = 90 deg
198
+
199
+ def test_cosine_tapered_half_power_beamwidth(self):
200
+ """element_pattern_cosine_tapered is -3 dB (power) at theta_3dB."""
201
+ theta = np.deg2rad(np.array([0.0, 65.0]))
202
+ phi = np.zeros_like(theta)
203
+
204
+ pattern = pa.element_pattern_cosine_tapered(
205
+ theta, phi, theta_3dB_deg=65.0
206
+ )
207
+
208
+ rel_dB = 10 * np.log10(pattern[1] ** 2 / pattern[0] ** 2)
209
+ assert np.isclose(rel_dB, 10 * np.log10(0.5))
171
210
 
172
211
 
173
212
  class TestPatternComputation:
@@ -96,7 +96,7 @@ class TestElementFactories:
96
96
  phi = np.deg2rad(np.linspace(0, 340, 20))
97
97
  E_theta, E_phi = f(theta, phi)
98
98
  power = np.abs(E_theta) ** 2 + np.abs(E_phi) ** 2
99
- scalar = pa.element_pattern(theta, phi, cos_exp_theta=2 * q)
99
+ scalar = np.abs(pa.element_pattern(theta, phi, cos_exp_theta=2 * q))**2
100
100
  assert np.allclose(power, scalar, atol=1e-12)
101
101
 
102
102
  def test_cos_q_gain_scale(self):
@@ -329,8 +329,9 @@ class TestConformalVector:
329
329
  )
330
330
 
331
331
  def test_scalar_conformal_regression(self):
332
- # array_factor_conformal default cos-pattern and cos^1 element
333
- # func agree after the local-frame fix
332
+ # array_factor_conformal's default cos(angle) field pattern is a
333
+ # cos^2 power pattern, so it matches element_pattern with the
334
+ # power exponent cos_exp_theta=2 (evaluated in the local frame)
334
335
  cyl = pa.create_cylindrical_array(8, 4, radius=1.0, height=2.0)
335
336
  k = pa.wavelength_to_k(1.0)
336
337
  w = np.ones(cyl.n_elements, dtype=complex)
@@ -339,7 +340,7 @@ class TestConformalVector:
339
340
  )
340
341
  af_cos = pa.array_factor_conformal(
341
342
  np.array([0.3]), np.array([0.1]), cyl, w, k,
342
- element_pattern_func=pa.element_pattern, cos_exp_theta=1.0,
343
+ element_pattern_func=pa.element_pattern, cos_exp_theta=2.0,
343
344
  )
344
345
  assert np.allclose(af_default, af_cos, atol=1e-9)
345
346