PyMAD-NG
Python interface to MAD-NG running as a subprocess
🚀 Installation
Install via pip from PyPI:
pip install pymadng
🧠 Getting Started
Before diving into PyMAD-NG, we recommend you:
- Familiarise yourself with MAD-NG — understanding MAD-NG is essential.
- Read the Quick Start Guide to see how to control MAD-NG from Python.
Explore Key Examples
- LHC Matching Example – Real-world optics matching with intermediate feedback.
- Examples Page - List of examples in an easy to read format.
- GitHub Examples Directory – List of available examples on the repository
A Few Things To Know Early
MAD()launches a real MAD-NG subprocess immediately. Preferwith MAD() as mad:in normal use.mad["x"] = valuewrites a variable inside MAD-NG.mad.x = valueonly changes the Python wrapper object.- Communication is explicit: tell MAD-NG to
py:send(...)before callingmad.recv(), and tell MAD-NG topy: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:
- Refer to the API Reference
- Check the MAD-NG Docs
- Or open an issue
🤖 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()andrecv()communication - Python-native handling of MAD tables and expressions
- Optional integration with
pandasandtfs-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)
| 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)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| 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 logRelease 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 logSecurity 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.
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 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.