.. title: Plotting Antenna Pattern
.. slug: 31
.. date: 2024-08-31 19:30
.. tags: documentation,english,howto,hamradio,antenna modeling
.. description:
.. wp-status: publish

.. |--|  unicode:: U+2013  .. en dash
.. |ohm| unicode:: U+02126 .. Omega
   :trim:
.. |_| unicode:: U+00A0 .. Non-breaking space
   :trim:

[Update 2025-12-04: Fix links in bibliography]

I'm the author of an antenna plotting program called plot-antenna_. It is
written in python and has graphics backends for both, matplotlib_ and
plotly_. As of this writing the `version available on pypi`_ does not
yet support different frequency resolution for pattern and impedance plots.
The matplotlib_ backend is better when generating graphics for
use in printed documentation while the plotly_ backend can generate
interactive graphics for the web. The documentation contains some
matplotlib_ examples, so I'm going into more detail here for the plotly_
backend.

I've recently added support for the "Antenna Scatterers Analysis
Program" ASAP_, an antenna simulation program written before the
Fortran_-77 Standard in 1974. It is still interesting today because it uses a
formulation for the `Method of Moments`_ [1]_ [2]_ that is different
from both, NEC [3]_ and Mininec_ [4]_. And it pioneered the simulation of
wire insulation when an antenna uses insulated elements.

In the following I'm using a 3-Element Yagi-Uda antenna that is in the
`Example Section`_ of ASAP_. The `input file`_ I'm using exports antenna
pattern for 280 MHz to 305 MHz in 5 MHz steps. In addition it exports
antenna impedance in 1 MHz steps.

.. TEASER_END

When plotting, plot-antenna_ can use different scaling methods for the
antenna pattern. The default is ARRL scaling [5]_ which I'm using in the
following example.

.. iframe:: /content/2024/08/plotly/3-ele-plot3d.html
    :width:  1000
    :height: 640

The 3D plot can switch the frequency in the legend on the right side,
by clicking on a frequency the display switches to the antenna pattern
for that frequency. In addition on mouse-over the gain values at
different positions in the 3D-plot can be seen. It is possible to zoom
with the mouse wheel and turn the plot by clicking and dragging.

Of course plot-antenna_ can also display the conventionaly 2D plots for
Azimuth and elevation:

.. iframe:: /content/2024/08/plotly/3-ele-azimuth.html
    :width: 800
    :height: 640

.. iframe:: /content/2024/08/plotly/3-ele-elevation.html
    :width: 800
    :height: 640

With the 2D display in the legend on the right side, multiple traces can
be enabled at once. This way it is easier to compare gain pattern than
with the 3D plot where only one pattern can be shown at a time. Similar
to the 3D-plot we can also see the gain values on mouse-over. It is
possible to zoom (althought this is not very useful in a polar plot) and
reset to the default view with the "Home" button in the menu.

Often it is useful to see the voltage standing-wave ratio and the antenna
impedance. This is achieved with the VSWR plot. In the following plot
I've turned on view of the impedance using the ``--swr-show-impedance``
option. The vertical green line indicates the position of minimum VSWR.
Again we can see the plotted values on mouse-over. We can zoom in by
selecting a rectangle with the mouse or by using the +/- buttons in the
menu. The view can be reset to the default using the "Home" button in
the menu.

.. iframe:: /content/2024/08/plotly/3-ele-plot_vswr.html
    :width: 1000
    :height: 640

Last not least we can plot the antenna geometry. This is again a 3D plot
where we can show the positions of the antenna elements on mouse-over.
In the legend on the right we can turn off the visibility of the feed
point (in orange). Other antennas may show a ground plane in this view
or additional impedance loading on the antenna. The geometry view is
very useful to check if the antenna has been modeled correctly (e.g. if
the feed point is at the correct position).

.. iframe:: /content/2024/08/plotly/3-ele-geo.html
    :width: 1000
    :height: 640

The program plot-antenna_ currently supports output from ASAP_, the
original Mininec_ core (written in Basic), my Python version pymininec_,
and output of NEC-2_. The format is auto-detected. In addition, with the
companion-program ``plot-eznec``, the gain pattern exported from EZNEC_
can be displayed.  As of this writing there is a not-yet released
version that can also display VSWR plots using the data exported by
EZNEC_ when plotting VSWR in a file called ``LastZ.txt``.


.. [1] J. H. Richmond. Radiation and scattering by thin-wire structures
       in the complex frequency domain. Contractor Report CR-2396, NASA,
       Columbia, Ohio, May 1974. Available as `CR-2936`_
.. [2] Jerry Wayne McCormack. "ASAP" antennas-scatterers analysis
       program, a general purpose user-oriented computer program for
       analysis of thin-wire structures in the presence of finite
       ground. Master’s thesis, Naval Postgraduate School, Monterey,
       California, December 1974. `Thesis available here`_
.. [3] G. J. Burke and A. J. Poggio. Numerical electromagnetics code (NEC)
       |--| method of moments, `Part I: Program description`_ |--| theory.
       January 1981.
.. [4] J. C. Logan and J. W. Rockway. The new MININEC (version 3): A
       mini-numerical electromagnetic code. Technical Report NOSC TD
       938, Naval Ocean Systems Center (NOSC), San Diego, California,
       September 1986. Available as ADA181682_ or in a better-readable
       `transcribed version from github`_.
.. [5] L. B. Cebik. Radiation plots: Polar or rectangular; log or linear.
       In Antenna Modeling Notes [6]_, chapter 48, pages 366–379. Available
       in Cebik's `Antenna modelling notes episode 48`_
.. [6] L. B. Cebik. Antenna Modeling Notes, volume 2. antenneX Online
       Magazine, 2003. Available with antenna models from the `Cebik
       collection`_.


.. _`input file`: /content/2024/08/plotly/3-ele.asap
.. _ASAP: http://raylcross.net/asap/index.html
.. _`Example Section`: http://raylcross.net/asap/asapexam/yagi.html
.. _ADA181682: https://apps.dtic.mil/sti/citations/ADA181682
.. _`CR-2936`: https://ntrs.nasa.gov/citations/19740013743
.. _`Thesis available here`: https://calhoun.nps.edu/handle/10945/16899
.. _`transcribed version from github`:
    https://github.com/schlatterbeck/mininec-3-doc
.. _Fortran: https://en.wikipedia.org/wiki/Fortran
.. _`Method of Moments`:
    https://en.wikipedia.org/wiki/Method_of_moments_(electromagnetics)
.. _pymininec: https://github.com/schlatterbeck/pymininec
.. _Mininec: https://github.com/schlatterbeck/MiniNec
.. _`NEC-2`: https://en.wikipedia.org/wiki/Numerical_Electromagnetics_Code
.. _`Part I: Program description`: https://nec2.org/other/nec2prt1.pdf
.. _`Cebik collection`:
    https://q82.uk/projects/cebik/modelling/W4RNL%20Antenna%20Modelling%20Notes%20Volume%202.pdf
.. _`Antenna modelling notes episode 48`:
   https://web.archive.org/web/20230816225141/http://on5au.be/content/amod/amod48.html
.. _Matplotlib: https://matplotlib.org/
.. _Plotly: https://github.com/plotly/plotly.py
.. _`plot-antenna`: https://github.com/schlatterbeck/plot-antenna
.. _`version available on pypi`: https://pypi.org/project/plot-antenna/
.. _`EZNEC`: https://eznec.com/
