Metadata-Version: 2.4
Name: raypyng
Version: 2.0.0a1
Summary: Python interface for RAY-UI x-ray tracing program
Author-email: "Simone Vadilonga, Ruslan Ovsyannikov, Sebastian Sachse" <simone.vadilonga@helmholtz-berlin.de>
License: The MIT License (MIT)
        
        Copyright (c) <2022> <Simone Vadilonga, Ruslan Ovsyannikov>
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in
        all copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
        THE SOFTWARE.
        
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.12
Classifier: License :: OSI Approved :: MIT License
Requires-Python: >=3.12
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: numpy>=1.22.0
Requires-Dist: psutil>=5.9.1
Requires-Dist: joblib>=1.1.0
Requires-Dist: matplotlib>=3.5.1
Requires-Dist: natsort>=8.2.0
Requires-Dist: openpyxl>=3.1.0
Requires-Dist: tqdm>=4.66.1
Requires-Dist: pandas>=2.0.3
Requires-Dist: srxraylib>=1.0.61
Provides-Extra: rayx
Requires-Dist: rayx>=0.4.5; extra == "rayx"
Requires-Dist: graxpy>=0.4.4; extra == "rayx"
Provides-Extra: dev
Requires-Dist: pytest>=8.0; extra == "dev"
Requires-Dist: pytest-cov>=5.0; extra == "dev"
Requires-Dist: pre-commit>=3.0; extra == "dev"
Requires-Dist: black>=24.3.0; extra == "dev"
Requires-Dist: ruff>=0.3.5; extra == "dev"
Provides-Extra: docs
Requires-Dist: sphinx>=7.0; extra == "docs"
Requires-Dist: sphinx-rtd-theme>=1.0.0; extra == "docs"
Requires-Dist: sphinx-autodoc-typehints>=1.0; extra == "docs"
Requires-Dist: myst-parser>=2.0; extra == "docs"
Dynamic: license-file

# raypyng

raypyng is a Python interface for [RAY-UI](https://www.helmholtz-berlin.de/forschung/oe/wi/optik-strahlrohre/arbeitsgebiete/ray_en.html), 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.

## Highlights

- 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 `rayx` backend support.

## Installation

raypyng requires:

1. RAY-UI installed on your machine.
2. Python 3.10 or newer.

Install the Python package with:

```bash
python3 -m pip install --upgrade raypyng
```

For local development in this repository:

```bash
./tools/bootstrap.sh
```

On Windows PowerShell:

```powershell
.\tools\bootstrap_windows.ps1
.\.venv\Scripts\Activate.ps1
```

Notes:

- On Linux, `xvfb` is needed for headless RAY-UI execution.
- On macOS and Windows, `xvfb` is not needed.
- On Windows and macOS, put `sim.run(...)` under `if __name__ == "__main__":` when using multiprocessing.

## Quickstart

```python
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.

## Experimental rayx support

raypyng can also use [rayx](https://github.com/hz-b/rayx) as an experimental backend:

```bash
pip install "raypyng[rayx]"
```

The integration is still unstable and should be cross-checked against RAY-UI, especially for beamlines with diffraction gratings.

## Tests

The repository includes four kinds of automated tests:

- `unit`
- `smoke`
- `platform`
- `functional`

See [`tests/test.md`](tests/test.md) for setup and run commands.

## Documentation

- 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

## Versioning

raypyng follows classic semantic versioning:

- `MAJOR` for incompatible or substantial user-facing changes
- `MINOR` for backward-compatible new features
- `PATCH` for backward-compatible bug fixes and smaller corrections

## Contact

For questions about use rights or licensing, contact Simone Vadilonga:
`simone.vadilonga@helmholtz-berlin.de`
