mbtrack2.tracking.monitors package

Submodules

mbtrack2.tracking.monitors.monitors module

This module defines the different monitor class which are used to save data during tracking.

class mbtrack2.tracking.monitors.monitors.BeamMonitor(h, save_every, buffer_size, total_size, file_name=None, mpi_mode=False)[source]

Bases: Monitor

Monitor the full beam and save each bunch attributes (mean, std, emit and current).

hint

Harmonic number of the ring.

save_everyint or float

Set the frequency of the save. The data is saved every save_every call of the montior.

buffer_sizeint or float

Size of the save buffer.

total_sizeint or float

Total size of the save. The following relationships between the parameters must exist:

total_size % buffer_size == 0 number of call to track / save_every == total_size

file_namestring, optional

Name of the HDF5 where the data will be stored. Must be specified the first time a subclass of Monitor is instancied and must be None the following times.

mpi_modebool, optional

If True, open the HDF5 file in parallel mode, which is needed to allow several cores to write in the same file at the same time. If False, open the HDF5 file in standard mode.

track(beam)

Save data

to_buffer(bunch, bunch_num)[source]

Save data to buffer, if mpi is being used.

bunch : Bunch object bunch_num : int

to_buffer_no_mpi(beam)[source]

Save data to buffer, if mpi is not being used.

beam : Beam object

track(beam)[source]

Save data

beam : Beam object

write(bunch_num)[source]

Write data from buffer to the HDF5 file, if mpi is being used.

bunch_num : int

write_no_mpi()[source]

Write data from buffer to the HDF5 file, if mpi is not being used.

class mbtrack2.tracking.monitors.monitors.BeamSpectrumMonitor(ring, save_every, buffer_size, total_size, dim='all', n_fft=None, file_name=None, mpi_mode=False)[source]

Bases: Monitor

Monitor coherent beam spectrum.

ring : Synchrotron object save_every : int or float

Set the frequency of the save. The spectrums are computed every save_every call of the montior.

buffer_sizeint or float

Size of the save buffer.

total_sizeint or float

Total size of the save. The following relationships between the parameters must exist:

total_size % buffer_size == 0 number of call to track / save_every == total_size - 1

dimstr, optional

Dimensions in which the spectrums have to be computed. Can be:

  • “all”

  • “tau”

  • “x”

  • “y”

  • “xy” or “yx”

  • “xtau” or “taux”

  • “ytau” or “tauy”

n_fftint or float, optional

The number of points used for FFT computation, if n_fft is bigger than save_every zero-padding is applied. If None, save_every is used.

file_namestring, optional

Name of the HDF5 where the data will be stored. Must be specified the first time a subclass of Monitor is instancied and must be None the following times.

mpi_modebool, optional

If True, open the HDF5 file in parallel mode, which is needed to allow several cores to write in the same file at the same time. If False, open the HDF5 file in standard mode.

fft_resolutionfloat

Return the fft resolution in [Hz].

signal_resolutionfloat

Return the signal resolution in [Hz].

frequency_samplesarray of float

Return the fft frequency samples in [Hz].

track(bunch):

Save spectrum data.

property fft_resolution

Return the fft resolution in [Hz].

It is defined as the sampling frequency over the number of samples.

property frequency_samples

Return the fft frequency samples in [Hz].

get_beam_spectrum(mean)[source]

Compute the beam coherent spectrum i.e. the absolute value of the FT of the mean position of every bunch.

coherentarray

The beam coherent spectrum.

property signal_resolution

Return the signal resolution in [Hz].

It is defined as the inverse of the signal length.

to_buffer(beam)[source]

A method to hold saved data before writing it to the output file.

track(beam)[source]

Save mean data.

beam : Beam object

write()[source]

Write data from buffer to output file.

class mbtrack2.tracking.monitors.monitors.BunchMonitor(bunch_number, save_every, buffer_size, total_size, file_name=None, mpi_mode=False)[source]

Bases: Monitor

Monitor a single bunch and save attributes (mean, std, emit, current, and cs_invariant).

bunch_numberint

Bunch to monitor

save_everyint or float

Set the frequency of the save. The data is saved every save_every call of the montior.

buffer_sizeint or float

Size of the save buffer.

