Skip to content
Snippets Groups Projects
Commit 58689f59 authored by Watanyu Foosang's avatar Watanyu Foosang
Browse files

Edit plot_optics

- ring has been removed from the input.
- for loop has been removed and replaced by linspace function
parent c165102f
No related branches found
No related tags found
No related merge requests found
......@@ -245,20 +245,21 @@ class Optics:
self.dispY(position), self.disppY(position)]
return np.array(dispersion)
def plot_optics(self, ring, var, option):
def plot_optics(self, var, option, n_points=1000):
"""
Plotting optical variables.
Parameters
----------
ring : Synchrotron object
var : {"beta", "alpha", "gamma", "dispersion"}
Optical variable to be plotted
Optical variable to be plotted.
option : str
If var = "beta", "alpha" and "gamma", option = {"x","y"} specifying
the axis of interest.
If var = "dispersion", option = {"x","px","y","py"} specifying the
axis of interest for the dispersion function or its derivative.
n_points : int
Number of points on the plot. The default value is 1000.
"""
......@@ -272,6 +273,7 @@ class Optics:
plt.ylabel(label[option_dict[option]])
elif var=="beta" or var=="alpha" or var=="gamma":
option_dict = {"x":0, "y":1}
label_dict = {"beta":"$\\beta$", "alpha":"$\\alpha$",
......@@ -284,16 +286,14 @@ class Optics:
plt.ylabel(label_dict[var] + label_sup + unit[var])
else:
raise ValueError("Variable name is not found.")
var_list = []
position_list = []
for i in range (int(ring.L)):
var_list.append(var_dict[var](i)[option_dict[option]])
position_list.append(i)
position = np.linspace(0, self.lattice.circumference, int(n_points))
var_list = var_dict[var](position)[option_dict[option]]
plt.plot(position,var_list)
plt.plot(position_list, var_list)
plt.xlabel("position (m)")
......@@ -566,3 +566,4 @@ class PhyisicalModel:
axs[1].set(xlabel="Longitudinal position [m]",
ylabel="Vertical aperture [mm]")
axs[1].legend(["Top","Bottom"])
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment