ocelot.gui package

Submodules

ocelot.gui.accelerator module

user interface for viewing/editing electron optics layouts

class ocelot.gui.accelerator.Save3DBeamDensity

Bases: ocelot.cpbd.physics_proc.PhysProc

apply(p_array, dz)

the method is called on every step.

Parameters
  • p_array

  • dz

Returns

apply_3d(p_array, dz)
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

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.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.elem_cord(lat)
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.plot_betas(ax, S, beta_x, beta_y, font_size)
ocelot.gui.accelerator.plot_disp(ax, tws, top_plot, font_size)
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_lattice(lat, axis, alpha=1.0, params={'ang_max': 0.005, 'kmax': 2.0}, s_start=0.0)
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_resonance_diag(ax, Qx, Qy, order)
ocelot.gui.accelerator.plot_xy(ax, S, X, Y, font_size)
ocelot.gui.accelerator.resonance(Qx, Qy, order=5)
ocelot.gui.accelerator.show_da(out_da, x_array, y_array, title='')
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_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.show_mu(contour_da, mux, muy, x_array, y_array, zones=None)
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.beam_plot module

ocelot.gui.beam_plot.plot_beam(beam, figsize=3, showfig=True, savefig=False, fig=None, plot_xy=None, debug=0)
ocelot.gui.beam_plot.plot_estimator_energy_evo(fel, fig=None, und_duty_factor=1, **kwargs)
ocelot.gui.beam_plot.plot_estimator_power_evo(fel, fig=None, und_duty_factor=1, **kwargs)
ocelot.gui.beam_plot.plot_estimator_power_z(fel, z=None, fig=None, und_duty_factor=1, fs=False)

plots estimated FEL power at position z fel is FelParamterArray object und_duty_factor <= 1

ocelot.gui.beam_plot.plot_estimator_spectrogram(fel, z=None, fig=None, cmap='Reds', **kwargs)
ocelot.gui.beam_plot.plot_estimator_spectrum(fel, z=None, fig=None, **kwargs)

ocelot.gui.db_example1 module

ocelot.gui.designer module

ocelot.gui.dfl_plot module

user interface for viewing radiation field

ocelot.gui.dfl_plot.plot_1d_hprofile(height_profile, figsize=4, fig_name='Height profile', savefig=False, showfig=True, **kwargs)

This function plotting the height map and PSD of HeightProfile object

Parameters
  • height_profile – HeightProfile object from ocelot

  • figsize – size of figure

  • fig_name – name of figure

  • savefig – bool type flag, responding for saving figure

  • showfig – bool type flag, responding for showing figure

  • kwargs

ocelot.gui.dfl_plot.plot_dfl(dfl, domains=None, z_lim=[], xy_lim=[], figsize=4, cmap='viridis', legend=True, phase=False, fig_name=None, auto_zoom=False, column_3d=True, savefig=False, showfig=True, return_proj=False, line_off_xy=True, slice_xy=False, log_scale=0, cmap_cutoff=0, vartype_dfl=None, **kwargs)

Plots dfl radiation object in 3d using matplotlib.

Parameters
  • dfl – RadiationField() object

  • domains – longitudinal domain + transverse domain (‘t’ or ‘f’ + ‘s’ or ‘k’) (example: ‘tk’ - time/inversespace domain)

  • z_lim – sets the boundaries to CUT the dfl object in z to ranges of e.g. [2,5] um or nm depending on freq_domain=False of True

  • xy_lim – sets the boundaries to SCALE the dfl object in x and y to ranges of e.g. [2,5] um or urad depending on far_field=False of True

  • figsize – rescales the size of the figure

  • cmap – color map which will be used for plotting (http://matplotlib.org/users/colormaps.html)

  • legend – not used yet

  • phase – bool type variable, can replace Z projection or spectrum with phase front distribution z dimensions correspondingly

  • fig_name – the desired name of the output figure, would be used as suffix to the image filename if savefig==True

  • auto_zoom – bool type variable, automatically scales xyz the images to the (1%?) of the intensity limits

  • column_3d – bool type variable, plots top and side views of the radiation distribution

  • savefig – bool type variable, allow to save figure to image (savefig=’png’ (default) or savefig=’eps’, etc…)

  • showfig – bool type variable, allow to display figure (slower)

  • return_proj – bool type variable, returns [xy_proj,yz_proj,xz_proj,x,y,z] array.

  • line_off_xy – bool type variable, if True, the transverse size of radiation are calculated at x=0 and y=0 position, otherwise marginal distribution are used

  • slice_xy – bool type variable, if True, slices will be plotted; if False, projections will be plotted

  • log_scale – bool type variable, if True, log scale will be used for potting

  • cmap_cutoff – 0 <= cmap_cutoff <= 1; all pixels that have intensity lower than cmap_cutoff will be seted to white color

  • vartype_dfl – the data type to store dfl in memory [either complex128 (two 64-bit floats) or complex64 (two 32-bit floats)], may save memory

  • kwargs

Returns

ocelot.gui.dfl_plot.plot_dfl_all(dfl, **kwargs)

plots given RadiationField() object in 4 domain combinations

ocelot.gui.dfl_plot.plot_dfl_waistscan(sc_res, fig_name=None, figsize=4, showfig=True, savefig=False)
ocelot.gui.dfl_plot.plot_hprofile(*args, **kwargs)
ocelot.gui.dfl_plot.plot_stokes_3d(stk_params, x_plane='max_slice', y_plane='max_slice', z_plane='max_slice', interpolation=None, cmap_lin='brightwheel', cmap_circ='bwr', figsize=4, fig_name='Visualization Stokes parameters', normalization='s0_max', cbars=True, savefig=False, showfig=True, text_present=True, **kwargs)

Plot 6 images with normalized Stokes parameters on them

Parameters
  • stk_params – 3d ocelot.optics.wave.StokesParameters() type object

  • x_plane – this variable responds on which value on x-axis the 3d stk_params will intersect. It can take 3 different recognition: ‘max_slice’: the intersection of 3d stk_params will contain the max value s0 in stk_params ‘proj’: at the third subplot will be shown the projection of 3d stk_params in x direction <number> in [m]: the position of intersection on x-axis

  • y_plane – this variable responds on which value on y-axis the 3d stk_params will intersect. It can take 3 different recognition: ‘max_slice’: the intersection of 3d stk_params will contain the max value s0 in stk_params ‘proj’: at the third subplot will be shown the projection of 3d stk_params in y direction <number> in [m]: the position of intersection on y-axis

  • z_plane – this variable responds on which value on z-axis the 3d stk_params will intersect. It can take 3 different recognition: ‘max_slice’: the intersection of 3d stk_params will contain the max value s0 in stk_params ‘proj’: at the third subplot will be shown the projection of 3d stk_params in z direction <number> in [m]: the position of intersection on z-axis

  • interpolation – str type variable wich responds for interpolation before plotting linear polarized part

  • cmap_lin – numpy array with shape (nwidth, nheight, 4) that contains the 4 rgba values in hue (width) and lightness (height). Can be obtained by a call to get_cmap2d(name). or: name where name is one of the following strings: ‘brightwheel’, ‘darkwheel’, ‘hardwheel’, ‘newwheel’, ‘smoothwheel’, ‘wheel’

:param cmap_circ:——————– :param figsize: size of the figure :param fig_name: name of the figure :param cbars: bool type variable which responds for showing of colorbars :param savefig: bool type variable which responds for saving of the figure :param showfig: bool type variable which responds for showing of the figure :param text_present: bool type variable which responds for showing text on subplots :param kwargs:

ocelot.gui.dfl_plot.plot_stokes_angles(S, fig=None, showfig=True, direction='z', plot_func='scatter')
ocelot.gui.dfl_plot.plot_stokes_sbfg_circ(ax, stk_params, slice, plane, cmap='seismic', plot_title=None, x_label='', y_label='', result=0, text_present=True, interpolation=None, normalization='s0_max', **kwargs)

Plot normalized Stokes parameter S3

Parameters
  • ax – matplotlib.pyplot.AxesSubplot on which the data will be plotted

  • stk_params – 3d ocelot.optics.wave.StokesParameters() type object

  • plane – the direction in which the projection/intersection of {stk_params} will be done

  • slice – this variable responds on which value on {plane} direction the 3d stk_params will intersect. It can take 3 different recognition: ‘max_slice’: the intersection of 3d stk_params will contain the max value s0 in stk_params ‘proj’: at the third subplot will be shown the projection of 3d stk_params in {plane} direction <number> in [m]: the position of intersection on {plane} direction

  • cmap – colormap which will be used for plotting data

  • plot_title – title of the plot

  • x_label – label of the x axis

  • y_label – label of the y axis

  • result – a bool type variable; if bool == True the function will return linear_plt of AxesImage type

  • text_present – bool type variable which responds for showing text on subplots

  • interpolation – str type variable wich responds for interpolation before plotting linear polarized part

  • kwargs

Returns

ocelot.gui.dfl_plot.plot_stokes_sbfg_lin(ax, stk_params, slice, plane, cmap2d='brightwheel', plot_title=None, x_label='', y_label='', result=0, text_present=True, interpolation=None, normalization='s0_max', **kwargs)

Plot normalized intensity and angle of the linear polarization of the light

Parameters
  • ax – matplotlib.pyplot.AxesSubplot on which the data will be plotted

  • stk_params – 3d ocelot.optics.wave.StokesParameters() type object

  • plane – the direction in which the projection/intersection of {stk_params} will be done

  • slice – this variable responds on which value on {plane} direction the 3d stk_params will intersect. It can take 3 different recognition: ‘max_slice’: the intersection of 3d stk_params will contain the max value s0 in stk_params ‘proj’: at the third subplot will be shown the projection of 3d stk_params in {plane} direction <number> in [m]: the position of intersection on {plane} direction

  • cmap2d – numpy array with shape (nwidth, nheight, 4) that contains the 4 rgba values in hue (width) and lightness (height). Can be obtained by a call to get_cmap2d(name). or: name where name is one of the following strings: ‘brightwheel’, ‘darkwheel’, ‘hardwheel’, ‘newwheel’, ‘smoothwheel’, ‘wheel’

  • plot_title – title of the plot

  • x_label – label of the x axis

  • y_label – label of the y axis

  • result – a bool type variable; if bool == True the function will return linear_plt of AxesImage type

  • text_present – bool type variable which responds for showing text on subplots

  • interpolation – str type variable wich responds for interpolation before plotting linear polarized part

  • kwargs

Returns

ocelot.gui.dfl_plot.plot_stokes_values(S, fig=None, d_pol=0, norm=0, showfig=True, gw=1, direction='z', plot_func='step', **kwargs)
ocelot.gui.dfl_plot.plot_trf(trf, mode='tr', autoscale=0, showfig=True, savefig=None, fig_name=None)

plots TransferFunction() object, mode:

‘tr’ - transmission ‘ref’ - reflection

autoscale = scale down to several FWHMma in frequency and several bumps in time showfig - display on screen or not savefig - path to save png (if any)

ocelot.gui.dfl_plot.plot_wigner(wig_or_out, z=inf, x_units='um', y_units='ev', x_lim=None, None, y_lim=None, None, downsample=1, autoscale=None, figsize=3, cmap='seismic', fig_name=None, savefig=False, showfig=True, plot_proj=1, plot_text=1, plot_moments=0, plot_cbar=0, log_scale=0, **kwargs)

Plots wigner distribution (WD) with marginals

Parameters
  • wig_or_out – may be WignerDistribution() or GenesisOutput() object

  • z – (if isinstance(wig_or_out, GenesisOutput)) location at which WD will be calculated

  • x_units – [m or fs] units to display power scale

  • y_units – [nm or eV] units to display spectrum scale

  • x_lim – scaling limits for x in given units, (min,max) or [min,max], e.g: (None,6)

  • x_lim – scaling limits for y in given units, (min,max) or [min,max], e.g: (None,6)

  • downsample – speeds up plotting by displaying only 1/downsample**2 points

  • autoscale – find x_lim and x_lim values automatically. Only (values > max_value * autoscale) will be displayed

  • figsize – rescales the size of the figure

  • cmap – colormar (http://matplotlib.org/users/colormaps.html)

  • fig_name – the desired name of the output figure, would be used as suffix to the image filename if savefig==True

  • savefig – bool type variable, allow to save figure to image (savefig=’png’ (default) or savefig=’eps’, etc…)

  • showfig – bool type variable, allow to display figure (slower)

  • plot_proj – plot marginal distributions

  • plot_text – show text

  • plot_moments – plot moments as lines on top of Wigner distribution

  • plot_cbar – plots colorbar

  • log_scale – plots wigner distribution in logarithmic scale

  • kwargs

Returns

None

ocelot.gui.genesis4_plot module

user interface for viewing genesis simulation results

ocelot.gui.genesis4_plot.plot_gen4_out_all(handle=None, savefig='png', showfig=False, choice=(1, 1, 1, 1, 10, 1, 0, 0, 0, 0, 0, 10, 1), vartype_dfl=<class 'numpy.complex128'>, *args, **kwargs)
ocelot.gui.genesis4_plot.plot_gen4_out_e(out, legend=False, figsize=3, fig_name='Electrons', savefig=False, showfig=True, debug=1)
ocelot.gui.genesis4_plot.plot_gen4_out_evo(out, params=['und_quad', 'el_size', 'el_pos', 'el_energy', 'el_bunching', 'rad_pow_en_log', 'rad_pow_en_lin', 'rad_spec_log', 'rad_size', 'rad_spec_evo_n', 'rad_pow_evo_n'], figsize=3, legend=False, fig_name=None, savefig=False, showfig=True, debug=1)

plots evolution of given parameters from genesis output with undulator length

ocelot.gui.genesis4_plot.plot_gen4_out_ph(out, legend=False, figsize=3, fig_name='Radiation', savefig=False, showfig=True, debug=1)
ocelot.gui.genesis4_plot.plot_gen4_out_z(out, z=inf, params=['rad_power+el_current', 'el_energy+el_espread+el_bunching', 'rad_spec'], figsize=3, x_units='um', y_units='ev', legend=False, fig_name=None, savefig=False, showfig=True, debug=1, *args, **kwargs)

radiation parameters at distance z out/out = GenesisOutput() object z distance along undulator [m] params = parameters of interest:

‘rad_power+el_current’ - radiation power and electron beam current ‘el_energy+el_espread+el_bunching’ - electron beam energy +/- spread and bunching ‘rad_phase’ - phase of radiation ‘rad_spec’ - on-axis spectrum

figsize - np.size of figure (unit-less) x_units - units of time domain (‘um’ of ‘fs’) y_units - units of frequency domain (‘nm’ of ‘ev’) legend - plot legend - tbd fig_name - override figure name savefig - save figure showfig - show figure

ocelot.gui.genesis4_plot.subfig_evo_el_bunching(ax_bunching, out, legend)
ocelot.gui.genesis4_plot.subfig_evo_el_energy(ax_energy, out, legend)
ocelot.gui.genesis4_plot.subfig_evo_el_pos(ax_size_tpos, out, legend, which='both')
ocelot.gui.genesis4_plot.subfig_evo_el_size(ax_size_tsize, out, legend, which='both')
ocelot.gui.genesis4_plot.subfig_evo_rad_pow(ax_rad_pow, out, legend, log=1)
ocelot.gui.genesis4_plot.subfig_evo_rad_pow_en(ax_rad_pow, out, legend, log=1)
ocelot.gui.genesis4_plot.subfig_evo_rad_pow_sz(ax_power_evo, out, legend, norm=1, **kwargs)
ocelot.gui.genesis4_plot.subfig_evo_rad_spec(ax_spectrum, out, legend, log=1)
ocelot.gui.genesis4_plot.subfig_evo_rad_spec_sz(ax_spectrum_evo, out, legend, norm=1)
ocelot.gui.genesis4_plot.subfig_evo_und(ax_und, out, legend)
ocelot.gui.genesis4_plot.subfig_evo_und_quad(ax_und, out, legend)
ocelot.gui.genesis4_plot.subfig_rad_size(ax_size_t, out, legend)
ocelot.gui.genesis4_plot.subfig_z_energy_espread(ax_energy, out, zi=None, x_units='um', legend=False)
ocelot.gui.genesis4_plot.subfig_z_energy_espread_bunching(ax_energy, out, zi=None, x_units='um', legend=False)
ocelot.gui.genesis4_plot.subfig_z_phase(ax_phase, out, zi=None, x_units='um', legend=False, rewrap=False)
ocelot.gui.genesis4_plot.subfig_z_power_curr(ax_curr, out, zi=None, x_units='um', legend=False)
ocelot.gui.genesis4_plot.subfig_z_spec(ax_spectrum, out, zi=None, loc='near', y_units='ev', estimate_ph_sp_dens=True, legend=False)

ocelot.gui.genesis_plot module

user interface for viewing genesis simulation results

class ocelot.gui.genesis_plot.Display(data=<function Display.<lambda>>, xlabel='', ylabel='')

Bases: object

ocelot.gui.genesis_plot.plot_dpa_bucket(dpa, slice_num=None, repeat=1, GeV=1, figsize=4, cmap='viridis', scatter=False, energy_mean=None, legend=True, fig_name=None, savefig=False, showfig=True, suffix='', bins=50, 50, debug=1, return_mode_gamma=0)
ocelot.gui.genesis_plot.plot_dpa_bucket_out(out, dpa=None, slice_pos='max_I', repeat=1, GeV=1, figsize=4, cmap='viridis', scatter=True, energy_mean=None, legend=True, fig_name=None, savefig=False, showfig=True, bins=[50, 50], debug=1)
ocelot.gui.genesis_plot.plot_edist(edist, figsize=4, fig_name=None, savefig=False, showfig=True, scatter=False, plot_x_y=True, plot_xy_s=True, bins=50, 50, 50, 50, flip_t=False, x_units='um', y_units='ev', cmin=0, y_offset=None, cmap='viridis', debug=1)
ocelot.gui.genesis_plot.plot_gen_corr(proj_dir, run_inp=[], p1=(), p2=(), savefig=False, showfig=True, saveval=False)
ocelot.gui.genesis_plot.plot_gen_out_all(handle=None, savefig='png', showfig=False, choice='all', vartype_dfl=<class 'numpy.complex128'>, debug=1, *args, **kwargs)

plots all possible output from the genesis output handle is either:

genesis output object path to genesis output file path to folders with genesis output files

choice=(1,1,1,1,6.05,1,0,0,0,0,0)

0 1 2 3 4 5 6 7 8 9 10

0 - electron evolution 1 - radiation evolution 2 - profile at z=0m 3 - profile at the end 4 - profile every m meters 5 - dfl at the end, space -time domain 6 - inv.space-time domain 7 - space -frequency domain 8 - inv.space-frequency domain 9 - dpa as edist at the end, smeared 10 - dpa as edist at the end, not smeared 11 - wigner distribution at end, 12 - ebeam bucket at max power

#picks as an input “GenesisOutput” object, file path of directory as strings. #plots e-beam evolution, radiation evolution, initial and final simulation window #If folder path is provided, all *.gout and *.out files are plotted

ocelot.gui.genesis_plot.plot_gen_out_all_paral(exp_dir, stage=1, savefig='png', debug=1)
ocelot.gui.genesis_plot.plot_gen_out_e(g, legend=False, figsize=4, fig_name='Electrons', savefig=False, showfig=True, debug=1, *args, **kwargs)
ocelot.gui.genesis_plot.plot_gen_out_evo(g, params=['und_quad', 'el_size', 'el_pos', 'el_energy', 'el_bunching', 'rad_pow_en_log', 'rad_pow_en_lin', 'rad_spec_log', 'rad_size', 'rad_spec_evo_n', 'rad_pow_evo_n'], figsize=4, legend=False, fig_name='', savefig=False, showfig=True, debug=1, *args, **kwargs)

plots evolution of given parameters from genesis output with undulator length

ocelot.gui.genesis_plot.plot_gen_out_ph(g, legend=False, figsize=4, fig_name='Radiation', savefig=False, showfig=True, debug=1, *args, **kwargs)
ocelot.gui.genesis_plot.plot_gen_out_scanned_z(g, figsize=10, 14, legend=True, fig_name=None, z=inf, savefig=False)
ocelot.gui.genesis_plot.plot_gen_out_slip(g, legend=False, figsize=4, fig_name='Slippage', savefig=False, showfig=True, debug=1, *args, **kwargs)
ocelot.gui.genesis_plot.plot_gen_out_z(g, z=inf, params=['rad_power+el_current', 'el_energy+el_espread+el_bunching', 'rad_spec'], figsize=3.5, x_units='um', y_units='ev', legend=False, fig_name=None, savefig=False, showfig=True, debug=1, *args, **kwargs)

radiation parameters at distance z g/out = GenesisOutput() object z distance along undulator [m] params = parameters of interest:

‘rad_power+el_current’ - radiation power and electron beam current ‘el_energy+el_espread+el_bunching’ - electron beam energy +/- spread and bunching ‘rad_phase’ - phase of radiation ‘rad_spec’ - on-axis spectrum

out_z_params overrides params figsize - np.size of figure (unit-less) x_units - units of time domain (‘um’ of ‘fs’) y_units - units of frequency domain (‘nm’ of ‘ev’) legend - plot legend - tbd fig_name - override figure name savefig - save figure showfig - show figure showtext - print text with additional info

ocelot.gui.genesis_plot.plot_gen_out_z_old(g, figsize=10, 14, x_units='um', y_units='ev', legend=True, fig_name=None, z=inf, savefig=False, showfig=1, debug=1, **kwargs)
ocelot.gui.genesis_plot.plot_gen_stat(proj_dir, run_inp=[], stage_inp=[], param_inp=[], s_param_inp=['p_int', 'pulse_energy', 'r_size_weighted', 'spec', 'spec_phot_density', 'error'], z_param_inp=['p_int', 'phi_mid_disp', 'spec', 'spec_phot_density', 'bunching', 'wigner'], dfl_param_inp=['dfl_spec'], run_param_inp=['p_int', 'spec', 'spec_phot_density', 'pulse_energy'], s_inp=['max'], z_inp=[0, 'end'], run_s_inp=['max'], run_z_inp=['end'], spec_pad=1, savefig=1, saveval=1, showfig=0, debug=1)

The routine for plotting the statistical info of many GENESIS runs — Will be rewritten and split in several separate modules —

proj_dir is the directory path in which

un_xxx folders are located.

run_inp=[1,2,3] number of runs to be processed, default - all possible up to run 1000 stage_inp=[1,2,3] stages to be processed, default - all possible up to stage 15 s_param_inp=[‘p_int’,’energy’] parameters to be displayed at certain position along the beam as a function of undulator length z_param_inp=[‘p_int’,’phi_mid_disp’,’spec’,’bunching’] parameters to be displayed at certain position along the undulator length as a function of location along the beam. s_inp=[1e-6,’max’,’mean’] positions at s to be plotted as function of z, max value of s as a function of z, mean value of s as a function of z z_inp=[12,’end’] position of z at which radiation and spectrum parameters are plotted savefig=1 save figures to given file format into proj_dir/results folder. 1 corresponds to ‘png’. accepts other values, such as ‘eps’ saveval=1, saves values being plotted to text files with the same names as the figures. first column - argument value (s[um],z[m],or lamd[nm]), second column - averaged parameters over shots, rest columns - single shot values. showfig=1 envokes plt.show() to display figures interactively. May be time- and processor-consuming

dfl_power, dfl_spec, dfl_size, dfl_divergence

ocelot.gui.genesis_plot.read_plot_dump_proj(exp_dir, stage, run_ids, plot_phase=1, showfig=True, savefig=0, debug=1)
ocelot.gui.genesis_plot.show_output(g, show_field=False, show_slice=0)
ocelot.gui.genesis_plot.show_plots(displays, fig)

putting arbitrarily many plots on single figure

ocelot.gui.genesis_plot.subfig_evo_el_bunching(ax_bunching, g, legend, harm=1, **kwargs)
ocelot.gui.genesis_plot.subfig_evo_el_energy(ax_energy, g, legend, **kwargs)
ocelot.gui.genesis_plot.subfig_evo_el_pos(ax_size_tpos, g, legend, which='both', **kwargs)
ocelot.gui.genesis_plot.subfig_evo_el_size(ax_size_tsize, g, legend, which='both', **kwargs)
ocelot.gui.genesis_plot.subfig_evo_rad_pow(ax_rad_pow, g, legend, log=1, **kwargs)
ocelot.gui.genesis_plot.subfig_evo_rad_pow_en(ax_rad_pow, g, legend, log=1, **kwargs)
ocelot.gui.genesis_plot.subfig_evo_rad_pow_sz(ax_power_evo, g, legend, norm=1, **kwargs)
ocelot.gui.genesis_plot.subfig_evo_rad_spec(ax_spectrum, g, legend, log=1, **kwargs)
ocelot.gui.genesis_plot.subfig_evo_rad_spec_sz(ax_spectrum_evo, g, legend, norm=1, **kwargs)
ocelot.gui.genesis_plot.subfig_evo_und(ax_und, g, legend, **kwargs)
ocelot.gui.genesis_plot.subfig_evo_und_quad(ax_und, g, legend, **kwargs)
ocelot.gui.genesis_plot.subfig_rad_size(ax_size_t, g, legend, **kwargs)
ocelot.gui.genesis_plot.subfig_z_energy_espread(ax_energy, g, zi=None, x_units='um', legend=False, *args, **kwargs)
ocelot.gui.genesis_plot.subfig_z_energy_espread_bunching(ax_energy, g, zi=None, x_units='um', legend=False, *args, **kwargs)
ocelot.gui.genesis_plot.subfig_z_phase(ax_phase, g, zi=None, x_units='um', legend=False, *args, **kwargs)
ocelot.gui.genesis_plot.subfig_z_power_curr(ax_curr, g, zi=None, x_units='um', legend=False, *args, **kwargs)
ocelot.gui.genesis_plot.subfig_z_spec(ax_spectrum, g, zi=None, y_units='ev', estimate_ph_sp_dens=True, legend=False, *args, **kwargs)

ocelot.gui.misc module

ocelot.gui.moga_plt module

class ocelot.gui.moga_plt.ParetoPlot

Bases: object

get_data()
get_data_once()
plot()
run()
show_once()

ocelot.gui.optics module

user interface for viewing/editing photon optics layouts

ocelot.gui.optics.init_plots(views, geo)
ocelot.gui.optics.plot_geometry(ax, geo, proj='y')
ocelot.gui.optics.plot_rays(ax, rays, proj='x', alpha=0.4)

ocelot.gui.plot_gen_out module

ocelot.gui.qrc_icons module

ocelot.gui.settings_plot module

ocelot.gui.settings_plot.if_plottable(plotting_func)
ocelot.gui.settings_plot.save_figure(plotting_func)
ocelot.gui.settings_plot.save_show(plotting_func)

ocelot.gui.sr_plot module

ocelot.gui.sr_plot.D1(data, X, distance, xlabel, xlim, ylim, file_name, unit, status, xlog=False, ylog=False, title=None, nfig=1, grid=True)
ocelot.gui.sr_plot.D3(screen, Data, distance, file_name=None, unit='mm', title=None, nfig=1)
ocelot.gui.sr_plot.plot3D_data(data, x=None, y=None)
ocelot.gui.sr_plot.show_flux(screen, show='Total', xlim=0, 0, ylim=0, 0, file_name=None, unit='mm', title=None, nfig=1, grid=True, xlog=False, ylog=False)

Function to plot radiation flux density 1D and 3D

Parameters
  • screen – Screen class

  • show – str, show polarization component, can be “Total”, “Sigma” or “Pi”

  • xlim – (0,0), xlimits, ignored if (0,0)

  • ylim – (0,0), ylimits, ignored if (0,0)

  • file_name – str, if None flux will be shown otherwise save to file

  • unit – str, units for spatial axis, can be “mm” or “mrad”,

  • title – figure title

  • nfig – figure number

  • grid – True, if False not show the grid

  • xlog – False, log scale for x-axis

  • ylog – False, log scale for y-axis

Returns

Module contents

ocelot.gui.plot_lattice(lat, axis, alpha=1.0, params={'ang_max': 0.005, 'kmax': 2.0}, s_start=0.0)
ocelot.gui.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.show_da(out_da, x_array, y_array, title='')
ocelot.gui.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.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.show_flux(screen, show='Total', xlim=0, 0, ylim=0, 0, file_name=None, unit='mm', title=None, nfig=1, grid=True, xlog=False, ylog=False)

Function to plot radiation flux density 1D and 3D

Parameters
  • screen – Screen class

  • show – str, show polarization component, can be “Total”, “Sigma” or “Pi”

  • xlim – (0,0), xlimits, ignored if (0,0)

  • ylim – (0,0), ylimits, ignored if (0,0)

  • file_name – str, if None flux will be shown otherwise save to file

  • unit – str, units for spatial axis, can be “mm” or “mrad”,

  • title – figure title

  • nfig – figure number

  • grid – True, if False not show the grid

  • xlog – False, log scale for x-axis

  • ylog – False, log scale for y-axis

Returns

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