total_sizeint or float

Total size of the save. The following relationships between the parameters must exist:

total_size % buffer_size == 0 number of call to track / save_every == total_size

file_namestring, optional

Name of the HDF5 where the data will be stored. Must be specified the first time a subclass of Monitor is instancied and must be None the following times.

mpi_modebool, optional

If True, open the HDF5 file in parallel mode, which is needed to allow several cores to write in the same file at the same time. If False, open the HDF5 file in standard mode.

track(object_to_save)

Save data

track(object_to_save)[source]

Save data

object_to_save : Bunch or Beam object

class mbtrack2.tracking.monitors.monitors.BunchSpectrumMonitor(ring, bunch_number, mp_number, sample_size, save_every, buffer_size, total_size, dim='all', n_fft=None, file_name=None, mpi_mode=False)[source]

Bases: Monitor

Monitor the coherent and incoherent bunch spectrums.

ring : Synchrotron object bunch_number : int

Bunch to monitor

mp_numberint or float

Total number of macro-particles in the bunch.

sample_sizeint or float

Number of macro-particles to be used for tune and FFT computation. This number cannot exceed mp_number.

save_everyint or float

Set the frequency of the save. The spectrums are computed every save_every call of the montior.

buffer_sizeint or float

Size of the save buffer.

total_sizeint or float

Total size of the save. The following relationships between the parameters must exist:

total_size % buffer_size == 0 number of call to track / save_every == total_size - 1

dimstr, optional

Dimensions in which the spectrums have to be computed. Can be:

  • “all”

  • “tau”

  • “x”

  • “y”

  • “xy” or “yx”

  • “xtau” or “taux”

  • “ytau” or “tauy”

n_fftint or float, optional

The number of points used for FFT computation, if n_fft is bigger than save_every zero-padding is applied. If None, save_every is used.

file_namestring, optional

Name of the HDF5 where the data will be stored. Must be specified the first time a subclass of Monitor is instancied and must be None the following times.

mpi_modebool, optional

If True, open the HDF5 file in parallel mode, which is needed to allow several cores to write in the same file at the same time. If False, open the HDF5 file in standard mode.

fft_resolutionfloat

Return the fft resolution in [Hz].

signal_resolutionfloat

Return the signal resolution in [Hz].

frequency_samplesarray of float

Return the fft frequency samples in [Hz].

track(bunch):

Save spectrum data.

property fft_resolution

Return the fft resolution in [Hz].

It is defined as the sampling frequency over the number of samples.

property frequency_samples

Return the fft frequency samples in [Hz].

get_coherent_spectrum(mean)[source]

Compute the coherent spectrum i.e. the absolute value of the FT of the mean position of the bunch.

coherentarray

Bunch coherent spectrum.

get_incoherent_spectrum(positions)[source]

Compute the incoherent spectrum i.e. the average of the absolute value of the FT of the position of every particule of the bunch.

incoherentarray

Bunch incoherent spectrum.

mean_incoherentfloat

Mean frequency of the maximum of each individual particle spectrum in [Hz].

std_incoherentfloat

Standard deviation of the frequency of the maximum of each individual particle spectrum in [Hz].

property signal_resolution

Return the signal resolution in [Hz].

It is defined as the inverse of the signal length.

to_buffer(bunch)[source]

A method to hold saved data before writing it to the output file.

track(object_to_save)[source]

Save spectrum data.

object_to_save : Beam or Bunch object

write()[source]

Write data from buffer to output file.

class mbtrack2.tracking.monitors.monitors.CavityMonitor(cavity_name, ring, save_every, buffer_size, total_size, file_name=None, mpi_mode=False)[source]

Bases: Monitor

Monitor a CavityResonator object and save attributes.

cavity_namestr

Name of the CavityResonator object to monitor.

ring : Synchrotron object save_every : int or float

Set the frequency of the save. The data is saved every save_every call of the montior.

buffer_sizeint or float

Size of the save buffer.

total_sizeint or float

Total size of the save. The following relationships between the parameters must exist:

total_size % buffer_size == 0 number of call to track / save_every == total_size

file_namestring, optional

Name of the HDF5 where the data will be stored. Must be specified the first time a subclass of Monitor is instancied and must be None the following times.

