Python NEC2++ Module
This module wraps the C++ API for antenna simulation of nec2++. It is easier to work with, and more powerful than the C-style API wrapper. Works with Python 2.7 and 3+.
Usage
Here is an example that plots a radiation pattern.
from PyNEC import *
import numpy as np
#creation of a nec context
context=nec_context()
#get the associated geometry
geo = context.get_geometry()
#add wires to the geometry
geo.wire(0, 36, 0, 0, 0, -0.042, 0.008, 0.017, 0.001, 1.0, 1.0)
context.geometry_complete(0)
context.gn_card(-1, 0, 0, 0, 0, 0, 0, 0)
#add a "ex" card to specify an excitation
context.ex_card(1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0)
#add a "fr" card to specify the frequency
context.fr_card(0, 2, 2400.0e6, 100.0e6)
#add a "rp" card to specify radiation pattern sampling parameters and to cause program execution
context.rp_card(0, 91, 1, 0, 5, 0, 0, 0.0, 45.0, 4.0, 2.0, 1.0, 0.0)
#get the radiation_pattern
rp = context.get_radiation_pattern(0)
# Gains are in decibels
gains_db = rp.get_gain()
gains = 10.0**(gains_db / 10.0)
thetas = rp.get_theta_angles() * 3.1415 / 180.0
phis = rp.get_phi_angles() * 3.1415 / 180.0
# Plot stuff
import matplotlib.pyplot as plt
ax = plt.subplot(111, polar=True)
ax.plot(thetas, gains[:,0], color='r', linewidth=3)
ax.grid(True)
ax.set_title("Gain at an elevation of 45 degrees", va='bottom')
plt.savefig('RadiationPattern.png')
plt.show()
Manual Build & install
Requirements
- Pandoc
- Swig
- For Windows: C/C++ compilers.
- Git bash (for running build.sh script)
- Latest python packages: pip, setuptools, numpy, wheel, numpy. Run:
$ pip install --upgrade pip setuptools wheel numpy
Note: Download and extract swigwin.zip and add the path to swig.exe to environment.
Then do following:
$ git clone --recursive https://github.com/tmolteno/python-necpp.git
$ cd python-necpp
$ cd PyNEC
$ ./build.sh
$ python setup.py bdist_wheel (For generating wheel, requires wheel package)
$ sudo python setup.py install
Note: 'sudo' is not required in windows.
Install from PyPI
$ sudo pip install pynec
Note: 'sudo' is not required in windows.
Testing
Requirements
-
python package: matplotlib
$ python example/test_rp.py
The example directory contains the following additional examples (that are inspired by excercises from a course on antennas):
- logperiodic_opt.py is an example on how to combine PyNECPP with scipy.optimize to use a genetic algorithm to optimize an antenna for multiple frequency bands at the same time (which I thin is not possible in 4nec2). The resulting gains and VSWR are plotted over the frequency range of interest. This requires scipy >= 0.15.0 due to the usage of scipy.optimize.differential_evolution.
- monopole_realistic_ground_plane.py plots the vertical gain pattern of a monopole antenna. Its dimensions are optimized with a local search, and the path through the search space is visualized with a heat map.
- dipole.py does a very simple optimization of a dipole, and plots the VSWR over a given frequency range for different system impedances to file.
Metadata
Release files for pynec-accel 1.7.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distributions (wheels)
Total release size: 126.1 MB
Release files / pynec_accel-1.7.6-cp314-cp314-win_amd64.whl
| Download URL | pynec_accel-1.7.6-cp314-cp314-win_amd64.whl |
|---|---|
| Size | 7.3 MB |
| Tags | CPython 3.14 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
b489ffe4fafd13e76f1560286b11c58ae2cce3236ecfc729090a1b51d80766f5
|
|
BLAKE2b-256 checksum How to use checksums |
70eeb3d3542754c6fd8d972bffa6a2ae58efcd19e1bb8f5ee6abfa9bca1f09e5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 23, 2026.
Transparency logRelease files / pynec_accel-1.7.6-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | pynec_accel-1.7.6-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl |
|---|---|
| Size | 11.1 MB |
| Tags | CPython 3.14 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
1b8dd5309a4b782a2b80ae01cd3a017e481c0694de2a2cf59cef86a385aef6e2
|
|
BLAKE2b-256 checksum How to use checksums |
6470d408186c54a3fa8361f434e28bab7f72868ae1ba6480b3cc4c0ddf47f552
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 23, 2026.
Transparency logRelease files / pynec_accel-1.7.6-cp314-cp314-macosx_14_0_arm64.whl
| Download URL | pynec_accel-1.7.6-cp314-cp314-macosx_14_0_arm64.whl |
|---|---|
| Size | 6.9 MB |
| Tags | CPython 3.14 macOS 14.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
3af6982579d1769796e598a3fc8a9df41876e1981d8cf6f28812cbc1d6b5d7be
|
|
BLAKE2b-256 checksum How to use checksums |
b91855259a3a5841ef38f9cd46ff5bb3341deeff146c51ad5e5a8e1336e2be44
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 23, 2026.
Transparency logRelease files / pynec_accel-1.7.6-cp313-cp313-win_amd64.whl
| Download URL | pynec_accel-1.7.6-cp313-cp313-win_amd64.whl |
|---|---|
| Size | 7.2 MB |
| Tags | CPython 3.13 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
f38c7c4da1c9ceab18a0ab15ff7700d3dfbe2bf6894ac1689228f3ad21b5e385
|
|
BLAKE2b-256 checksum How to use checksums |
db13956f3c400c5d3a270a646b01b1c5ee922e084be8cafc672be3e42de3b742
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 23, 2026.
Transparency logRelease files / pynec_accel-1.7.6-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | pynec_accel-1.7.6-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl |
|---|---|
| Size | 11.1 MB |
| Tags | CPython 3.13 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
3d4707f6176bb0b952a3c20ef5e674b73fe792a0b7c902db2c8ea401ae055a92
|
|
BLAKE2b-256 checksum How to use checksums |
9253b89068a8115d44fa2a60a7e86f28fc1cc6829c189144667032830b36aa4b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 23, 2026.
Transparency logRelease files / pynec_accel-1.7.6-cp313-cp313-macosx_14_0_arm64.whl
| Download URL | pynec_accel-1.7.6-cp313-cp313-macosx_14_0_arm64.whl |
|---|---|
| Size | 6.9 MB |
| Tags | CPython 3.13 macOS 14.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
eba48468f31fe03682f055aa0a4e228a86bec230e948362f0701b906f71aa4d0
|
|
BLAKE2b-256 checksum How to use checksums |
7c6f249a661d2c81a3c8d2abb28077e53313f3e0057d8e6593c463d4344b19ee
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 23, 2026.
Transparency logRelease files / pynec_accel-1.7.6-cp312-cp312-win_amd64.whl
| Download URL | pynec_accel-1.7.6-cp312-cp312-win_amd64.whl |
|---|---|
| Size | 7.2 MB |
| Tags | CPython 3.12 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
b9e5f2b2b4786ff9e6cfc3a32e0da4dbab7eeab7fa724485e5c6acd60f19790d
|
|
BLAKE2b-256 checksum How to use checksums |
3bdcf490be81b900042e0e2d2010ddd252f26b3498bdd56dc2420b460340afaa
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 23, 2026.
Transparency logRelease files / pynec_accel-1.7.6-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | pynec_accel-1.7.6-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl |
|---|---|
| Size | 11.1 MB |
| Tags | CPython 3.12 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
ffe14026eb3fb3abb8a2d302bab86d41b9110c726e1317a1cf3d0b3c2f129b50
|
|
BLAKE2b-256 checksum How to use checksums |
eefe71b826bb599e59c22100bcb970ecd7772909a2a99cbb83fcac4e3b65e7b4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 23, 2026.
Transparency logRelease files / pynec_accel-1.7.6-cp312-cp312-macosx_14_0_arm64.whl
| Download URL | pynec_accel-1.7.6-cp312-cp312-macosx_14_0_arm64.whl |
|---|---|
| Size | 6.9 MB |
| Tags | CPython 3.12 macOS 14.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
4c3498751d577b3801c700b16d5f8d8c8714111ddda8298a3ba4acb1304558bd
|
|
BLAKE2b-256 checksum How to use checksums |
cbe2a8370d313d29ffc9c4d8ddcdbb288445329f06d6c84ab9c41dd45946d217
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 23, 2026.
Transparency logRelease files / pynec_accel-1.7.6-cp311-cp311-win_amd64.whl
| Download URL | pynec_accel-1.7.6-cp311-cp311-win_amd64.whl |
|---|---|
| Size | 7.2 MB |
| Tags | CPython 3.11 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
1f172a055cbc941ab2f9c3336163772579dd8a08f17d9ac4a736e44ece9307d7
|
|
BLAKE2b-256 checksum How to use checksums |
4e1b1103d0e5fada563dc19059511c7ae6802b660b76234b7e1b4dcbe1314dba
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 23, 2026.
Transparency logRelease files / pynec_accel-1.7.6-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | pynec_accel-1.7.6-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl |
|---|---|
| Size | 11.1 MB |
| Tags | CPython 3.11 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
b994892c1b0d6267adec8170222a4e44f5282f73c521d11e7832202e1cac353b
|
|
BLAKE2b-256 checksum How to use checksums |
2727d1c8abb7a8541075eb1b3ec188c377d079d0ebdc8af4c26592e368865eb6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 23, 2026.
Transparency logRelease files / pynec_accel-1.7.6-cp311-cp311-macosx_14_0_arm64.whl
| Download URL | pynec_accel-1.7.6-cp311-cp311-macosx_14_0_arm64.whl |
|---|---|
| Size | 6.9 MB |
| Tags | CPython 3.11 macOS 14.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
d94a27142628ce52376f06f86bf2c5ccc87bdb34346f881e2cb26efa5e0816e3
|
|
BLAKE2b-256 checksum How to use checksums |
b7799f37551f4bfcd4dc12f10c69d15fac7c74f5ad7bc264df514d51c9d0ab45
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 23, 2026.
Transparency logRelease files / pynec_accel-1.7.6-cp310-cp310-win_amd64.whl
| Download URL | pynec_accel-1.7.6-cp310-cp310-win_amd64.whl |
|---|---|
| Size | 7.2 MB |
| Tags | CPython 3.10 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
3d1bdbf6fca51ecf1ca3a9878d36bd23eeea3ba19d7b4dabce7f36742270a97f
|
|
BLAKE2b-256 checksum How to use checksums |
dcabe5059fd7b833756e869dc9576724cb90eed659ab6b838f6ac2181d6ecfc8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 23, 2026.
Transparency logRelease files / pynec_accel-1.7.6-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | pynec_accel-1.7.6-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl |
|---|---|
| Size | 11.1 MB |
| Tags | CPython 3.10 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
e65406c060932c2ddbd5010002300b8c94f51b85d09176da2a8851295d6dab6b
|
|
BLAKE2b-256 checksum How to use checksums |
2d045f5363e46fc92f4c5e52d24e33d8dbb2bc4ee4e5fe2a04db15004270e9d1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 23, 2026.
Transparency logRelease files / pynec_accel-1.7.6-cp310-cp310-macosx_14_0_arm64.whl
| Download URL | pynec_accel-1.7.6-cp310-cp310-macosx_14_0_arm64.whl |
|---|---|
| Size | 6.9 MB |
| Tags | CPython 3.10 macOS 14.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
63b9bbec3da9e6973bdff654d6415998323cb7d817f85c77152bfad2c1508511
|
|
BLAKE2b-256 checksum How to use checksums |
e0cb10afbb2eff6816a9b38693b55e657eb7f41afe6aeb2477c00c87a2454772
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 23, 2026.
Transparency logSecurity for pynec-accel 1.7.6
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 15 files in this release have been uploaded with provenance metadata.
Attestation for pynec_accel-1.7.6-cp314-cp314-win_amd64.whl
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 23, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.