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.5-cp314-cp314-win_amd64.whl (7.3 MB view details)

Uploaded CPython 3.14Windows x86-64

pynec_accel-1.7.5-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.5-cp314-cp314-macosx_14_0_arm64.whl (6.9 MB view details)

Uploaded CPython 3.14macOS 14.0+ ARM64

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

Uploaded CPython 3.13Windows x86-64

pynec_accel-1.7.5-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.5-cp313-cp313-macosx_14_0_arm64.whl (6.9 MB view details)

Uploaded CPython 3.13macOS 14.0+ ARM64

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

Uploaded CPython 3.12Windows x86-64

pynec_accel-1.7.5-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.5-cp312-cp312-macosx_14_0_arm64.whl (6.9 MB view details)

Uploaded CPython 3.12macOS 14.0+ ARM64

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

Uploaded CPython 3.11Windows x86-64

pynec_accel-1.7.5-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.5-cp311-cp311-macosx_14_0_arm64.whl (6.9 MB view details)

Uploaded CPython 3.11macOS 14.0+ ARM64

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

Uploaded CPython 3.10Windows x86-64

pynec_accel-1.7.5-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (11.0 MB view details)

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

pynec_accel-1.7.5-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.5-cp314-cp314-win_amd64.whl.

File metadata

File hashes

Hashes for pynec_accel-1.7.5-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 32da06b60cf36815ce899220b5a67bffbe58b6be9c4adc338e94b143eca6c1b1
MD5 f2a6129e268b23edeeb7a13498b1cf14
BLAKE2b-256 29d039b13b4f1525da593ecc91948bfd37f0f02b2f860e6ea1eed24b315aad18

See more details on using hashes here.

Provenance

The following attestation bundles were made for pynec_accel-1.7.5-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.5-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pynec_accel-1.7.5-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 98afa7de7664d0551c9052c936048689411d6ed8f8c316354fd78ab71e43f0ef
MD5 84e54a6e503d4d85aec60439607f3841
BLAKE2b-256 e9336bac2391144479fe22222195d24b925f46536d563e1ee7fa28f9b237d89e

See more details on using hashes here.

Provenance

The following attestation bundles were made for pynec_accel-1.7.5-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.5-cp314-cp314-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for pynec_accel-1.7.5-cp314-cp314-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 77e87e4a3dc05dd9019e6cc6ec2507771d502962d8b3dae11e6188aa4d2d89af
MD5 7428e6b89bf00b79afa9dfb48510dd04
BLAKE2b-256 e4588b05261dd29fb6fbc651d34d44a8d9dc637473f814b8765797e0306ed422

See more details on using hashes here.

Provenance

The following attestation bundles were made for pynec_accel-1.7.5-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.5-cp313-cp313-win_amd64.whl.

File metadata

File hashes

Hashes for pynec_accel-1.7.5-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 704157afa38cce24ec7f2fc4104885328e12f26f8daafcaa40c8a332963416b4
MD5 64708105ccc0fbbe1eedef90a8093e79
BLAKE2b-256 16f100efc6dcdd0e6bcb8ef5e62daedefc625fa51a54e220f363a2fea467dbe4

See more details on using hashes here.

Provenance

The following attestation bundles were made for pynec_accel-1.7.5-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.5-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pynec_accel-1.7.5-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 1d62eff3b5dac52cf63b3d8e2a52dd4f643a5123227d219ace2b169046269f0d
MD5 67f66bf69f33a20c5f221e6264a894ff
BLAKE2b-256 a08ce45f931f5d76ad9a677a11a85e2274c33235cc91c5c9ef13155568701494

See more details on using hashes here.

Provenance

The following attestation bundles were made for pynec_accel-1.7.5-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.5-cp313-cp313-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for pynec_accel-1.7.5-cp313-cp313-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 2ea98539e2e884f986428f787b4cb40998cd523690d300b43fc539d8ccac66a5
MD5 6f6761994cb97a49ab826600f3efcaa6
BLAKE2b-256 d80c17cfaae5ab472daba960165f2b9c6ecd21cbcde06a3622967070073100ca

See more details on using hashes here.

Provenance

