simba.Modules.Beams package
Subpackages
- simba.Modules.Beams.Particles package
- Submodules
- simba.Modules.Beams.Particles.centroids module
centroidscentroids.CEncentroids.Ccpcentroids.Cgammacentroids.Cpcentroids.Cpxcentroids.Cpycentroids.Cpzcentroids.Ctcentroids.Cxcentroids.Cxpcentroids.Cycentroids.Cypcentroids.Czcentroids.mean_cpcentroids.mean_cpxcentroids.mean_cpycentroids.mean_cpzcentroids.mean_energycentroids.mean_gammacentroids.mean_pxcentroids.mean_pycentroids.mean_pzcentroids.mean_tcentroids.mean_xcentroids.mean_ycentroids.mean_z
- simba.Modules.Beams.Particles.emittance module
emittanceemittance.ecnxemittance.ecnyemittance.ecxemittance.ecyemittance.emittance()emittance.emittance_calc()emittance.enxemittance.enyemittance.exemittance.eyemittance.horizontal_emittanceemittance.horizontal_emittance_90emittance.horizontal_emittance_correctedemittance.normalised_horizontal_emittance_correctedemittance.normalised_vertical_emittance_correctedemittance.normalized_emittance()emittance.normalized_horizontal_emittanceemittance.normalized_horizontal_emittance_90emittance.normalized_vertical_emittanceemittance.normalized_vertical_emittance_90emittance.vertical_emittanceemittance.vertical_emittance_90emittance.vertical_emittance_corrected
- simba.Modules.Beams.Particles.kde module
- simba.Modules.Beams.Particles.minimumVolumeEllipse module
- simba.Modules.Beams.Particles.mve module
MVEMVE.CDF()MVE.FWHM()MVE.PDF()MVE.PDFI()MVE.densityMVE.horizontal_mve_emittanceMVE.kde_bw_func()MVE.kde_function()MVE.mve_emittance()MVE.mvesliceAnalysis()MVE.normalized_mve_horizontal_emittanceMVE.normalized_mve_vertical_emittanceMVE.slice_6D_VolumeMVE.slice_densityMVE.slice_normalized_mve_horizontal_emittanceMVE.slice_normalized_mve_vertical_emittanceMVE.vertical_mve_emittanceMVE.volumeMVE.volume6D()
- simba.Modules.Beams.Particles.sigmas module
- simba.Modules.Beams.Particles.slice module
sliceslice.alpha_xslice.alpha_yslice.beta_xslice.beta_yslice.bin_momentum()slice.bin_time()slice.chirpslice.chirp_m1slice.emitbins()slice.enxslice.enyslice.exslice.eyslice.gamma_xslice.gamma_yslice.get_chirp_coeffs()slice.have_we_already_been_binned()slice.peak_currentslice.set_slices()slice.sliceAnalysis()slice.slice_alpha_xslice.slice_alpha_yslice.slice_beta_xslice.slice_beta_yslice.slice_binsslice.slice_cpbinsslice.slice_currentslice.slice_data()slice.slice_enxslice.slice_enyslice.slice_exslice.slice_eyslice.slice_gamma_xslice.slice_gamma_yslice.slice_horizontal_emittanceslice.slice_length()slice.slice_max_peak_current_sliceslice.slice_momentumslice.slice_momentum_spreadslice.slice_normalized_horizontal_emittanceslice.slice_normalized_vertical_emittanceslice.slice_relative_momentum_spreadslice.slice_tslice.slice_vertical_emittanceslice.slice_zslice.slices()slice.time_binnedslice.update_binned_parameters()
- simba.Modules.Beams.Particles.twiss module
twisstwiss.alpha_xtwiss.alpha_x_correctedtwiss.alpha_ytwiss.alpha_y_correctedtwiss.beta_xtwiss.beta_x_correctedtwiss.beta_ytwiss.beta_y_correctedtwiss.calculate_etax()twiss.calculate_etay()twiss.correctedtwiss.eta_xtwiss.eta_xptwiss.eta_ytwiss.eta_yptwiss.gamma_xtwiss.gamma_x_correctedtwiss.gamma_ytwiss.gamma_y_correctedtwiss.horizontal_emittancetwiss.horizontal_emittance_correctedtwiss.normaltwiss.normalized_horizontal_emittancetwiss.normalized_vertical_emittancetwiss.twiss_analysistwiss.twiss_analysis_correctedtwiss.vertical_emittancetwiss.vertical_emittance_corrected
- Module contents
ParticlesParticles.BetaGammaParticles.BrhoParticles.BxParticles.ByParticles.BzParticles.E0_eVParticles.ExParticles.EyParticles.EzParticles.QParticles.apply_mask()Particles.centroidsParticles.chargeParticles.charge_sign_indexParticles.chargesignParticles.clockParticles.computeCorrelations()Particles.covariance()Particles.cpParticles.cpxParticles.cpyParticles.cpzParticles.deltapParticles.emittanceParticles.energyParticles.eta_corrected()Particles.eta_correlation()Particles.fullbeamParticles.gammaParticles.get_particle_index()Particles.kdeParticles.kinetic_energyParticles.massParticles.mass_indexParticles.mean_energyParticles.mveParticles.nmacroParticles.offsetParticles.pParticles.particle_chargeParticles.particle_indexParticles.particle_massParticles.particle_rest_energyParticles.particle_rest_energy_eVParticles.performTransformation()Particles.performTransformationPeakISlice()Particles.pxParticles.pyParticles.pzParticles.q_over_cParticles.rematchXPlane()Particles.rematchXPlanePeakISlice()Particles.rematchYPlane()Particles.rematchYPlanePeakISlice()Particles.sParticles.set_total_charge()Particles.sigmasParticles.sign()Particles.sliceParticles.species_nameParticles.speed_of_lightParticles.statusParticles.tParticles.thetaParticles.toffsetParticles.total_chargeParticles.twissParticles.xParticles.xcParticles.xpParticles.xpcParticles.yParticles.ycParticles.ypParticles.ypcParticles.z
Submodules
simba.Modules.Beams.astra module
simba.Modules.Beams.cheetah module
simba.Modules.Beams.gdf module
simba.Modules.Beams.hdf5 module
simba.Modules.Beams.mad8 module
- read_tfs(tfs_file_path, index=None)[source]
Parses the TFS table present in tfs_file_path and returns a dictionary. :type tfs_file_path:
str:param tfs_file_path: Path object to the output TFS file. :type tfs_file_path: str :type index:Optional[str] :param index: Name of the column to set as index. If not given, looks in tfs_file_pathfor a column starting with INDEX&&&.
- Returns:
Dictionary object.
simba.Modules.Beams.ocelot module
- particle_group_to_parray(self, s_start=0)[source]
Construct an Ocelot ParticleArray from an openPMD-beamphysics ParticleGroup. The particle type is assumed to be electrons.
- Parameters:
pgroup – ParticleGroup from which to construct the ParticleArray
- Returns:
ParticleArray corresponding to the provided ParticleGroup
- Return type:
ParticleArray
simba.Modules.Beams.opal module
simba.Modules.Beams.openpmd module
simba.Modules.Beams.plot module
- density_plot(particle_group, key='x', bins=None, filename=None, **kwargs)[source]
1D density plot. Also see: marginal_plot
Example
density_plot(P, ‘x’, bins=100)
- getScreenImage(beam, keys=['x', 'y'], scale=[1, 1], iscale=1, colormap=<matplotlib.colors.LinearSegmentedColormap object>, size=None, use_scipy=False, subtract_mean=[False, False], **kwargs)[source]
- marginal_plot(particle_group, key1='t', key2='p', bins=None, units=['', ''], scale=[1, 1], subtract_mean=[False, False], cmap=None, limits=None, filename=None, **kwargs)[source]
Density plot and projections
Example
marginal_plot(P, ‘t’, ‘energy’, bins=200)
- plotScreenImage(beam, keys=['x', 'y'], scale=[1, 1], iscale=1, colormap=<matplotlib.colors.LinearSegmentedColormap object>, size=None, grid=False, marginals=False, limits=None, screen=False, use_scipy=False, subtract_mean=[False, False], title='', filename=None, fig=None, ax=None, labelsize=None, **kwargs)[source]
simba.Modules.Beams.sdds module
simba.Modules.Beams.vsim module
simba.Modules.Beams.wake_t module
simba.Modules.Beams.xsuite module
Module contents
SIMBA Beams Module
This module defines the base class and utilities for representing particle beams and groups of beams.
Each beam consists of particles (see Particles),
represented in 6-dimensional phase space (x, cpx, y, cpy, z, cpz).
Functions are provided to read/write the particle distribution from a range of simulation codes.
The beamGroup class is used for loading and analysing a group of beam distributions, for example from a directory.
- Classes:
beam: Generic container for a particle beam.beamGroup: Container for a group of particle beams.particlesGroup: Container for a group of particle distributions.
- class beam(*args: Any, **kwargs: Any)[source]
Bases:
BaseModelClass describing a particle distribution. The distribution is contained in the beam or Particles property of this class (see
Particles).Additional results from analysis of the beam are contained in the following properties:
sigmas– average beam properties,
see
sigmas.centroids– beam centroids,
see
centroids.centroids– various emittance calculations,
see
emittance.kde– kernel density estimator,
see
kde.mve– minimum volume ellipse,
see
MVE.slices– calculations of slice properties,
see
slice.twiss– Twiss parameters,
see
twiss.Functions are also provided for translating the particle distribution from and to HDF5 format (in-house developed or OpenPMD), ASTRA, GPT, OCELOT, or SDDS.
- property E0_eV: float
Particle rest mass energy in eV
- Returns:
Particle rest mass energy in eV; if already defined, just return the attribute; if not, calculate from the
Particlesobject; if not possible, assume electrons and calculate its rest mass energy- Return type:
float
- property Particles: Particles
Property defining the particle distribution
- Returns:
The particle distribution
- Return type:
- property beam: Particles
Property defining the particle distribution
- Returns:
The particle distribution
- Return type:
-
beam_energy:
float|None= None Beam energy [required for Cheetah]
- property centroids: centroids
Property defining the beam centroids
- Returns:
Beam centroids
- Return type:
-
code:
str|None= None Code from which the beam distribution was generated
- property data: <property object at 0x77336bd4e340>
Property defining the particle distribution
- Returns:
The particle distribution
- Return type:
- property emittance: emittance
Property defining the beam emittances
- Returns:
Beam emittance
- Return type:
-
filename:
str|None= None Name of beam distribution file; if provided on instantiation, load the file into this object
- property fullbeam
-
longitudinal_reference:
ndarray|str|None= None Longitudinal reference position for ASTRA-type distributions
- property mve: Any
Property defining the beam minimum volume ellipse
- Returns:
Beam sigmas
- Return type:
- normalise_to_ref_particle(array, index=0, subtractmean=False)[source]
Normalise a distribution to the first element in the array (i.e. the ASTRA reference particle)
- Parameters:
array (np.ndarray) – The array to normalise
index (int) – Not in use
subtractmean (bool) – If true, subtract the reference particle from the array
- Returns:
The normalised array
- Return type:
np.ndarray
-
offset:
list|ndarray= [0, 0, 0] Beam offset from nominal axis [x,y,z]
-
particle_mass:
ndarray|None= None Particle mass in kg
- read_HDF5_beam_file(*args, **kwargs)[source]
Load in an HDF5-type beam distribution file and update the
Particlesobject.
- read_SDDS_beam_file(*args, **kwargs)[source]
Load in an SDDS-type beam distribution file and update the
Particlesobject.
- read_astra_beam_file(*args, **kwargs)[source]
Load in an ASTRA-type beam distribution file and update the
Particlesobject.
- read_beam_file(filename, run_extension='001', beam_energy=None, step=0)[source]
Load in a beam distribution file and update the
Particlesobject.Based on the extension in filename, the appropriate function will be called.
- Parameters:
filename (str) – The name of the file to be loaded
run_extension (str) – Run extension for ASTRA-type beam distribution files.
beam_energy (float, optional) – Beam energy in eV (for Cheetah beam distributions)
step (int, optional) – Step number in output file (for OPAL beam distributions)
- read_gdf_beam_file(*args, **kwargs)[source]
Load in a GDF-type beam distribution file and update the
Particlesobject.
- read_ocelot_beam_file(*args, **kwargs)[source]
Load in an OCELOT-type beam distribution file and update the
Particlesobject.
- read_opal_beam_file(*args, **kwargs)[source]
Load in an OPAL-type beam distribution file and update the
Particlesobject.
- read_xsuite_beam_file(*args, **kwargs)[source]
Load in an Xsuite-type beam distribution file and update the
Particlesobject.
-
reference_particle:
ndarray|None= None Reference particle for ASTRA-type distributions
-
reference_particle_coords:
list= ['x', 'y', 'z', 'cpx', 'cpy', 'cpz', 't', 'charge', 'status']
-
reference_particle_index:
int|None= None Reference particle index for ASTRA-type distributions
- resample(npart, **kwargs)[source]
Resample the beam using a kernel density estimator, updating the number of particles. See
kde.- Parameters:
npart (int) – Number of particles for the new distribution
- Returns:
The resampled beam.
- Return type:
- reset_dicts()[source]
Clear out the
Particlesobject, removing the distribution from this object.- Return type:
None
- rms(x, axis=None)[source]
Calculate the RMS of a distribution
- Parameters:
x (np.ndarray) – Array from which to calculate the RMS
axis (int, optional) – Axis along which to calculate the RMS
- Returns:
RMS of the distribution
- Return type:
float or np.ndarray
-
sddsindex:
int= 0 Index for SDDS files
- set_particle_mass(mass=9.1093837015e-31)[source]
Set the mass of all particles in the distribution by updating
particle_mass.- Parameters:
mass (float) – Particle mass in kg
- Return type:
None
- property slice: slice
Property defining the beam slice properties
- Returns:
Beam slice properties
- Return type:
-
species:
str= 'electron'
-
starting_position:
list|ndarray= [0, 0, 0] Beam starting position [x,y,z]
- property status
-
theta:
float= 0 Horizontal angle of beam distribution
- class beamGroup(*args: Any, **kwargs: Any)[source]
Bases:
BaseModelClass for grouping together multiple particle distributions. These distributions can be loaded in from a directory, for example, using the function
load_directory().Properties such as the
emittanceobjects for these distributions are stored as properties of the beamGroup.(see
particlesGroup).- property centroids
- property data
- property emittance
- property kde
- property mve
-
sddsindex:
int= 0 Index for SDDS files
- property sigmas
- property slice
- property twiss
- load_directory(directory='.', types={'SIMBA': '.hdf5'}, verbose=False)[source]
Load in all beam distribution files from a directory and create a
beamGroupobject.- Parameters:
directory (str) – Directory from which to load the files
types (Dict) – Beam distribution file types to load
verbose (bool) – If true, print progress
- Returns:
A new beamGroup.
- Return type:
- load_file(filename, *args, **kwargs)[source]
Load in a beam distribution files and create a
beamobject.- Parameters:
filename (str) – Name of file to load
- Returns:
A new beam.
- Return type:
- class particlesGroup(*args, **kwargs)[source]
Bases:
BaseModelClass for grouping together properties of multiple particle distributions, such as the
emittanceobjects.- Parameters:
args (
Any)kwargs (
Any)