mpi_modebool, optional

If True, open the HDF5 file in parallel mode, which is needed to allow several cores to write in the same file at the same time. If False, open the HDF5 file in standard mode.

track(beam, cavity)

Save data

track(beam, cavity)[source]

Save data

beam : Beam object cavity : CavityResonator object

class mbtrack2.tracking.monitors.monitors.Monitor[source]

Bases: Element

Abstract Monitor class used for subclass inheritance to define all the different kind of monitors objects.

The Monitor class is based on h5py module to be able to write data on structured binary files. The class provides a common file where the different Monitor subclass can write.

fileHDF5 file

Common file where all monitors, Monitor subclass elements, write the saved data. Based on class attribute _file_storage.

file_namestring

Name of the HDF5 file where the data is stored. Based on class attribute _file_name_storage.

monitor_init(group_name, save_every, buffer_size, total_size,

dict_buffer, dict_file, file_name=None, mpi_mode=True)

Method called to initialize Monitor subclass.

write()

Write data from buffer to the HDF5 file.

to_buffer(object_to_save)

Save data to buffer.

close()

Close the HDF5 file shared by all Monitor subclass, must be called by at least an instance of a Montior subclass at the end of the tracking.

track_bunch_data(object_to_save)

Track method to use when saving bunch data.

close()[source]

Close the HDF5 file shared by all Monitor subclass, must be called by at least an instance of a Montior subclass at the end of the tracking.

property file

Name of the HDF5 file where the data is stored.

property file_name

Common file where all monitors, Monitor subclass elements, write the saved data.

monitor_init(group_name, save_every, buffer_size, total_size, dict_buffer, dict_file, file_name=None, mpi_mode=False, dict_dtype=None)[source]

Method called to initialize Monitor subclass.

group_namestring

Name of the HDF5 group in which the data for the current monitor will be saved.

save_everyint or float

Set the frequency of the save. The data is saved every save_every call of the montior.

buffer_sizeint or float

Size of the save buffer.

total_sizeint or float

Total size of the save. The following relationships between the parameters must exist:

total_size % buffer_size == 0 number of call to track / save_every == total_size

dict_bufferdict

Dictionary with keys as the attribute name to save and values as the shape of the buffer to create to hold the attribute, like (key.shape, buffer_size)

dict_filedict

Dictionary with keys as the attribute name to save and values as the shape of the dataset to create to hold the attribute, like (key.shape, total_size)

file_namestring, optional

Name of the HDF5 where the data will be stored. Must be specified the first time a subclass of Monitor is instancied and must be None the following times.

mpi_modebool, optional

If True, open the HDF5 file in parallel mode, which is needed to allow several cores to write in the same file at the same time. If False, open the HDF5 file in standard mode.

dict_dtypedict, optional

Dictionary with keys as the attribute name to save and values as the dtype to use to save the values. If None, float is used for all attributes.

to_buffer(object_to_save)[source]

Save data to buffer.

object_to_savepython object

Depends on the Monitor subclass, typically a Beam or Bunch object.

track_bunch_data(object_to_save, check_empty=False)[source]

Track method to use when saving bunch data.

object_to_save : Beam or Bunch check_emptiness: bool

If True, check if the bunch is empty. If it is, then do nothing.

write()[source]

Write data from buffer to the HDF5 file.

class mbtrack2.tracking.monitors.monitors.PhaseSpaceMonitor(bunch_number, mp_number, save_every, buffer_size, total_size, file_name=None, mpi_mode=False)[source]

Bases: Monitor

Monitor a single bunch and save the full phase space.

bunch_numberint

Bunch to monitor

mp_numberint or float

Number of macroparticle in the phase space to save. If less than the total number of macroparticles, a random fraction of the bunch is saved.

save_everyint or float

Set the frequency of the save. The data is saved every save_every call of the montior.

buffer_sizeint or float

Size of the save buffer.

total_sizeint or float

Total size of the save. The following relationships between the parameters must exist:

total_size % buffer_size == 0 number of call to track / save_every == total_size

file_namestring, optional

Name of the HDF5 where the data will be stored. Must be specified the first time a subclass of Monitor is instancied and must be None the following times.

mpi_modebool, optional

