ocelot.gui.accelerator

user interface for viewing/editing electron optics layouts

Module Contents

Classes

Save3DBeamDensity

Parent class for all Physics processes

Functions

plot_lattice(lat, axis, alpha=1.0, params={'kmax': 2.0, 'ang_max': 0.005}, s_start=0.0)

elem_cord(lat)

plot_elems(fig, ax, lat, s_point=0, nturns=1, y_lim=None, y_scale=1, legend=True, font_size=18, excld_legend=None)

plot_disp(ax, tws, top_plot, font_size)

plot_betas(ax, S, beta_x, beta_y, font_size)

plot_opt_func(lat, tws, top_plot=['Dx'], legend=True, fig_name=None, grid=True, font_size=12, excld_legend=None)

function for plotting: lattice (bottom section), vertical and horizontal beta-functions (middle section),

plot_opt_func_reduced(lat, tws, top_plot=['Dx'], legend=True, fig_name=None, grid=False, font_size=18)

function for plotting: lattice (bottom section), vertical and horizontal beta-functions (middle section),

plot_xy(ax, S, X, Y, font_size)

plot_API(lat, legend=True, fig_name=1, grid=True, font_size=12, excld_legend=None)

Function creates a picture with lattice on the bottom part of the picture and top part of the picture can be

compare_betas(lat, tws1, tws2, prefix1='beam1', prefix2='beam2', legend=True, fig_name=None, grid=True, font_size=18)

function for plotting: lattice (bottom section), vertical and horizontal beta-functions (middle section),

resonance(Qx, Qy, order=5)

plot_resonance_diag(ax, Qx, Qy, order)

show_da(out_da, x_array, y_array, title='')

show_mu(contour_da, mux, muy, x_array, y_array, zones=None)

show_density(x, y, ax=None, nbins_x=250, nbins_y=250, interpolation='bilinear', xlabel=None, ylabel=None, nfig=50, title=None, figsize=None, grid=True, show_xtick_label=True, limits=None)

Function shows density

show_e_beam(p_array, nparts_in_slice=5000, smooth_param=0.05, nbins_x=200, nbins_y=200, interpolation='bilinear', inverse_tau=False, show_moments=False, nfig=40, title=None, figsize=None, grid=True, filename=None, headtail=True, filter_base=2, filter_iter=2, tau_units='mm')

Shows e-beam slice parameters (current, emittances, energy spread)

show_phase_space(p_array, nparts_in_slice=5000, smooth_param=0.05, nbins_x=200, nbins_y=200, interpolation='bilinear', inverse_tau=False, show_moments=False, nfig=40, title=None, figsize=None, grid=True)

Shows e-beam slice parameters (current, emittances, energy spread)

compare_beams(p_array_1, p_array_2, nparts_in_slice1=5000, nparts_in_slice2=5000, smoth_param=0.05, inverse_tau=False, nfig=40, title=None, figsize=None, legend_beam1=None, legend_beam2=None)

Shows e-beam slice parameters (current, emittances, energy spread)

compare_beams_reduced(p_array_1, p_array_2, nparts_in_slice=5000, smoth_param=0.05, inverse_tau=True, nfig=40, title=None, figsize=None, legend_beam1=None, legend_beam2=None)

Shows e-beam slice parameters (current, emittances, energy spread)

show_e_beam_reduced(p_array, nparts_in_slice=5000, smooth_param=0.05, nbins_x=200, nbins_y=200, interpolation='bilinear', inverse_tau=False, show_moments=False, nfig=40, title=None, figsize=None, grid=True, filename=None)

Shows e-beam slice parameters (current, emittances, energy spread)

beam_jointplot(p_array, show_plane='x', nparts_in_slice=5000, smooth_param=0.05, nbins_x=200, nbins_y=200, interpolation='bilinear', inverse_tau=True, show_head=True, show_moments=False, nfig=40, title=None, figsize=None, grid=True, filename=None)

Shows e-beam slice parameters (current, emittances, energy spread)

ocelot.gui.accelerator.plot_lattice(lat, axis, alpha=1.0, params={'kmax': 2.0, 'ang_max': 0.005}, s_start=0.0)
ocelot.gui.accelerator.elem_cord(lat)
ocelot.gui.accelerator.dict_plot
ocelot.gui.accelerator.plot_elems(fig, ax, lat, s_point=0, nturns=1, y_lim=None, y_scale=1, legend=True, font_size=18, excld_legend=None)
ocelot.gui.accelerator.plot_disp(ax, tws, top_plot, font_size)
ocelot.gui.accelerator.plot_betas(ax, S, beta_x, beta_y, font_size)
ocelot.gui.accelerator.plot_opt_func(lat, tws, top_plot=['Dx'], legend=True, fig_name=None, grid=True, font_size=12, excld_legend=None)

