Modeling Antenna Patterns with Python: What the Model Can Prove
Modeling Antenna Patterns with Python: What the Model Can Prove
Python can make the physics behind lobes, nulls and phasing visible. The useful question is not whether it replaces an electromagnetic solver, but whether the model matches the claim you want to make.
A short Python program can sum the far-field contributions of prescribed current elements and reveal how geometry, phase, amplitude and wavelength produce a pattern. That is real electromagnetic modelling. It is also a conditional result: if the currents were assumed rather than solved, the plot proves what those assumed currents radiate—not what a particular installed antenna must do.
Python Is the Workbench, Not the Model
Python, NumPy and Matplotlib provide arrays, complex arithmetic and plotting. They do not decide which electromagnetic problem is being solved. A Python program can implement a simple array factor, integrate a known current distribution, solve a method-of-moments matrix or call a full-wave solver. The validity comes from the equations, boundary conditions and inputs—not the programming language.
For rapid pattern exploration, the most useful lightweight model starts with currents that you prescribe. A NEC-class program takes a different route: it represents conductors and surfaces, applies excitation and boundary conditions, solves integral equations numerically for induced currents, and derives fields and circuit quantities from that solution.
| Prescribed-current field sum | NEC-class electromagnetic solution |
|---|---|
| Starts with segment or element currents supplied by the modeller | Starts with geometry, excitation, materials and environmental assumptions |
| Calculates the field conditional on those currents | Solves an approximate numerical electromagnetic problem for the currents |
| Excellent for exposing phase addition, cancellation and trends | Needed when geometry-dependent current, coupling and input quantities matter |
| Does not inherently predict feedpoint impedance, accepted power or loss | Can calculate impedance, currents and fields within the solver's formulation and model |
| Easy to sweep and inspect because every assumption is visible | More complete, but still only as faithful as its geometry, segmentation and boundaries |
From Current Elements to a Far-Field Pattern
Divide a thin conductor into electrically short directed segments. For segment n, declare its midpoint rn, directed length Δln and complex current In. For an observation unit vector r̂, a useful relative far-field sum is:
F(r̂) ∝ Σ In [Δln − r̂(r̂ · Δln)] exp(+jk r̂ · rn)
Here k = 2π/λ. The bracket projects each directed current element into the plane transverse to the observation direction. The exponential carries the position-dependent phase. Its sign changes if you choose the opposite time convention; consistency throughout the model is what matters.
The common range, propagation and physical constants can be omitted when only a normalized angular pattern is required. They must not be omitted when comparing absolute field, gain, accepted power or efficiency.
This compact NumPy function retains the vector field rather than collapsing polarization into one scalar:
import numpy as np
def prescribed_current_field(midpoints_m, dl_vectors_m,
currents_a, look_vectors,
wavelength_m):
"""Relative far field for prescribed short current elements.
look_vectors must contain unit vectors. The result omits the
common propagation and physical constants, so it is suitable
for a normalized pattern, not absolute gain or efficiency.
"""
k = 2.0 * np.pi / wavelength_m
radial_part = np.einsum("oi,ni->on", look_vectors, dl_vectors_m)
transverse = (
dl_vectors_m[None, :, :]
- look_vectors[:, None, :] * radial_part[:, :, None]
)
phase = np.exp(1j * k * (look_vectors @ midpoints_m.T))
return np.sum(
currents_a[None, :, None] * phase[:, :, None] * transverse,
axis=1,
)
That function is only the radiation integral. The difficult question remains upstream: where did the complex current assigned to every segment come from?
The Current Assumption Decides the Answer
A sinusoidal current approximation can give excellent intuition for a thin, isolated, centre-fed dipole near its intended mode. It becomes less trustworthy when the wire is bent, loaded, coupled to another conductor, fed asymmetrically or surrounded by a real installation. A travelling-wave taper for a Beverage-like wire is likewise a hypothesis until propagation, termination, ground coupling and return paths support it.
For an array, equal element currents with a chosen phase progression create an ideal array-factor study. A real feed network supplies voltages through finite impedances. Mutual coupling then changes the element currents, while cable loss, delay, amplitude error and element-pattern differences alter the combined pattern. Steering an ideal null in code is not the same as demonstrating its depth at the antenna terminals or in a field test.
Normalization Can Hide the Result
Normalizing every plot to its own maximum is useful for comparing pattern shape. It also forces the largest value in every model to 0 dB. A lossy antenna, an efficient antenna and a model with arbitrary current amplitude can therefore display equally impressive normalized maxima.
- Relative field pattern: use 20 log10(|E|/|E|max) and state the polarization component or vector magnitude.
- Relative power pattern: use 10 log10(P/Pmax).
- Directivity: requires integration over the complete radiation sphere, not one azimuth or elevation cut.
- Gain: requires an efficiency reference in addition to directivity.
- Realized gain: also includes mismatch at a declared reference impedance and plane.
Do not use separately normalized plots to claim an efficiency, gain or SNR advantage. Preserve one absolute reference, accepted-power normalization or calibrated measurement appropriate to the comparison.
What the Lightweight Model Shows Well
- How path-length phase and excitation phase create lobes and nulls
- How electrical spacing changes an ideal array factor with frequency
- How amplitude taper changes sidelobes and beamwidth under declared normalization
- How a prescribed wire-current distribution contributes to polarization and pattern
- How an ideal conducting-plane reflection changes an elevation pattern
- How sensitive a result is to phase, amplitude, placement or frequency error
These models are especially strong when used to isolate one mechanism. If moving one element by 0.02λ shifts a null, the code makes that sensitivity obvious. If the result changes drastically when a plausible current taper is altered, the model has also told you something valuable: the conclusion depends on a current distribution that needs stronger evidence.
What It Does Not Establish by Itself
- Feedpoint impedance, SWR or the impedance presented to a particular transmitter
- The actual current created by mutual coupling, nearby conductors or an asymmetric feed
- Conductor, dielectric, ground, transformer, loading-coil or termination loss
- Accepted power, efficiency, gain, heating, voltage stress or a power rating
- Common-mode current on coax, mast, control wiring or station bonds unless that path is included
- An installed takeoff angle, null depth or SNR result without environmental and measurement evidence
A model cannot discover a conductor that was never entered. If the coax exterior, mast, balcony, rainwater path or station wiring carries RF current, the real antenna is larger than the clean drawing.
Ground Changes the Question
Translating an isolated antenna upward in free space does not change its far-field pattern; there is no ground reference against which “height” can act. Height-dependent elevation lobes appear only after a reflecting or lossy boundary and the antenna's relation to it are included.
Image theory can represent an infinite perfectly conducting plane and is excellent for seeing direct-and-reflected-field interference. Real earth is not a perfect mirror. Reflection depends on frequency, angle, polarization, conductivity, permittivity and the assumed ground model. Layering, terrain, buildings, vegetation and finite radial systems can move the installation far from the ideal case.
Therefore a simple perfect-ground plot is an explanation of a mechanism, not a site-specific takeoff-angle prediction. Declare the ground model and compare it with a lossy-ground solution or measurement before attaching a performance conclusion.
Segment Count Is a Convergence Question
There is no universal segment count that certifies every geometry. Segment length must resolve changes in geometry, phase and current. Feed regions, bends, loads and close conductor spacing can demand finer treatment than a smooth isolated wire.
Repeat the calculation with progressively finer segmentation. Track the quantities that matter—lobe direction, beamwidth, null position, polarization component and any absolute normalization. A result is numerically credible only when further refinement changes those quantities by less than the tolerance required for the decision.
Convergence does not prove the physical assumptions. It proves that the numerical approximation has stabilized for the model you wrote.
A Defensible Modelling Workflow
- Name the claim. Pattern shape, null direction, input impedance, realized gain and installed SNR are different questions.
- Declare coordinates and conventions. Record units, frequency, polarization basis, time convention, observation cuts and normalization.
- Identify how currents were obtained. Separate an assumed distribution, a measured distribution and a solved distribution.
- Run sensitivity and convergence checks. Vary segment size and every uncertain input that could reverse the conclusion.
- Compare with a reference case. Use a closed-form result where available or reproduce the same idealized geometry in an independent solver.
- Add the omitted current paths deliberately. Include feedline exterior, return structure and nearby conductors when the claim depends on them.
- Validate at the claim's measurement plane. Impedance, current, field pattern, gain and receiver SNR require different fixtures and uncertainty statements.
Simple Python models and NEC/MMANA-type tools belong in the same engineering workflow. Start with the transparent model to expose the mechanism. Use a current-solving model when geometry and coupling decide the currents. Use calibrated measurements to test the built installation. Agreement between them is evidence; an attractive plot by itself is not.
Primary and authoritative references
- Burke and Poggio — Numerical Electromagnetics Code, Method of Moments: theory, code and user's guide
- Lawrence Livermore National Laboratory — Present Capabilities and New Developments in Antenna Modeling with NEC
- IEEE 149-2021 — Recommended Practice for Antenna Measurements
- IEEE 145-2025 — Standard for Definitions of Terms for Antennas
- NumPy reference documentation
- Matplotlib polar-plot documentation
Mini-FAQ
- Does Python replace NEC or MMANA? No. Python is a programming environment. A prescribed-current Python model exposes pattern mechanisms; a current-solving electromagnetic model is needed when geometry and coupling determine the currents.
- What does a prescribed-current model calculate? It calculates the field produced if the declared complex currents flow on the declared segments or elements. It does not prove that a real feed system creates those currents.
- Can this model predict SWR? Not from field summation alone. SWR requires input impedance at a declared reference plane and reference impedance, including the relevant feed and matching network.
- Can a simple model include ground? Yes, but the result belongs to the selected ground model. A perfect image plane explains reflection trends; real-earth conclusions require conductivity, permittivity, geometry and validation.
- How many segments are enough? There is no universal count. Refine the segmentation until the quantities used for the decision converge within a stated tolerance, then test whether the physical assumptions are credible.
- Can normalized patterns compare efficiency? No. Normalizing each pattern to its own maximum removes absolute amplitude. Efficiency or gain comparisons require accepted-power, loss and calibration information.