This repository contains Python tools for post processing of elegant simulation data. There are multiple examples in the examples folder, whereby each example includes a separate Readme.md file with further instructions.
-
Install elegant
-
Install this package:
-
If you intend to make changes to this repository, clone and install it with:
git clone [email protected]:nobeam/eleganttools.git pip install -Ue ./eleganttools -
If you just want to use this package:
pip install -U git+https://github.com/nobeam/eleganttools.git
-
Load the twiss data from the twiss.twi SDDS file into a Python dictionary:
from eleganttools import SDDS
twiss = SDDS("/path/to/twiss.twi").as_dict()You can now access items of the twiss data via:
twiss["betax"]Or, assign multiple items to individual Python variables:
s, beta_x, beta_y = (twiss[key] for key in ("s", "betax", "betay"))It is also possible to load the data into a pandas dataframe and use the slightly more convenient dot notation:
df = SDDS("/path/to/twiss.twi").as_dataframe()
df.betaxThis package comes with some matplotlib convenience functions.
Draw the magnets of the lattice on top of a matplotlib axis:
from eleganttools import draw_elements
fig, ax = plt.subplots()
ax.plot(twiss["s"], twiss["betax"])
draw_elements(ax, twiss)