Beamline#
This is an example of plotting lines and surveys. First, create a simple line and a tracker:
Survey#
Create a survey and a default floor plan plot:
survey = line.survey()
plot = xplt.FloorPlot(survey, labels=["S.Q.", "S1SX"])
plot.legend()
Customize the plot:
plot = xplt.FloorPlot(
line.survey(X0=4.5),
projection="XZ",
#
# Adjust box style for element names matching regex
#
# default_boxes=False, # use this to show *only* the boxes defined below (hiding the default elements)
boxes={
"S.QF": dict(color="limegreen"),
"S.QD": True, # default style for defocussing quads
"S.SX": dict(width=0.5),
},
#
# Adjust labels for element names matching regex
#
labels={
"S.Q.": True, # default labels
"S4MU1": dict(
text=(
"A bending magnet\n"
"name: {name}\n"
"l = {length} m\n"
"k0l = {element.knl[0]:g} rad"
),
xytext=(-3, -4),
bbox={"fc": "white"},
font="monospace",
c="red",
),
},
line=line, # optional, here we need it only to access it in the custom label of S4MU1
)
plot.add_scale()
plot.legend(loc="upper left")
Different projections are also supported. In this example we have a line with a horizontal and vertical chicane:
fig, ax = xplt.mpl.pyplot.subplots(2, figsize=(6, 4), sharex=True)
# First the default ZX projection, second the ZY projection
survey = line2.survey()
xplt.FloorPlot(survey, ax=ax[0])
xplt.FloorPlot(survey, projection="ZY", ax=ax[1])
ax[0].legend()
ax[0].set(xlabel=None);
Multipole strength#
A plot of the multipole strength \(k_nl\) as function of s-coordinate:
plot = xplt.KnlPlot(line, figsize=(7, 3))
plot.ax.set(ylim=(-1, 1));
The usual subplot spec string is also supported:
plot = xplt.KnlPlot(line, knl="k0l,k2l,k1l", filled=False)
See also