function for plotting: lattice (bottom section), vertical and horizontal beta-functions (middle section), other parameters (top section) such as “Dx”, “Dy”, “E”, “mux”, “muy”, “alpha_x”, “alpha_y”, “gamma_x”, “gamma_y”

Parameters
  • lat – MagneticLattice,

  • tws – list if Twiss objects,

  • top_plot – [“Dx”] - parameters which displayed in top section. Can be any attribute of Twiss class, e.g. top_plot=[“Dx”, “Dy”, “alpha_x”]

  • legend – True - displaying legend of element types in bottom section,

  • fig_name – None - name of figure,

  • grid – True - grid

  • font_size – 16 - font size for any element of plot

  • excld_legend – None, exclude type of element from the legend, e.g. excld_legend=[Hcor, Vcor]

Returns

ocelot.gui.accelerator.plot_opt_func_reduced(lat, tws, top_plot=['Dx'], legend=True, fig_name=None, grid=False, font_size=18)

function for plotting: lattice (bottom section), vertical and horizontal beta-functions (middle section), other parameters (top section) such as “Dx”, “Dy”, “E”, “mux”, “muy”, “alpha_x”, “alpha_y”, “gamma_x”, “gamma_y” lat - MagneticLattice, tws - list if Twiss objects, top_plot=[“Dx”] - parameters which displayed in top section. Example top_plot=[“Dx”, “Dy”, “alpha_x”] legend=True - displaying legend of element types in bottom section, fig_name=None - name of figure, grid=True - grid font_size=18 - font size.

ocelot.gui.accelerator.plot_xy(ax, S, X, Y, font_size)
ocelot.gui.accelerator.plot_API(lat, legend=True, fig_name=1, grid=True, font_size=12, excld_legend=None)

Function creates a picture with lattice on the bottom part of the picture and top part of the picture can be plot arbitrary lines.

Parameters
  • lat – MagneticLattice

  • legend – True, description of the elements, if False it is switched legend off

Returns

fig, ax

ocelot.gui.accelerator.compare_betas(lat, tws1, tws2, prefix1='beam1', prefix2='beam2', legend=True, fig_name=None, grid=True, font_size=18)

function for plotting: lattice (bottom section), vertical and horizontal beta-functions (middle section), other parameters (top section) such as “Dx”, “Dy”, “E”, “mux”, “muy”, “alpha_x”, “alpha_y”, “gamma_x”, “gamma_y” lat - MagneticLattice, tws - list if Twiss objects, top_plot=[“Dx”] - parameters which displayed in top section. Example top_plot=[“Dx”, “Dy”, “alpha_x”] legend=True - displaying legend of element types in bottom section, fig_name=None - name of figure, grid=True - grid font_size=18 - font size.

ocelot.gui.accelerator.resonance(Qx, Qy, order=5)
ocelot.gui.accelerator.plot_resonance_diag(ax, Qx, Qy, order)
ocelot.gui.accelerator.show_da(out_da, x_array, y_array, title='')
ocelot.gui.accelerator.show_mu(contour_da, mux, muy, x_array, y_array, zones=None)
ocelot.gui.accelerator.show_density(x, y, ax=None, nbins_x=250, nbins_y=250, interpolation='bilinear', xlabel=None, ylabel=None, nfig=50, title=None, figsize=None, grid=True, show_xtick_label=True, limits=None)

Function shows density

Parameters
  • x – np.array

  • y – np.array

  • ax – None, subplot axis, if None creates standalone plot.

  • nbins_x – 250, number of bins for 2D hist. in horz. plane

  • nbins_y – 250, number of bins for 2D hist. in vertical plane

  • interpolation – “bilinear”. Acceptable values are ‘none’, ‘nearest’, ‘bilinear’, ‘bicubic’, ‘spline16’, ‘spline36’, ‘hanning’, ‘hamming’, ‘hermite’, ‘kaiser’, ‘quadric’, ‘catrom’, ‘gaussian’, ‘bessel’

  • xlabel – None, otherwise “string”

  • ylabel – None, otherwise “string”

  • nfig – number of the figure

  • title – title of the figure

  • figsize – None or e.g. (8, 6)

  • grid – True, show grid

  • show_xtick_label – True

:param label, None or string. :param limits, None or [[xmin, xmax], [ymin, ymax]] :return:

