Skip to main content

A Python package for Synchrotron Radiation calculations

Project description

barc4sr

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)

Features

Core modelling

  • ElectronBeam: canonical storage of second-order moments
  • MagneticStructure: bending magnets, arbitrary fields; undulators/ wigglers planned
  • SynchrotronSource hierarchy:
    • BendingMagnetSource
    • ArbitraryMagnetSource

Magnetic-field generation

  • bm_magnetic_field() – soft-edge bending magnet model
  • arb_magnetic_field() – arbitrary user-defined magnetic fields
  • multi_bm_magnetic_field() – composite bending-magnet lattices
  • multi_arb_magnetic_field() – multi-field arbitrary lattices

SRW-based radiation calculations

  • electron_trajectory()
  • wavefront()
  • power_density()

All return backend-agnostic dictionaries (NumPy arrays + metadata).

Plotting

Available via barc4sr.plotting:

  • plot_electron_trajectory
  • plot_wavefront
  • plot_power_density
  • Shared colormaps, styles, and layout helpers

I/O utilities

  • Save/load: trajectories, wavefronts, power-density maps
  • Simple .dat and .json formats for interoperability

Installation

Basic installation

pip install barc4sr

This installs the core models, magnetic-field utilities, plotting tools, and I/O helpers.


Enable SRW-based radiation calculations

To perform wavefront, power-density, and trajectory calculations, install SRW bindings:

Option 1 (recommended if it works on your setup)

pip install srwpy

Option 2 (fallback)

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.

Examples:

Check the examples! You can learn a lot from them.

PyPI Documentation Status License: CeCILL-2.1 DOI

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

barc4sr-2025.11.28.tar.gz (55.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

barc4sr-2025.11.28-py3-none-any.whl (66.0 kB view details)

Uploaded Python 3

File details

Details for the file barc4sr-2025.11.28.tar.gz.

File metadata

  • Download URL: barc4sr-2025.11.28.tar.gz
  • Upload date:
  • Size: 55.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.19

File hashes

Hashes for barc4sr-2025.11.28.tar.gz
Algorithm Hash digest
SHA256 9fdab9cd47e94bfc507b19df44f6acea2eaf6b3cec691899795fadd062b71073
MD5 680bd23c7f9a4d882a706e4227166a68
BLAKE2b-256 734c41224404ce9f24a4e29ef5413fd5057fe91f105915191794cf2af10d8ba1

See more details on using hashes here.

File details

Details for the file barc4sr-2025.11.28-py3-none-any.whl.

File metadata

  • Download URL: barc4sr-2025.11.28-py3-none-any.whl
  • Upload date:
  • Size: 66.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.19

File hashes

Hashes for barc4sr-2025.11.28-py3-none-any.whl
Algorithm Hash digest
SHA256 3ac8d42341025f26ad5db4f80696891e07350885e48172651b6ff9250d7de606
MD5 689b3ebbecf6e4f5220a1721f5a1c5e7
BLAKE2b-256 0c74af91b164d62b035d4640ec4a2415498256557204f2db2318d0dad9eb20c2

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page