Note
Go to the end to download the full example code.
Machine Survey
This example shows how to use the plot_machine_survey
function
to represent your machine geometry in a from-the-top view.
import matplotlib.pyplot as plt
from cpymad.madx import Madx
from pyhdtoolkit.cpymadtools._generators import LatticeGenerator
from pyhdtoolkit.plotting.lattice import plot_machine_survey
from pyhdtoolkit.plotting.styles import _SPHINX_GALLERY_PARAMS
from pyhdtoolkit.utils import logging
logging.config_logger(level="error")
plt.rcParams.update(_SPHINX_GALLERY_PARAMS) # for readability of this tutorial
Generate a simple lattice and setup your simulation:
base_lattice = LatticeGenerator.generate_base_cas_lattice()
Input the lattice into MAD-X
, no more needed here
madx = Madx(stdout=False)
madx.input(base_lattice)
Plot the machine survey, as simplistic as possible:
plt.figure(figsize=(16, 11))
plot_machine_survey(madx, title="Machine Layout")
plt.show()
Plot the machine survey, differenciating elements and showing high order magnets:
plt.figure(figsize=(16, 11))
plot_machine_survey(madx, title="Machine Layout", show_elements=True, high_orders=True)
plt.show()
Let’s not forget to close the rpc connection to MAD-X
:
References
The use of the following functions, methods, classes and modules is shown in this example:
_generators
:LatticeGenerator
lattice
:plot_machine_survey
Total running time of the script: (0 minutes 3.336 seconds)