If True, open the HDF5 file in parallel mode, which is needed to allow several cores to write in the same file at the same time. If False, open the HDF5 file in standard mode.

track(object_to_save)

Save data

to_buffer(bunch)[source]

Save data to buffer.

bunch : Bunch object

track(object_to_save)[source]

Save data

object_to_save : Bunch or Beam object

class mbtrack2.tracking.monitors.monitors.ProfileMonitor(bunch_number, save_every, buffer_size, total_size, dimensions='tau', n_bin=75, file_name=None, mpi_mode=False)[source]

Bases: Monitor

Monitor a single bunch and save bunch profiles.

bunch_numberint

Bunch to monitor.

save_everyint or float

Set the frequency of the save. The data is saved every save_every call of the montior.

buffer_sizeint or float

Size of the save buffer.

total_sizeint or float

Total size of the save. The following relationships between the parameters must exist:

total_size % buffer_size == 0 number of call to track / save_every == total_size

dimensionsstr or list of str, optional

Dimensions to save.

n_binint or list of int, optional

Number of bin to use in each dimension.

file_namestring, optional

Name of the HDF5 where the data will be stored. Must be specified the first time a subclass of Monitor is instancied and must be None the following times.

mpi_modebool, optional

If True, open the HDF5 file in parallel mode, which is needed to allow several cores to write in the same file at the same time. If False, open the HDF5 file in standard mode.

track(object_to_save)

Save data.

to_buffer(bunch)[source]

Save data to buffer.

bunch : Bunch object

track(object_to_save)[source]

Save data.

object_to_save : Bunch or Beam object

write()[source]

Write data from buffer to the HDF5 file.

class mbtrack2.tracking.monitors.monitors.WakePotentialMonitor(bunch_number, wake_types, n_bin, save_every, buffer_size, total_size, file_name=None, mpi_mode=False)[source]

Bases: Monitor

Monitor the wake potential from a single bunch and save attributes (tau, …).

bunch_numberint

Bunch to monitor.

wake_typesstr or list of str

Wake types to save: “Wlong, “Wxdip”, …

n_binint

Number of bin to be used to interpolate the wake potential on a fixed grid.

save_everyint or float

Set the frequency of the save. The data is saved every save_every call of the montior.

buffer_sizeint or float

Size of the save buffer.

total_sizeint or float

Total size of the save. The following relationships between the parameters must exist:

total_size % buffer_size == 0 number of call to track / save_every == total_size

file_namestring, optional

Name of the HDF5 where the data will be stored. Must be specified the first time a subclass of Monitor is instancied and must be None the following times.

mpi_modebool, optional

If True, open the HDF5 file in parallel mode, which is needed to allow several cores to write in the same file at the same time. If False, open the HDF5 file in standard mode.

track(object_to_save, wake_potential_to_save)

Save data.

to_buffer(wp)[source]

Save data to buffer.

wp : WakePotential object

track(object_to_save, wake_potential_to_save)[source]

Save data.

object_to_save : Bunch or Beam object wake_potential_to_save : WakePotential object

write()[source]

Write data from buffer to the HDF5 file.

mbtrack2.tracking.monitors.plotting module

Module for plotting the data recorded by the monitor module during the tracking.

mbtrack2.tracking.monitors.plotting.plot_beamdata(filenames, dataset='mean', dimension='tau', stat_var='mean', x_var='time', turn=None, legend=None)[source]

Plot 2D data recorded by BeamMonitor.

filenamesstr or list of str

Names of the HDF5 files to be plotted.

dataset{“current”,”emit”,”mean”,”std”,”cs_invariant”}

HDF5 file’s dataset to be plotted. The default is “mean”.

dimensionstr
The dimension of the dataset to plot:

for “emit”, dimension = {“x”,”y”,”s”}, for “cs_invariant”, dimension = {“x”,”y”,”s”}, for “mean” and “std”, dimension = {“x”,”xp”,”y”,”yp”,”tau”,”delta”}. not used if “current”.

The default is “tau”.

stat_var{“mean”, “std”}

Statistical value of the dimension.

x_var{“time”, “index”}
Choice of the horizontal axis:

“time” corresponds to turn number. “index” corresponds to bunch index.

