BARC library for Synchrotron Radiation
This library was created for facilitating the use of SRW and WOFRY for a few routine calculations.
It provides:
- canonical beam and magnet classes (ElectronBeam, MagneticStructure, SynchrotronSource, …)
- magnetic-field generators (bending magnets, arbitrary fields, multi-element fields)
- SRW-powered computations (electron trajectories, wavefronts, power density)
- Wofry-powered computations (CMD)
- ElectronBeam: canonical storage of second-order moments
- MagneticStructure: bending magnets, arbitrary fields; undulators/ wigglers planned
- SynchrotronSource hierarchy:
BendingMagnetSourceArbitraryMagnetSource
bm_magnetic_field()– soft-edge bending magnet modelarb_magnetic_field()– arbitrary user-defined magnetic fieldsmulti_bm_magnetic_field()– composite bending-magnet latticesmulti_arb_magnetic_field()– multi-field arbitrary lattices
electron_trajectory()wavefront()power_density()
All return backend-agnostic dictionaries (NumPy arrays + metadata).
Available via barc4sr.plotting:
plot_electron_trajectoryplot_wavefrontplot_power_density- Shared colormaps, styles, and layout helpers
- Save/load: trajectories, wavefronts, power-density maps
- Simple
.datand.jsonformats for interoperability
pip install barc4sr
This installs the core models, magnetic-field utilities, plotting tools, and I/O helpers.
To perform wavefront, power-density, and trajectory calculations, install SRW bindings:
pip install srwpy
pip install oasys-srwpy
If neither is available for your platform, you can also build SRW from source;
barc4sr will still import, but SRW-based calculations will be unavailable.
Check the examples! You can learn a lot from them.