ocelot.gui.accelerator.show_e_beam(p_array, nparts_in_slice=5000, smooth_param=0.05, nbins_x=200, nbins_y=200, interpolation='bilinear', inverse_tau=False, show_moments=False, nfig=40, title=None, figsize=None, grid=True, filename=None, headtail=True, filter_base=2, filter_iter=2, tau_units='mm')

Shows e-beam slice parameters (current, emittances, energy spread) and beam distributions (dE/(p0 c), X, Y) against long. coordinate (S) Note: beam head is on the left side

Parameters
  • p_array – ParticleArray

  • nparts_in_slice – number of particles per slice

  • smoth_param – 0.05, smoothing parameters to calculate the beam current: sigma = smoth_param * np.std(p_array.tau())

  • nbins_x – number of bins for 2D hist. in horz. plane

  • nbins_y – number of bins for 2D hist. in vertical plane

  • interpolation – “bilinear”, and acceptable values are ‘none’, ‘nearest’, ‘bilinear’, ‘bicubic’, ‘spline16’, ‘spline36’, ‘hanning’, ‘hamming’, ‘hermite’, ‘kaiser’, ‘quadric’, ‘catrom’, ‘gaussian’, ‘bessel’

  • inverse_tau – False, inverse tau - head will be on the right side of figure

  • show_moments – False, show moments (X_mean_slice and Y_mean_slice) in the density distribution

  • nfig – number of the figure

  • title – None or string - title of the figure

  • figsize – None or e.g. (8, 6)

  • grid – True, show grid

  • filename – None or str, filename to save picture in the file

  • headtail – True, shows where is the beam head is.

  • filter_base – support of rectangle filter is 2*p+1

  • filter_iter – the number of the filter iterations

Returns

ocelot.gui.accelerator.show_phase_space(p_array, nparts_in_slice=5000, smooth_param=0.05, nbins_x=200, nbins_y=200, interpolation='bilinear', inverse_tau=False, show_moments=False, nfig=40, title=None, figsize=None, grid=True)

Shows e-beam slice parameters (current, emittances, energy spread) and beam distributions (dE/(p0 c), X, Y) against long. coordinate (S) Note: beam head is on the left side

Parameters
  • p_array – ParticleArray

  • nparts_in_slice – number of particles per slice

  • smoth_param – 0.05, smoothing parameters to calculate the beam current: sigma = smoth_param * np.std(p_array.tau())

  • nbins_x – number of bins for 2D hist. in horz. plane

  • nbins_y – number of bins for 2D hist. in vertical plane

  • interpolation – “bilinear”, and acceptable values are ‘none’, ‘nearest’, ‘bilinear’, ‘bicubic’, ‘spline16’, ‘spline36’, ‘hanning’, ‘hamming’, ‘hermite’, ‘kaiser’, ‘quadric’, ‘catrom’, ‘gaussian’, ‘bessel’

  • inverse_tau – False, inverse tau - head will be on the right side of figure

  • show_moments – False, show moments (X_mean_slice and Y_mean_slice) in the density distribution

  • nfig – number of the figure

  • title – None or string - title of the figure

  • figsize – None or e.g. (8, 6)

  • grid – True, show grid

Returns

ocelot.gui.accelerator.compare_beams(p_array_1, p_array_2, nparts_in_slice1=5000, nparts_in_slice2=5000, smoth_param=0.05, inverse_tau=False, nfig=40, title=None, figsize=None, legend_beam1=None, legend_beam2=None)

Shows e-beam slice parameters (current, emittances, energy spread) and beam distributions (dE/(p0 c), X, Y) against long. coordinate (S) Note: beam head is on the left side

Parameters
  • p_array_1 – ParticleArray

  • p_array_2 – ParticleArray

  • nparts_in_slice1 – number of particles per slice in p_array_1

  • nparts_in_slice2 – number of particles per slice in p_array_2

  • smoth_param – 0.05, smoothing parameters to calculate the beam current: sigma = smoth_param * np.std(p_array.tau())

  • inverse_tau – False, inverse tau - head will be on the right side of figure

  • nfig – number of the figure

  • title – None or string - title of the figure

  • figsize – None or e.g. (8, 6)

  • legend_beam1 – None, legend for beam N1

  • legend_beam2 – None, legend for beam N1

Returns

ocelot.gui.accelerator.compare_beams_reduced(p_array_1, p_array_2, nparts_in_slice=5000, smoth_param=0.05, inverse_tau=True, nfig=40, title=None, figsize=None, legend_beam1=None, legend_beam2=None)

Shows e-beam slice parameters (current, emittances, energy spread) and beam distributions (dE/(p0 c), X, Y) against long. coordinate (S) Note: beam head is on the left side