turnint or float, optional

Choice of the turn to plot when x_var = “index”. If None, the last turn is plotted.

legendlist of str, optional

Legend to add for each file.

figFigure

Figure object with the plot on it.

mbtrack2.tracking.monitors.plotting.plot_beamspectrum(filenames, dim='tau', turns=None, f0=None, log_scale=True, legend=None, norm=False)[source]

Plot coherent beam spectrum data.

filenamesstr or list of str

Names of the HDF5 files to be plotted.

dim{“x”,”y”,”tau”}, optional

The dimension of the dataset to plot. The default is “tau”.

turnsarray or None, optional

Numbers of the turns to plot. If None, all turns are shown. The default is None.

f0float or None, optional

If not None, the frequency axis is noramlised by f0. The default is None.

log_scalebool, optional

If True, the spectrum plots are shown in y-log scale. The default is True.

legendlist of str, optional

Legend to add for each file. The default is None.

normbool, optional

If True, normalise the data of each spectrum by its geometric mean. The default is False.

fig : Figure

mbtrack2.tracking.monitors.plotting.plot_bunchdata(filenames, bunch_number, dataset, dimension='x', legend=None)[source]

Plot data recorded by BunchMonitor.

filenamesstr or list of str

Names of the HDF5 files to be plotted.

bunch_numberint or list of int

Bunch to plot. This has to be identical to ‘bunch_number’ parameter in ‘BunchMonitor’ object.

dataset{“current”, “emit”, “mean”, “std”, “cs_invariant”}

HDF5 file’s dataset to be plotted.

dimensionstr, optional

The dimension of the dataset to plot. Use “None” for “current”, otherwise use the following :

for “emit”, dimension = {“x”,”y”,”s”}, for “cs_invariant”, dimension = {“x”,”y”,”s”}, for “mean” and “std”, dimension = {“x”,”xp”,”y”,”yp”,”tau”,”delta”}, for “action”, dimension = {“x”,”y”}.

legendlist of str, optional

Legend to add for each file.

figFigure

Figure object with the plot on it.

mbtrack2.tracking.monitors.plotting.plot_bunchspectrum(filenames, bunch_number, dataset='incoherent', dim='tau', turns=None, fs=None, log_scale=True, legend=None, norm=False)[source]

Plot coherent and incoherent spectrum data.

filenamesstr or list of str

Names of the HDF5 files to be plotted.

bunch_numberint or list of int

Bunch to plot. This has to be identical to ‘bunch_number’ parameter in ‘BunchSpectrumMonitor’ object.

dataset{“mean_incoherent”, “coherent”, “incoherent”}

HDF5 file’s dataset to be plotted. The default is “incoherent”.

dim{“x”,”y”,”tau”}, optional

The dimension of the dataset to plot. The default is “tau”.

turnsarray or None, optional

Numbers of the turns to plot. If None, all turns are shown. The default is None.

fsfloat or None, optional

If not None, the frequency axis is noramlised by fs. The default is None.

log_scalebool, optional

If True, the spectrum plots are shown in y-log scale. The default is True.

legendlist of str, optional

Legend to add for each file. The default is None.

normbool, optional

If True, normalise the data of each spectrum by its geometric mean. The default is False.

fig : Figure

mbtrack2.tracking.monitors.plotting.plot_cavitydata(filename, cavity_name, phasor='cavity', plot_type='bunch', bunch_number=0, turn=None, cm_lim=None, show_objective=False)[source]

Plot data recorded by CavityMonitor.

filenamestr

Name of the HDF5 file that contains the data.

cavity_namestr

Name of the CavityResonator object.

phasorstr, optional

Type of the phasor to plot. Can be “beam”, “cavity”, “generator” or “ig”.

plot_typestr, optional
Type of plot:
  • “bunch” plots the phasor voltage and angle versus time for a

given bunch. - “turn” plots the phasor voltage and ange versus bunch index for a given turn. - “streak_amplitude” plots the phasor amplitude versus bunch index and time. - “streak_angle” plots the phasor angle versus bunch index and time. - “detune” or “psi” plots the detuning or tuning angle versus time. - “power” plots the generator, cavity, beam and reflected power versus time. Needs BeamMonitor data with same save_every as CavityMonitor. - “mean” plots the mean phasor voltage and angle versus time for non empty bunches. Needs BeamMonitor data with same save_every as CavityMonitor. - “tuner_diff” plots the tuner difference from optimal tuning condition (for a given bunch) and the tuning angle versus time.

