Skip to main content

PyMAD-NG

Python interface to MAD-NG running as a subprocess

PyPI version Documentation Status License DOI


🚀 Installation

Install via pip from PyPI:

pip install pymadng

🧠 Getting Started

Before diving into PyMAD-NG, we recommend you:

  1. Familiarise yourself with MAD-NG — understanding MAD-NG is essential.
  2. Read the Quick Start Guide to see how to control MAD-NG from Python.

Explore Key Examples

A Few Things To Know Early

  • MAD() launches a real MAD-NG subprocess immediately. Prefer with MAD() as mad: in normal use.
  • mad["x"] = value writes a variable inside MAD-NG. mad.x = value only changes the Python wrapper object.
  • Communication is explicit: tell MAD-NG to py:send(...) before calling mad.recv(), and tell MAD-NG to py:recv() before sending Python data.
  • Many high-level results are references to MAD-NG objects. Use .eval() or conversion helpers such as .to_df() when you want Python-side values.

If anything seems unclear:


🤖 AI Agents

skills/pymadng is a skill for AI coding agents (Claude Code and similar) that write PyMAD-NG code. See the docs for how to install it.


📚 Documentation

Full documentation and example breakdowns are hosted at: https://pymadng.readthedocs.io/en/latest/

To build locally:

git clone https://github.com/MethodicalAcceleratorDesign/MAD-NG.py.git
cd MAD-NG.py/docs
make html

🧪 Running Examples

Examples are stored in the examples/ folder. Run any script with:

python3 examples/ex-fodo/ex-fodos.py

You can also batch-run everything using:

python3 runall.py

💡 Features

  • High-level Python interface to MAD-NG
  • Access to MAD-NG functions, sequences, optics, and tracking
  • Dynamic send() and recv() communication
  • Python-native handling of MAD tables and expressions
  • Optional integration with pandas and tfs-pandas

🤝 Contributing

We welcome contributions! See the contributing guide or the Contributing Guide in the docs.

Bug reports, feature requests, and pull requests are encouraged.


📜 License

PyMAD-NG is licensed under the GNU General Public License v3.0.


🙌 Acknowledgements

Built on top of MAD-NG, developed at CERN. This interface aims to bring MAD's power to the Python ecosystem with minimal friction.

Metadata

Release files for pymadng 0.10.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pymadng 0.10.0
File Size Uploaded Provenance Actions
pymadng-0.10.0.tar.gz 10.6 MB With provenance Details for pymadng-0.10.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pymadng 0.10.0
File Interpreter ABI Platform Actions
pymadng-0.10.0-py3-none-any.whl Python 3 none any Details for pymadng-0.10.0-py3-none-any.whl

Total release size: 20.5 MB

Release files / pymadng-0.10.0.tar.gz

Download URL pymadng-0.10.0.tar.gz
Size 10.6 MB
Tags Source
SHA-256 checksum
How to use checksums
b03931057b43fe9f2d3a8f5fbb7ab682b569124118a6094ad6126b6a7e86a0b9
BLAKE2b-256 checksum
How to use checksums
b42779b7d6e47264cc7ddbcd85b33b6d7b16d5268aa548ed6a5d8b92f74e7cd4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 21, 2026.

Transparency log

Release files / pymadng-0.10.0-py3-none-any.whl

Download URL pymadng-0.10.0-py3-none-any.whl
Size 9.9 MB
Tags Python 3
SHA-256 checksum
How to use checksums
a2e0ff69004ba5d45c4bf734a3a25aabe5ffe7a67347cdea9059b2481c2b42ae
BLAKE2b-256 checksum
How to use checksums
e237f74c4b0c686445c246946c09744eae6448f0ea41486d159a36889f47d431
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 21, 2026.

Transparency log

Security for pymadng 0.10.0

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

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for pymadng-0.10.0.tar.gz

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 Nov 21, 2026.

Transparency log

A 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.

Release history Release notifications | RSS feed

This release

0.10.0 This release

2 release files Full provenance

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