Package: plot-antenna
Author:Ralf Schlatterbeck <rsc@runtux.com>This is a program to plot antenna-related data resulting from an antenna
simulation. It can read the text output produced bynec2cand my
python mininec portpymininec. Most notably it can plot antenna
far-field pattern in both 2D (Azimuth and Elevation) and 3D (as a 3D
graphic that can be rotated and zoomed). It supports a local display
program (usingmatplotlib) and a HTML output version that displays
everything using javascript (usingplotly). The program features a--helpoption. If the program called with--helpdoes not
display a-Hor--export-htmloption, you most likely do not
have a recent version ofplotlyinstalled. In that case only thematplotlibvariant is available. For the plotly variant to work you
need both, a recent version ofplotlyas well aspandasinstalled.The program started out as a companion-program to mypymininecproject and is now an independent program.The plot program can also display output files ofnec2c, not only
frompymininec.Standalone Plotting with MatplotlibThe default is to plot all available
graphics, including an interactive 3d view. In addition with the--azimuthor--elevationoptions you can get an Azimuth
diagram:plot-antenna --azimuth test/12-el-1deg.poutor an elevation diagram:plot-antenna --elevation test/12-el-1deg.poutrespectively. Note that I used an output file with 1-degree resolution
in elevation and azimuth angles not with 5 degrees as in the example
above. The pattern look smoother but a 3D-view will be very slow due to
the large number of points. The plot program also has a--helpoption for further information. In particular the scaling of the antenna
plot can be selected using the--scaling-methodoption with an
additional keyword which can be one oflinear,linear_db, andlinear_voltagein addition to the default ofarrlscaling. You
may consult Cebik’s[1]article for explanation of the different
diagrams. Thelinear_voltageoption is not explained by Cebik, it is
in-between thelinearandlinear_dbscaling options.The latest version accepts several plot parameters,--elevation,--azimuth,--plot3d,--plot-vswr, and--geowhich are
plotted into one diagram. The default is to plot the first four graphs.
With the--outputoption pictures can directly be saved without
displaying the graphics on the screen. Note that unfortunately the
geometry display with the--geooption does not perform very well
becausematplotlibhas poor support for panning and scaling in 3D
plots.The latest version has key-bindings for scrolling through the
frequencies of an antenna simulation. So if you have an output file with
a simulation of multiple frequencies (either withpymininecornec2c) you can display diagrams for the next frequency by typing+, and to the previous frequency by typing-. For newer versions
ofmatplotlibyou can display a scrollbar for the frequencies with
the--with-slideroption.Other keybindings switch the scaling for the antenna plots,aswitches toarrlscaling,lswitches to linear scaling,dswitches to linear dB scaling, andvswitches to linear voltage
scaling.Finally thewkey toggles display of the 3d diagram from/to
wireframe display. Note that the wireframe display may not be supported
on all versions ofmatplotliband/or graphics cards.Plotting for the Browser with PlotlyAll the plot supported formatplotlibare also supported withplotly.
These are--elevation,--azimuth,--plot3d,--plot-vswr,
and--geo. The plots can be either exported to a .html file using
the-Hor--export-htmloption (with an additional filename to
export to) or injected into a running browser using the-Sor--show-in-browseroption.Unlike formatplotlib, each plot selected with an option is either
shown in a separate window in the browser or exported to a separate
file. If exporting to a file, additional output options can be selected
with the--html-export-optionsetting. The default is to export the
file with all javascript included (adds about 3MB to the file size).
With--html-export-option=directorythe javascript is not included
and aplotly.min.jsfile is expected in the same directory as the
exported file. This file ships with theplotlydistribution. When
exporting to a file, the plot name is appended to the file name given,
this allows export to several different plots in one program invocation.The scaling variants selected with the--scaling-methodoption
cannot currently be changed at runtime with theplotlyplots. As withmatplotlib, the default isarrlscaling.All plots are interactive. For the far-field pattern
plots (Azimuth, Elevation, 3D) frequencies can be selected in the legend
to the right of the plot. With mouse-over you can see the current angle
(Elevation or Azimuth with the 2D plots and both for the 3D plot) and
the gain at that point. For the 2D variants, more than one frequency can
be selected for plotting. This allows comparison of pattern between
different frequencies. For the 3D plot, the frequencies in the legend
act like radio-buttons, only one at a time can be selected.With the--geooption you get a display of the antenna geometry.
Unfortunatelyplotlyseems to have limitations on the zoom depths, so
for large antennas it is not possible to see the plot in deep detail. As
of this writing not all geometry details are displayed. In particular 2D
patches in NEC, transmission lines in NEC, and visualization of loaded
segments (e.g. with a capacity) are not shown.[1]L. B. Cebik. Radiation plots: Polar or rectangular; log or linear.
In Antenna Modeling Notes [2], chapter 48, pages 366–379. Available
in Cebik’sAntenna modelling notes episode 48[2]L. B. Cebik. Antenna Modeling Notes, volume 2. antenneX Online
Magazine, 2003. Available with antenna models from theCebik
collection.Release Notesv1.8: Allow plotting of measurement dataDeal with sparse matrix for plot valuesInterpolation of measured values in Phi (Azimuth) directionAdd STL output of 3d pattern with optional libraryAllow setting the dB-unit (e.g. dBm for measurements)Allow plotting by polarizationVersion computation changed to allow install from git urlNote: Smith chart with matplotlib currently needs mypatched pySmithPlotlibrary. You can install this with:python -m pip install pysmithplot@git+https://github.com/schlatterbeck/pySmithPlot.gitv1.7: Add Smith charts, optionally show impedance and band in VSWR plotsMany of the changes in this and several previous versions were suggested
by Rob Banfield, DM1CM: Adding the bands and impedance to the VSWR plot
are his idea as well as adding a Smith chart. Due to his attention to
detail this release corrects a lot of rough edges of previous versions.
Thanks Rob!The aspect ratio in 3D plotly plots is now correct. It used to be a
little too wide in the X directionAdd Smith chart displayOptions to add the impedance (either as real/imag or |Z|/phi (Z)) in
the VSWR plotOption to show the ham radio bands in the VSWR plotShow loads and excitation(s) in geo plot, add ground to geo plotMargin of 3D plots in plotly are much wider now by default and can be
configured with an optionThe style how the gain is displayed in the plotly 3D color bar can now
be configured to save space (either relative or absolute gain in dB or
dBi, the default is both)When there is only one frequency in the 3D plot, remove the frequency
legendAdd LICENSE file and pyproject.toml for newer install mechanisms in
pythonAdd tests for plotly outputUse ppm images for the tests, the previously-used png images did
contain the matplotlib version and thus were different for each
version – the ppm images do not have that problem, there are still
many differences with different matplotlib versionsv1.6: More SWR plot changesMake SWR-plot vertical line colors configurableRename elevation-angle and azimuth-angle options to angle-elevation
and angle-azimuth so that we can again request an elevation/azimuth
plot with shortened options like –ele or –aziSort options lexicographically on –helpv1.5: Allow target SWR frequency in VSWR plotAdd command-line option –target-swr-frequencyDraw user-specifed target frequency in red, best (minimum) swr in greyv1.4: Reset button and VSWR-Plot improvementsAdd grid and minimum-SWR vertical line to VSWR plotRemove display of frequency in mouse-over (in polar plots and 3D plot)Make polar reset button reset more parametersv1.3: Add a reset button to plotly polar plotsThe polar plots, when zoomed in, could only be reset to the unzoomed
view with a double-click. All other plots do have a reset button, add
one for the polar plots, too.v1.2: Allow specification of title (legend) font size in plotly versionFor some application (e.g. when using the plotly graphics inside a
html iframe) the title (or we may want to call it legend) of the
graphics may collide with the graphics itself. We can now specify the
font size with--title-font-size. This option currently works only
with plotly graphics.v1.1: Specification of azimuth / elevation angleNow we can specify an azimuth angle for elevation plot and an
elevation angle for azimuth plots.Bug-fix in computation of maximum gain azimuth direction: If the
maximum gain in theta direction goes up or down, the azimuth angle
would be computed incorrectly because all gain values at that theta
angle are the same for all azimuth angles.Sort options: Since there are some options that only exist when some
packages are installed we sort options instead of trying to add them
in the correct order.v1.0: Initial Release