bunch_numberint, optional

Bunch number to select. The default is 0.

turnint, optional

Turn to plot. The default is None.

cm_limlist [vmin, vmax], optional

Colormap scale for the “streak” plots.

show_objectivebool, optional

If True, shows the Cavity voltage and phase objective value (Vc and theta) in plot type “mean” and “bunch” for “cavity” phasor. Default is False.

figFigure

Figure object with the plot on it.

mbtrack2.tracking.monitors.plotting.plot_phasespacedata(filename, bunch_number, x_var, y_var, turn, only_alive=True, plot_size=1, plot_kind='kde')[source]

Plot data recorded by PhaseSpaceMonitor.

filenamestr

Name of the HDF5 file that contains the data.

bunch_numberint

Bunch to plot. This has to be identical to ‘bunch_number’ parameter in ‘PhaseSpaceMonitor’ object.

x_var, y_varstr {“x”, “xp”, “y”, “yp”, “tau”, “delta”}

If dataset is “particles”, the variables to be plotted on the horizontal and the vertical axes need to be specified.

turnint

Turn at which the data will be extracted.

only_alivebool, optional

When only_alive is True, only alive particles are plotted and dead particles will be discarded.

plot_size[0,1], optional

Number of macro-particles to plot relative to the total number of macro-particles recorded. This option helps reduce processing time when the data is big.

plot_kind{‘scatter’, ‘kde’, ‘hex’, ‘reg’, ‘resid’}, optional

The plot style. The default is ‘kde’.

figFigure

Figure object with the plot on it.

mbtrack2.tracking.monitors.plotting.plot_profiledata(filename, bunch_number, dimension='tau', start=0, stop=None, step=None, profile_plot=True, streak_plot=True)[source]

Plot data recorded by ProfileMonitor

filenamestr

Name of the HDF5 file that contains the data.

bunch_numberint

Bunch to plot. This has to be identical to ‘bunch_number’ parameter in ‘ProfileMonitor’ object.

dimensionstr, optional

Dimension to plot. The default is “tau”

startint, optional

First turn to plot. The default is 0.

stopint, optional

Last turn to plot. If None, the last turn of the record is selected.

stepint, optional

Plotting step. This has to be divisible by ‘save_every’ parameter in ‘ProfileMonitor’ object, i.e. step % save_every == 0. If None, step is equivalent to save_every.

profile_plotbool, optional

If Ture, bunch profile plot is plotted.

streak_plotbool, optional

If True, strek plot is plotted.

figFigure

Figure object with the plot on it.

mbtrack2.tracking.monitors.plotting.plot_wakedata(filename, bunch_number, wake_type='Wlong', start=0, stop=None, step=None, profile_plot=False, streak_plot=True, bunch_profile=False, dipole=False)[source]

Plot data recorded by WakePotentialMonitor

filenamestr

Name of the HDF5 file that contains the data.

bunch_numberint

Bunch to plot. This has to be identical to ‘bunch_number’ parameter in ‘WakePotentialMonitor’ object.

wake_typestr, optional

Wake type to plot: “Wlong”, “Wxdip”, …

startint, optional

First turn to plot. The default is 0.

stopint, optional

Last turn to plot. If None, the last turn of the record is selected.

stepint, optional

Plotting step. This has to be divisible by ‘save_every’ parameter in ‘WakePotentialMonitor’ object, i.e. step % save_every == 0. If None, step is equivalent to save_every.

profile_plotbool, optional

If Ture, wake potential profile plot is plotted.

streak_plotbool, optional

If True, strek plot is plotted.

bunch_profilebool, optional.

If True, the bunch profile is plotted.

dipolebool, optional

If True, the dipole moment is plotted.

figFigure

Figure object with the plot on it.

mbtrack2.tracking.monitors.plotting.streak_beamdata(filename, dataset='mean', dimension='tau', cm_lim=None)[source]

Plot 3D data recorded by BeamMonitor.

