Skip to main content

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.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

pynec_accel-1.7.6-cp314-cp314-win_amd64.whl (7.3 MB view details)

Uploaded CPython 3.14Windows x86-64

pynec_accel-1.7.6-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (11.1 MB view details)

Uploaded CPython 3.14manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

pynec_accel-1.7.6-cp314-cp314-macosx_14_0_arm64.whl (6.9 MB view details)

Uploaded CPython 3.14macOS 14.0+ ARM64

pynec_accel-1.7.6-cp313-cp313-win_amd64.whl (7.2 MB view details)

Uploaded CPython 3.13Windows x86-64

pynec_accel-1.7.6-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (11.1 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

pynec_accel-1.7.6-cp313-cp313-macosx_14_0_arm64.whl (6.9 MB view details)

Uploaded CPython 3.13macOS 14.0+ ARM64

pynec_accel-1.7.6-cp312-cp312-win_amd64.whl (7.2 MB view details)

Uploaded CPython 3.12Windows x86-64

pynec_accel-1.7.6-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (11.1 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

pynec_accel-1.7.6-cp312-cp312-macosx_14_0_arm64.whl (6.9 MB view details)

Uploaded CPython 3.12macOS 14.0+ ARM64

pynec_accel-1.7.6-cp311-cp311-win_amd64.whl (7.2 MB view details)

Uploaded CPython 3.11Windows x86-64

pynec_accel-1.7.6-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (11.1 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

pynec_accel-1.7.6-cp311-cp311-macosx_14_0_arm64.whl (6.9 MB view details)

Uploaded CPython 3.11macOS 14.0+ ARM64

pynec_accel-1.7.6-cp310-cp310-win_amd64.whl (7.2 MB view details)

Uploaded CPython 3.10Windows x86-64

pynec_accel-1.7.6-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (11.1 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

pynec_accel-1.7.6-cp310-cp310-macosx_14_0_arm64.whl (6.9 MB view details)

Uploaded CPython 3.10macOS 14.0+ ARM64

File details

Details for the file pynec_accel-1.7.6-cp314-cp314-win_amd64.whl.

File metadata

File hashes

Hashes for pynec_accel-1.7.6-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 b489ffe4fafd13e76f1560286b11c58ae2cce3236ecfc729090a1b51d80766f5
MD5 82ce20763a8efdb6b1e5642708be15c3
BLAKE2b-256 70eeb3d3542754c6fd8d972bffa6a2ae58efcd19e1bb8f5ee6abfa9bca1f09e5

See more details on using hashes here.

Provenance

The following attestation bundles were made for pynec_accel-1.7.6-cp314-cp314-win_amd64.whl:

Publisher: wheels.yml on stevenmburns/python-necpp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pynec_accel-1.7.6-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pynec_accel-1.7.6-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 1b8dd5309a4b782a2b80ae01cd3a017e481c0694de2a2cf59cef86a385aef6e2
MD5 88deab2c9bf3ac0ac3fc826fdbc88575
BLAKE2b-256 6470d408186c54a3fa8361f434e28bab7f72868ae1ba6480b3cc4c0ddf47f552

See more details on using hashes here.

Provenance

The following attestation bundles were made for pynec_accel-1.7.6-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl:

Publisher: wheels.yml on stevenmburns/python-necpp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pynec_accel-1.7.6-cp314-cp314-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for pynec_accel-1.7.6-cp314-cp314-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 3af6982579d1769796e598a3fc8a9df41876e1981d8cf6f28812cbc1d6b5d7be
MD5 2e7a84688b3999e6b32c5681facb37f9
BLAKE2b-256 b91855259a3a5841ef38f9cd46ff5bb3341deeff146c51ad5e5a8e1336e2be44

See more details on using hashes here.

Provenance

The following attestation bundles were made for pynec_accel-1.7.6-cp314-cp314-macosx_14_0_arm64.whl:

Publisher: wheels.yml on stevenmburns/python-necpp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pynec_accel-1.7.6-cp313-cp313-win_amd64.whl.

File metadata

File hashes

Hashes for pynec_accel-1.7.6-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 f38c7c4da1c9ceab18a0ab15ff7700d3dfbe2bf6894ac1689228f3ad21b5e385
MD5 2cc5587274e0c7ea5b9ee9c7d53a2fa4
BLAKE2b-256 db13956f3c400c5d3a270a646b01b1c5ee922e084be8cafc672be3e42de3b742

See more details on using hashes here.

Provenance

The following attestation bundles were made for pynec_accel-1.7.6-cp313-cp313-win_amd64.whl:

Publisher: wheels.yml on stevenmburns/python-necpp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pynec_accel-1.7.6-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pynec_accel-1.7.6-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 3d4707f6176bb0b952a3c20ef5e674b73fe792a0b7c902db2c8ea401ae055a92
MD5 24fceb392e36fe0d350005d4790006df
BLAKE2b-256 9253b89068a8115d44fa2a60a7e86f28fc1cc6829c189144667032830b36aa4b

See more details on using hashes here.

Provenance

The following attestation bundles were made for pynec_accel-1.7.6-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl:

Publisher: wheels.yml on stevenmburns/python-necpp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pynec_accel-1.7.6-cp313-cp313-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for pynec_accel-1.7.6-cp313-cp313-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 eba48468f31fe03682f055aa0a4e228a86bec230e948362f0701b906f71aa4d0
MD5 8d517b4b4f7a6ab1f4b54ce142dc7479
BLAKE2b-256 7c6f249a661d2c81a3c8d2abb28077e53313f3e0057d8e6593c463d4344b19ee

See more details on using hashes here.

Provenance

The following attestation bundles were made for pynec_accel-1.7.6-cp313-cp313-macosx_14_0_arm64.whl:

Publisher: wheels.yml on stevenmburns/python-necpp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pynec_accel-1.7.6-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for pynec_accel-1.7.6-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 b9e5f2b2b4786ff9e6cfc3a32e0da4dbab7eeab7fa724485e5c6acd60f19790d
MD5 1f4fe12b58a71dc630a18a0d2157ddbe
BLAKE2b-256 3bdcf490be81b900042e0e2d2010ddd252f26b3498bdd56dc2420b460340afaa

See more details on using hashes here.

Provenance

The following attestation bundles were made for pynec_accel-1.7.6-cp312-cp312-win_amd64.whl:

Publisher: wheels.yml on stevenmburns/python-necpp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pynec_accel-1.7.6-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pynec_accel-1.7.6-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 ffe14026eb3fb3abb8a2d302bab86d41b9110c726e1317a1cf3d0b3c2f129b50
MD5 93b58c0898a17a556a200642991a9f40
BLAKE2b-256 eefe71b826bb599e59c22100bcb970ecd7772909a2a99cbb83fcac4e3b65e7b4

See more details on using hashes here.

Provenance

The following attestation bundles were made for pynec_accel-1.7.6-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl:

Publisher: wheels.yml on stevenmburns/python-necpp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pynec_accel-1.7.6-cp312-cp312-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for pynec_accel-1.7.6-cp312-cp312-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 4c3498751d577b3801c700b16d5f8d8c8714111ddda8298a3ba4acb1304558bd
MD5 7b1724beafb9653245a072a660a815ef
BLAKE2b-256 cbe2a8370d313d29ffc9c4d8ddcdbb288445329f06d6c84ab9c41dd45946d217

See more details on using hashes here.

Provenance

The following attestation bundles were made for pynec_accel-1.7.6-cp312-cp312-macosx_14_0_arm64.whl:

Publisher: wheels.yml on stevenmburns/python-necpp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pynec_accel-1.7.6-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for pynec_accel-1.7.6-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 1f172a055cbc941ab2f9c3336163772579dd8a08f17d9ac4a736e44ece9307d7
MD5 1b84476572e37406b295a0b516ccbe88
BLAKE2b-256 4e1b1103d0e5fada563dc19059511c7ae6802b660b76234b7e1b4dcbe1314dba

See more details on using hashes here.

Provenance

The following attestation bundles were made for pynec_accel-1.7.6-cp311-cp311-win_amd64.whl:

Publisher: wheels.yml on stevenmburns/python-necpp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pynec_accel-1.7.6-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pynec_accel-1.7.6-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 b994892c1b0d6267adec8170222a4e44f5282f73c521d11e7832202e1cac353b
MD5 7a84db9c35cfed0509103dd9906293be
BLAKE2b-256 2727d1c8abb7a8541075eb1b3ec188c377d079d0ebdc8af4c26592e368865eb6

See more details on using hashes here.

Provenance

The following attestation bundles were made for pynec_accel-1.7.6-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl:

Publisher: wheels.yml on stevenmburns/python-necpp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pynec_accel-1.7.6-cp311-cp311-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for pynec_accel-1.7.6-cp311-cp311-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 d94a27142628ce52376f06f86bf2c5ccc87bdb34346f881e2cb26efa5e0816e3
MD5 c25980897c92feef39d73b6338523850
BLAKE2b-256 b7799f37551f4bfcd4dc12f10c69d15fac7c74f5ad7bc264df514d51c9d0ab45

See more details on using hashes here.

Provenance

The following attestation bundles were made for pynec_accel-1.7.6-cp311-cp311-macosx_14_0_arm64.whl:

Publisher: wheels.yml on stevenmburns/python-necpp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pynec_accel-1.7.6-cp310-cp310-win_amd64.whl.

File metadata

File hashes

Hashes for pynec_accel-1.7.6-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 3d1bdbf6fca51ecf1ca3a9878d36bd23eeea3ba19d7b4dabce7f36742270a97f
MD5 6fdc9d0fa6050e0cfc2c49bfa17c3221
BLAKE2b-256 dcabe5059fd7b833756e869dc9576724cb90eed659ab6b838f6ac2181d6ecfc8

See more details on using hashes here.

Provenance

The following attestation bundles were made for pynec_accel-1.7.6-cp310-cp310-win_amd64.whl:

Publisher: wheels.yml on stevenmburns/python-necpp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pynec_accel-1.7.6-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pynec_accel-1.7.6-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 e65406c060932c2ddbd5010002300b8c94f51b85d09176da2a8851295d6dab6b
MD5 eaaf90cf45ab1601b955122e0f9d89f6
BLAKE2b-256 2d045f5363e46fc92f4c5e52d24e33d8dbb2bc4ee4e5fe2a04db15004270e9d1

See more details on using hashes here.

Provenance

The following attestation bundles were made for pynec_accel-1.7.6-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl:

Publisher: wheels.yml on stevenmburns/python-necpp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pynec_accel-1.7.6-cp310-cp310-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for pynec_accel-1.7.6-cp310-cp310-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 63b9bbec3da9e6973bdff654d6415998323cb7d817f85c77152bfad2c1508511
MD5 98daf65ec628eb09be18c8e5be9ed32c
BLAKE2b-256 e0cb10afbb2eff6816a9b38693b55e657eb7f41afe6aeb2477c00c87a2454772

See more details on using hashes here.

Provenance

The following attestation bundles were made for pynec_accel-1.7.6-cp310-cp310-macosx_14_0_arm64.whl:

Publisher: wheels.yml on stevenmburns/python-necpp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

1.7.6 This release

15 files

1.7.5

15 files

1.7.4.post2

15 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page