The following attestation bundles were made for pynec_accel-1.7.5-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.5-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for pynec_accel-1.7.5-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 ede7b7d83294f9878602f20b588cd00b5bc21a8efca31a11a1341da158fff364
MD5 97432cbed1a92a676ff86c6a2a4f9e60
BLAKE2b-256 4c9a6ec2aecd2240d36062d5e900fc3c93db2fc32e91e283743493222dee0026

See more details on using hashes here.

Provenance

The following attestation bundles were made for pynec_accel-1.7.5-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.5-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pynec_accel-1.7.5-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 ba99f607287632dbbca29351914ecd61ddea4a0f47e029b04730cee9b42f3ecb
MD5 aa107bf6d40bd1a57b6a732f48af89c0
BLAKE2b-256 e44c6597a09814cba0bac6bc81e58c09b856ab67e6635ea4ca61a7e7db02b2db

See more details on using hashes here.

Provenance

The following attestation bundles were made for pynec_accel-1.7.5-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.5-cp312-cp312-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for pynec_accel-1.7.5-cp312-cp312-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 7fce03498349af01b4509d7a2f6773aa902d3e46b248c03052569bb813f65537
MD5 907daacda5592c5b9c51c63b148eba51
BLAKE2b-256 46b061c86762ec36dd23c27520c688b7f7d7cebe18ec6cd5aa7ab278eec0c8d6

See more details on using hashes here.

Provenance

The following attestation bundles were made for pynec_accel-1.7.5-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.5-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for pynec_accel-1.7.5-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 0a21af158d08f87f0b4648e59f0d5ce6e725de54d6feccac05f2a2009eba4aa4
MD5 7c46248e6f5ec99f2567d50eb6afd4e5
BLAKE2b-256 262870fbb6f90a0ffd2ef3a08fe4445d1ae24d75c8023b6e813905c9d27e38d0

See more details on using hashes here.

Provenance

The following attestation bundles were made for pynec_accel-1.7.5-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.5-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pynec_accel-1.7.5-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 a89cc30d0f94fafd45cc319f90e004e26704000ef65657e577e2c4c5dacfe542
MD5 f193f6a972669bbe0a3580dcb3335b64
BLAKE2b-256 71a136a7d0be92e4171fa6ad35157b8033093ede4816d80418cf8c46dc9c0913

See more details on using hashes here.

Provenance

The following attestation bundles were made for pynec_accel-1.7.5-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.5-cp311-cp311-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for pynec_accel-1.7.5-cp311-cp311-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 4e92e7a70061ab9bae7e80c1c426fa1697fd68338a1f05149ff4698daf0e5830
MD5 5030536e51182bb6e40d374ebadef15d
BLAKE2b-256 475fbf1132e118793dd0ae5095c4a0e7c3ccfa6a9ffdf3132316d34e585ffdfb

See more details on using hashes here.

Provenance

The following attestation bundles were made for pynec_accel-1.7.5-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.5-cp310-cp310-win_amd64.whl.

File metadata

File hashes

Hashes for pynec_accel-1.7.5-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 a0c110b6b671fff1a20a4d04881a68dbf31f3153a61cfc29973492251dfa8386
MD5 a1948de2b3a563844964b38297f2c117
BLAKE2b-256 480f280f16770e9d69a7892540cc737b4c68562e2f293d3eac2c972af314973c

See more details on using hashes here.

Provenance

The following attestation bundles were made for pynec_accel-1.7.5-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.5-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pynec_accel-1.7.5-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 86d76f20c4351e83dcb59fc01d148b09f96f98391743cb66f298a0ccbf293ce0
MD5 d54ca5210be0a7b59b61c60e34f813e9
BLAKE2b-256 9dc94cb6c6a66e0cd710cf1aa5a17a97c7e62963d1ee09676bf9a2554c1c4e54

See more details on using hashes here.

Provenance

The following attestation bundles were made for pynec_accel-1.7.5-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.5-cp310-cp310-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for pynec_accel-1.7.5-cp310-cp310-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 e7ed4f6c775fca13b59e1d3dc6e7ad85e99dd01e05f3f0064a3ff74782d98177
MD5 9d18d7b4751f90c50863b0659ab3918b
BLAKE2b-256 56cc251225268b8b87117037554432090993858b70e26c5c261c8c184833ceaf

See more details on using hashes here.

Provenance

The following attestation bundles were made for pynec_accel-1.7.5-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

1.7.6

15 files

This release

1.7.5 This release

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