filenamestr

Name of the HDF5 file that contains the data.

dataset{“current”,”emit”,”mean”,”std”,”cs_invariant”}

HDF5 file’s dataset to be plotted. The default is “mean”.

dimensionstr
The dimension of the dataset to plot:

for “emit”, dimension = {“x”,”y”,”s”}, for “cs_invariant”, dimension = {“x”,”y”,”s”}, for “mean” and “std”, dimension = {“x”,”xp”,”y”,”yp”,”tau”,”delta”}. not used if “current”.

The default is “tau”.

cm_limlist [vmin, vmax], optional

Colormap scale for the “streak” plot.

figFigure

Figure object with the plot on it.

mbtrack2.tracking.monitors.plotting.streak_beamspectrum(filename, dim='tau', f0=None, log_scale=True, fmin=None, fmax=None, turns=None, norm=False, ylim=None)[source]

Plot 3D data recorded by the BeamSpectrumMonitor.

filenamesstr

Name of the HDF5 file to be plotted.

dim{“x”,”y”,”tau”}, optional

The dimension of the dataset to plot. The default is “tau”.

f0float or None, optional

If not None, the frequency axis is noramlised by f0.

log_scalebool, optional

If True, the spectrum plots are shown in y-log scale. The default is True.

fminfloat, optional

If not None, the plot is limitted to values bigger than fmin.

fmaxfloat, optional

If not None, the plot is limitted to values smaller than fmax.

turnsarray, optional

If not None, only the turn numbers in the turns array are plotted.

normbool, optional

If True, normalise the data of each spectrum by its geometric mean. The default is False.

ylimarray, optional

If not None, should be array like in the form [ymin, ymax] where ymin and ymax are the minimum and maxmimum values used in the y axis.

fig : Figure

mbtrack2.tracking.monitors.plotting.streak_bunchspectrum(filename, bunch_number, dataset='incoherent', dim='tau', fs=None, log_scale=True, fmin=None, fmax=None, turns=None, norm=False, ylim=None)[source]

Plot 3D data recorded by the BunchSpectrumMonitor.

filenamesstr

Name of the HDF5 file to be plotted.

bunch_numberint

Bunch to plot. This has to be identical to ‘bunch_number’ parameter in ‘BunchSpectrumMonitor’ object.

dataset{“coherent”, “incoherent”}

HDF5 file’s dataset to be plotted. The default is “incoherent”.

dim{“x”,”y”,”tau”}, optional

The dimension of the dataset to plot. The default is “tau”.

fsfloat or None, optional

If not None, the frequency axis is noramlised by fs.

log_scalebool, optional

If True, the spectrum plots are shown in y-log scale. The default is True.

fminfloat, optional

If not None, the plot is limitted to values bigger than fmin.

fmaxfloat, optional

If not None, the plot is limitted to values smaller than fmax.

turnsarray, optional

If not None, only the turn numbers in the turns array are plotted.

normbool, optional

If True, normalise the data of each spectrum by its geometric mean. The default is False.

ylimarray, optional

If not None, should be array like in the form [ymin, ymax] where ymin and ymax are the minimum and maxmimum values used in the y axis.

fig : Figure

mbtrack2.tracking.monitors.tools module

This module defines utilities functions, helping to deals with tracking output and hdf5 files.

mbtrack2.tracking.monitors.tools.copy_files(source, copy, version=None)[source]

Copy a source hdf5 file into another hdf5 file using a different HDF5 version.

The function assumes that the source file has only a single group layer.

sourcestr

Name of the source file.

copystr

Name of the copy file.

versionstr, optional

Version number of the copy file.

mbtrack2.tracking.monitors.tools.merge_files(files_prefix, files_number, start_idx=0, file_name=None)[source]

Merge several hdf5 files into one.

The function assumes that the files to merge have names in the follwing format:

  • “files_prefix_0.hdf5”

  • “files_prefix_1.hdf5”

… - “files_prefix_files_number.hdf5”

files_prefixstr

Name of the files to merge.

files_numberint

Number of files to merge.

start_idxint, optional

Start index of the hdf5 files.

file_namestr, optional

Name of the file with the merged data. If None, files_prefix without number is used.

Module contents