Parameters
  • p_array_1 – ParticleArray

  • p_array_2 – ParticleArray

  • nparts_in_slice – number of particles per slice

  • smoth_param – 0.05, smoothing parameters to calculate the beam current: sigma = smoth_param * np.std(p_array.tau())

  • inverse_tau – False, inverse tau - head will be on the right side of figure

  • nfig – number of the figure

  • title – None or string - title of the figure

  • figsize – None or e.g. (8, 6)

  • legend_beam1 – None, legend for beam N1

  • legend_beam2 – None, legend for beam N1

Returns

ocelot.gui.accelerator.show_e_beam_reduced(p_array, nparts_in_slice=5000, smooth_param=0.05, nbins_x=200, nbins_y=200, interpolation='bilinear', inverse_tau=False, show_moments=False, nfig=40, title=None, figsize=None, grid=True, filename=None)

Shows e-beam slice parameters (current, emittances, energy spread) and beam distributions (dE/(p0 c), X, Y) against long. coordinate (S) Note: beam head is on the left side

Parameters
  • p_array – ParticleArray

  • nparts_in_slice – number of particles per slice

  • smoth_param – 0.05, smoothing parameters to calculate the beam current: sigma = smoth_param * np.std(p_array.tau())

  • nbins_x – number of bins for 2D hist. in horz. plane

  • nbins_y – number of bins for 2D hist. in vertical plane

  • interpolation – “bilinear”, and acceptable values are ‘none’, ‘nearest’, ‘bilinear’, ‘bicubic’, ‘spline16’, ‘spline36’, ‘hanning’, ‘hamming’, ‘hermite’, ‘kaiser’, ‘quadric’, ‘catrom’, ‘gaussian’, ‘bessel’

  • inverse_tau – False, inverse tau - head will be on the right side of figure

  • show_moments – False, show moments (X_mean_slice and Y_mean_slice) in the density distribution

  • nfig – number of the figure

  • title – None or string - title of the figure

  • figsize – None or e.g. (8, 6)

  • grid – True, show grid

  • filename – None or str, filename to save picture in the file

Returns

ocelot.gui.accelerator.beam_jointplot(p_array, show_plane='x', nparts_in_slice=5000, smooth_param=0.05, nbins_x=200, nbins_y=200, interpolation='bilinear', inverse_tau=True, show_head=True, show_moments=False, nfig=40, title=None, figsize=None, grid=True, filename=None)

Shows e-beam slice parameters (current, emittances, energy spread) and beam distributions (dE/(p0 c), X, Y) against long. coordinate (S) Note: beam head is on the left side

Parameters
  • p_array – ParticleArray

  • nparts_in_slice – number of particles per slice

  • smoth_param – 0.05, smoothing parameters to calculate the beam current: sigma = smoth_param * np.std(p_array.tau())

  • nbins_x – number of bins for 2D hist. in horz. plane

  • nbins_y – number of bins for 2D hist. in vertical plane

  • interpolation – “bilinear”, and acceptable values are ‘none’, ‘nearest’, ‘bilinear’, ‘bicubic’, ‘spline16’, ‘spline36’, ‘hanning’, ‘hamming’, ‘hermite’, ‘kaiser’, ‘quadric’, ‘catrom’, ‘gaussian’, ‘bessel’

  • inverse_tau – False, inverse tau - head will be on the right side of figure

  • show_moments – False, show moments (X_mean_slice and Y_mean_slice) in the density distribution

  • nfig – number of the figure

  • title – None or string - title of the figure

  • figsize – None or e.g. (8, 6)

  • grid – True, show grid

  • filename – None or str, filename to save picture in the file

Returns

class ocelot.gui.accelerator.Save3DBeamDensity

Bases: ocelot.cpbd.physics_proc.PhysProc

Parent class for all Physics processes

Method prepare(self, lat)
  • the method is called at the moment of Physics Process addition to Navigator class.

Method apply(self, p_array, dz)
  • the method is called on every step.

Attribute step
  • number of steps in [Navigator.unit_step] self.step*Navigator.unit_step = [m]

Attribute indx0
  • number of start element in lattice.sequence - assigned in navigator.add_physics_proc()

Attribute indx1
  • number of stop element in lattice.sequence - assigned in navigator.add_physics_proc()

Attribute s_start
  • position of start element in lattice - assigned in navigator.add_physics_proc()

Attribute s_stop
  • position of stop element in lattice.sequence - assigned in navigator.add_physics_proc()

Attribute z0
  • current position of navigator - assigned in track.track() before p.apply()

apply_3d(self, p_array, dz)
apply(self, p_array, dz)

the method is called on every step.

Parameters
  • p_array

  • dz

Returns