raypyng is a Python interface for RAY-UI, the ray-tracing software developed at Helmholtz-Zentrum Berlin for synchrotron beamlines and X-ray optics.
It loads a beamline saved from RAY-UI as an .rml file, scans beamline parameters, runs traces in parallel, and post-processes the exported rays.
- Works on Linux, macOS, and Windows.
- Drives RAY-UI from Python through a simple simulation API.
- Supports parameter scans and parallel execution.
- Can post-process raw exported rays directly in raypyng.
- Includes automated unit, smoke, platform, and functional tests.
- Offers experimental
rayxbackend support.
raypyng requires:
- RAY-UI installed on your machine.
- Python 3.10 or newer.
Install the Python package with:
python3 -m pip install --upgrade raypyngFor local development in this repository:
./tools/bootstrap.shOn Windows PowerShell:
.\tools\bootstrap_windows.ps1
.\.venv\Scripts\Activate.ps1Notes:
- On Linux,
xvfbis needed for headless RAY-UI execution. - On macOS and Windows,
xvfbis not needed. - On Windows and macOS, put
sim.run(...)underif __name__ == "__main__":when using multiprocessing.
import numpy as np
from raypyng import Simulate
if __name__ == "__main__":
sim = Simulate("rml/dipole_beamline.rml", hide=True)
beamline = sim.rml.beamline
sim.params = [
{beamline.Dipole.photonEnergy: np.arange(200, 2001, 200)},
]
sim.exports = [{beamline.DetectorAtFocus: ["RawRaysOutgoing"]}]
sim.simulation_name = "quickstart"
sim.analyze = False
sim.raypyng_analysis = True
sim.run(multiprocessing="auto", force=True)This writes the simulation output into a RAYPy_Simulation_quickstart folder.
raypyng can also use rayx as an experimental backend:
pip install "raypyng[rayx]"The integration is still unstable and should be cross-checked against RAY-UI, especially for beamlines with diffraction gratings.
The repository includes four kinds of automated tests:
unitsmokeplatformfunctional
See tests/test.md for setup and run commands.
- Full documentation: https://raypyng.readthedocs.io/en/latest/index.html
- Installation guide: https://raypyng.readthedocs.io/en/latest/installation.html
- Tutorial: https://raypyng.readthedocs.io/en/latest/tutorial.html
- Troubleshooting: https://raypyng.readthedocs.io/en/latest/troubleshooting.html
raypyng follows classic semantic versioning:
MAJORfor incompatible or substantial user-facing changesMINORfor backward-compatible new featuresPATCHfor backward-compatible bug fixes and smaller corrections
For questions about use rights or licensing, contact Simone Vadilonga:
simone.vadilonga@helmholtz-berlin.de