Skip to content

Command line

antennaknobs has a command-line interface for batch work. The subcommands:

python -m antennaknobs {draw,sweep,optimize,pattern,compare_patterns,params,export,list}
CommandWhat it does
listList available designs (built-in and user)
drawDraw the antenna geometry
sweepSweep a parameter or frequency
patternPlot the far-field pattern
compare_patternsOverlay the patterns of several antennas / engines
optimizeOptimize an antenna’s parameters
paramsPrint a design’s knob values as paste-ready Python
exportExport the design to a NEC-2 .nec card deck

Designs are addressed as family.name (the same names list prints):

Terminal window
python -m antennaknobs list # arrays.bowtiearray, beams.yagi, loops.delta_loop, ...
Terminal window
# Far-field pattern of a Yagi, solved with momwire's triangular basis
python -m antennaknobs pattern --builder beams.yagi --engine momwire:triangular

Useful pattern flags: --fn out.png (write to a file instead of the screen), --ground free|pec|finite|finite:<eps_r>,<sigma>, --wireframe, and --elevation_angle.

The --engine flag selects the solver:

Terminal window
--engine momwire # momwire (default), default (triangular) basis
--engine momwire:triangular # piecewise-linear (tent) basis
--engine momwire:sinusoidal # NEC-2-style three-term basis
--engine momwire:bspline # B-spline Galerkin basis
--engine momwire:hmatrix # B-spline + hierarchical-matrix (ACA) acceleration
--engine momwire:arrayblock # element-aware block solver for arrays
--engine pynec # the NEC-2 reference backend (needs pynec-accel)

momwire is the default so a plain install works without the optional pynec-accel package. See The solver & accuracy for which engine to reach for — including when the accelerated hmatrix / arrayblock solvers pay off.

Solve the same design two ways and overlay the patterns — the built-in cross-validation:

Terminal window
python -m antennaknobs compare_patterns \
--builders beams.moxon beams.moxon \
--engines pynec momwire:bspline --fn check.png

Alongside the overlaid plot, compare_patterns prints a metrics table — peak gain (dBi), takeoff angle, front-to-back, and −3 dB azimuth/elevation beamwidths — one row per antenna, so the comparison comes with numbers, not just shapes:

design peak dBi takeoff° F/B dB az bw° el bw°
----------------------------------------------------------------
dipoles.invvee 1.93 1 0.0 85 89
beams.yagi 8.89 1 8.2 60 42

After tuning — in the workbench or with optimize — turn the knob values back into source you can paste into a design file. params prints a design’s (or a name:variant’s) current values as a default_params = {...} block:

Terminal window
python -m antennaknobs params --builder beams.yagi
python -m antennaknobs params --builder specialty.hentenna:z100 --wrap mappingproxy

Useful flags: --name <var> (name the emitted block), --no-ui (knob values only, drop the ui_params block), and --wrap mappingproxy (match the catalog’s frozen-params style). An optimize run ends by printing the same paste-ready block for its result, so the tuned values go straight into code.

Terminal window
python -m antennaknobs export --builder beams.yagi --fn yagi.nec

The deck is validated against nec2c, so designs round-trip into other NEC tools.