:mod:`ocelot.gui.accelerator` ============================= .. py:module:: ocelot.gui.accelerator .. autoapi-nested-parse:: user interface for viewing/editing electron optics layouts Module Contents --------------- Classes ~~~~~~~ .. autoapisummary:: ocelot.gui.accelerator.Save3DBeamDensity Functions ~~~~~~~~~ .. autoapisummary:: ocelot.gui.accelerator.plot_lattice ocelot.gui.accelerator.elem_cord ocelot.gui.accelerator.plot_elems ocelot.gui.accelerator.plot_disp ocelot.gui.accelerator.plot_betas ocelot.gui.accelerator.plot_opt_func ocelot.gui.accelerator.plot_opt_func_reduced ocelot.gui.accelerator.plot_xy ocelot.gui.accelerator.plot_API ocelot.gui.accelerator.compare_betas ocelot.gui.accelerator.resonance ocelot.gui.accelerator.plot_resonance_diag ocelot.gui.accelerator.show_da ocelot.gui.accelerator.show_mu ocelot.gui.accelerator.show_density ocelot.gui.accelerator.show_e_beam ocelot.gui.accelerator.show_phase_space ocelot.gui.accelerator.compare_beams ocelot.gui.accelerator.compare_beams_reduced ocelot.gui.accelerator.show_e_beam_reduced ocelot.gui.accelerator.beam_jointplot .. function:: plot_lattice(lat, axis, alpha=1.0, params={'kmax': 2.0, 'ang_max': 0.005}, s_start=0.0) .. function:: elem_cord(lat) .. data:: dict_plot .. function:: plot_elems(fig, ax, lat, s_point=0, nturns=1, y_lim=None, y_scale=1, legend=True, font_size=18, excld_legend=None) .. function:: plot_disp(ax, tws, top_plot, font_size) .. function:: plot_betas(ax, S, beta_x, beta_y, font_size) .. function:: 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" :param lat: MagneticLattice, :param tws: list if Twiss objects, :param top_plot: ["Dx"] - parameters which displayed in top section. Can be any attribute of Twiss class, e.g. top_plot=["Dx", "Dy", "alpha_x"] :param legend: True - displaying legend of element types in bottom section, :param fig_name: None - name of figure, :param grid: True - grid :param font_size: 16 - font size for any element of plot :param excld_legend: None, exclude type of element from the legend, e.g. excld_legend=[Hcor, Vcor] :return: .. function:: 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. .. function:: plot_xy(ax, S, X, Y, font_size) .. function:: 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. :param lat: MagneticLattice :param legend: True, description of the elements, if False it is switched legend off :return: fig, ax .. function:: 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. .. function:: resonance(Qx, Qy, order=5) .. function:: plot_resonance_diag(ax, Qx, Qy, order) .. function:: show_da(out_da, x_array, y_array, title='') .. function:: show_mu(contour_da, mux, muy, x_array, y_array, zones=None) .. function:: 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 :param x: np.array :param y: np.array :param ax: None, subplot axis, if None creates standalone plot. :param nbins_x: 250, number of bins for 2D hist. in horz. plane :param nbins_y: 250, number of bins for 2D hist. in vertical plane :param interpolation: "bilinear". Acceptable values are 'none’, ‘nearest’, ‘bilinear’, ‘bicubic’, ‘spline16’, ‘spline36’, ‘hanning’, ‘hamming’, ‘hermite’, ‘kaiser’, ‘quadric’, ‘catrom’, ‘gaussian’, ‘bessel’ :param xlabel: None, otherwise "string" :param ylabel: None, otherwise "string" :param nfig: number of the figure :param title: title of the figure :param figsize: None or e.g. (8, 6) :param grid: True, show grid :param show_xtick_label: True :param label, None or string. :param limits, None or [[xmin, xmax], [ymin, ymax]] :return: .. function:: 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 :param p_array: ParticleArray :param nparts_in_slice: number of particles per slice :param smoth_param: 0.05, smoothing parameters to calculate the beam current: sigma = smoth_param * np.std(p_array.tau()) :param nbins_x: number of bins for 2D hist. in horz. plane :param nbins_y: number of bins for 2D hist. in vertical plane :param interpolation: "bilinear", and acceptable values are 'none’, ‘nearest’, ‘bilinear’, ‘bicubic’, ‘spline16’, ‘spline36’, ‘hanning’, ‘hamming’, ‘hermite’, ‘kaiser’, ‘quadric’, ‘catrom’, ‘gaussian’, ‘bessel’ :param inverse_tau: False, inverse tau - head will be on the right side of figure :param show_moments: False, show moments (X_mean_slice and Y_mean_slice) in the density distribution :param nfig: number of the figure :param title: None or string - title of the figure :param figsize: None or e.g. (8, 6) :param grid: True, show grid :param filename: None or str, filename to save picture in the file :param headtail: True, shows where is the beam head is. :param filter_base: support of rectangle filter is 2*p+1 :param filter_iter: the number of the filter iterations :return: .. function:: 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 :param p_array: ParticleArray :param nparts_in_slice: number of particles per slice :param smoth_param: 0.05, smoothing parameters to calculate the beam current: sigma = smoth_param * np.std(p_array.tau()) :param nbins_x: number of bins for 2D hist. in horz. plane :param nbins_y: number of bins for 2D hist. in vertical plane :param interpolation: "bilinear", and acceptable values are 'none’, ‘nearest’, ‘bilinear’, ‘bicubic’, ‘spline16’, ‘spline36’, ‘hanning’, ‘hamming’, ‘hermite’, ‘kaiser’, ‘quadric’, ‘catrom’, ‘gaussian’, ‘bessel’ :param inverse_tau: False, inverse tau - head will be on the right side of figure :param show_moments: False, show moments (X_mean_slice and Y_mean_slice) in the density distribution :param nfig: number of the figure :param title: None or string - title of the figure :param figsize: None or e.g. (8, 6) :param grid: True, show grid :return: .. function:: 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 :param p_array_1: ParticleArray :param p_array_2: ParticleArray :param nparts_in_slice1: number of particles per slice in p_array_1 :param nparts_in_slice2: number of particles per slice in p_array_2 :param smoth_param: 0.05, smoothing parameters to calculate the beam current: sigma = smoth_param * np.std(p_array.tau()) :param inverse_tau: False, inverse tau - head will be on the right side of figure :param nfig: number of the figure :param title: None or string - title of the figure :param figsize: None or e.g. (8, 6) :param legend_beam1: None, legend for beam N1 :param legend_beam2: None, legend for beam N1 :return: .. function:: 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 :param p_array_1: ParticleArray :param p_array_2: ParticleArray :param nparts_in_slice: number of particles per slice :param smoth_param: 0.05, smoothing parameters to calculate the beam current: sigma = smoth_param * np.std(p_array.tau()) :param inverse_tau: False, inverse tau - head will be on the right side of figure :param nfig: number of the figure :param title: None or string - title of the figure :param figsize: None or e.g. (8, 6) :param legend_beam1: None, legend for beam N1 :param legend_beam2: None, legend for beam N1 :return: .. function:: 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 :param p_array: ParticleArray :param nparts_in_slice: number of particles per slice :param smoth_param: 0.05, smoothing parameters to calculate the beam current: sigma = smoth_param * np.std(p_array.tau()) :param nbins_x: number of bins for 2D hist. in horz. plane :param nbins_y: number of bins for 2D hist. in vertical plane :param interpolation: "bilinear", and acceptable values are 'none’, ‘nearest’, ‘bilinear’, ‘bicubic’, ‘spline16’, ‘spline36’, ‘hanning’, ‘hamming’, ‘hermite’, ‘kaiser’, ‘quadric’, ‘catrom’, ‘gaussian’, ‘bessel’ :param inverse_tau: False, inverse tau - head will be on the right side of figure :param show_moments: False, show moments (X_mean_slice and Y_mean_slice) in the density distribution :param nfig: number of the figure :param title: None or string - title of the figure :param figsize: None or e.g. (8, 6) :param grid: True, show grid :param filename: None or str, filename to save picture in the file :return: .. function:: 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 :param p_array: ParticleArray :param nparts_in_slice: number of particles per slice :param smoth_param: 0.05, smoothing parameters to calculate the beam current: sigma = smoth_param * np.std(p_array.tau()) :param nbins_x: number of bins for 2D hist. in horz. plane :param nbins_y: number of bins for 2D hist. in vertical plane :param interpolation: "bilinear", and acceptable values are 'none’, ‘nearest’, ‘bilinear’, ‘bicubic’, ‘spline16’, ‘spline36’, ‘hanning’, ‘hamming’, ‘hermite’, ‘kaiser’, ‘quadric’, ‘catrom’, ‘gaussian’, ‘bessel’ :param inverse_tau: False, inverse tau - head will be on the right side of figure :param show_moments: False, show moments (X_mean_slice and Y_mean_slice) in the density distribution :param nfig: number of the figure :param title: None or string - title of the figure :param figsize: None or e.g. (8, 6) :param grid: True, show grid :param filename: None or str, filename to save picture in the file :return: .. py:class:: Save3DBeamDensity Bases: :class:`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() .. method:: apply_3d(self, p_array, dz) .. method:: apply(self, p_array, dz) the method is called on every step. :param p_array: :param dz: :return: