simba.Modules package
Subpackages
- simba.Modules.Beams package
- Subpackages
- simba.Modules.Beams.Particles package
- Submodules
- simba.Modules.Beams.Particles.centroids module
- simba.Modules.Beams.Particles.emittance module
- simba.Modules.Beams.Particles.kde module
- simba.Modules.Beams.Particles.minimumVolumeEllipse module
- simba.Modules.Beams.Particles.mve module
- simba.Modules.Beams.Particles.sigmas module
- simba.Modules.Beams.Particles.slice module
- simba.Modules.Beams.Particles.twiss module
- Module contents
- simba.Modules.Beams.Particles package
- 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
- simba.Modules.Beams.ocelot module
- simba.Modules.Beams.opal module
- simba.Modules.Beams.openpmd module
- simba.Modules.Beams.plot module
- simba.Modules.Beams.sdds module
- simba.Modules.Beams.vsim module
- simba.Modules.Beams.wake_t module
- simba.Modules.Beams.xsuite module
- Module contents
beambeam.E0_eVbeam.Particlesbeam.beambeam.beam_energybeam.centroidsbeam.codebeam.databeam.emittancebeam.filenamebeam.fullbeambeam.kdebeam.longitudinal_referencebeam.mvebeam.normalise_to_ref_particle()beam.offsetbeam.particle_massbeam.plot()beam.plotScreenImage()beam.q_over_cbeam.read_HDF5_beam_file()beam.read_SDDS_beam_file()beam.read_astra_beam_file()beam.read_beam_file()beam.read_cheetah_beam_file()beam.read_gdf_beam_file()beam.read_ocelot_beam_file()beam.read_opal_beam_file()beam.read_xsuite_beam_file()beam.reference_particlebeam.reference_particle_coordsbeam.reference_particle_indexbeam.resample()beam.reset_dicts()beam.rms()beam.rotate_beamXZ()beam.sddsindexbeam.set_particle_mass()beam.set_species()beam.sigmasbeam.slicebeam.slice_plot()beam.speciesbeam.speed_of_lightbeam.starting_positionbeam.statusbeam.thetabeam.twissbeam.unrotate_beamXZ()beam.write_HDF5_beam_file()beam.write_SDDS_beam_file()beam.write_astra_beam_file()beam.write_cheetah_beam_file()beam.write_gdf_beam_file()beam.write_mad8_beam_file()beam.write_ocelot_beam_file()beam.write_opal_beam_file()beam.write_openpmd_beam_file()beam.write_xsuite_beam_file()
beamGroupget_properties()load_HDF5_summary_file()load_directory()load_file()particlesGroupsave_HDF5_summary_file()statsstatsGroup
- Subpackages
- simba.Modules.Fields package
- Submodules
- simba.Modules.Fields.FieldParameter module
- simba.Modules.Fields.astra module
- simba.Modules.Fields.gdf module
- simba.Modules.Fields.hdf5 module
- simba.Modules.Fields.opal module
- simba.Modules.Fields.sdds module
- Module contents
fieldfield.Brfield.Bxfield.Byfield.Bzfield.Erfield.Exfield.Eyfield.Ezfield.Gfield.Wrfield.Wxfield.Wyfield.Wzfield.cavity_typefield.end_cell_zfield.field_typefield.filenamefield.fourierfield.frequencyfield.get_field_data()field.lengthfield.mode_denominatorfield.mode_numeratorfield.n_cellsfield.normfield.orientationfield.origin_codefield.rfield.radiusfield.readfield.read_field_file()field.reset_dicts()field.start_cell_zfield.tfield.t_valuesfield.validate_fields()field.write_field_file()field.xfield.yfield.zfield.z_values
- simba.Modules.Matrices package
- simba.Modules.Twiss package
- Submodules
- simba.Modules.Twiss.astra module
- simba.Modules.Twiss.cheetah module
- simba.Modules.Twiss.elegant module
- simba.Modules.Twiss.gpt module
- simba.Modules.Twiss.hdf5 module
- simba.Modules.Twiss.ocelot module
- simba.Modules.Twiss.opal module
- simba.Modules.Twiss.plot module
- simba.Modules.Twiss.xsuite module
- Module contents
initialTwissload_directory()load_file()twisstwiss.E0twiss.E0_eVtwiss.alpha_xtwiss.alpha_x_beamtwiss.alpha_ytwiss.alpha_y_beamtwiss.alpha_ztwiss.append()twiss.beta_xtwiss.beta_x_beamtwiss.beta_ytwiss.beta_y_beamtwiss.beta_ztwiss.code_signaturestwiss.codestwiss.covariance()twiss.cptwiss.ecnxtwiss.ecnytwiss.elegantDatatwiss.elegantTwisstwiss.element_nametwiss.enxtwiss.enytwiss.enztwiss.eta_xtwiss.eta_x_beamtwiss.eta_xptwiss.eta_xp_beamtwiss.eta_ytwiss.eta_y_beamtwiss.eta_yptwiss.eta_yp_beamtwiss.extwiss.extract_values()twiss.eytwiss.eztwiss.find_nearest()twiss.find_nearest_idx()twiss.gammatwiss.gamma_xtwiss.gamma_ytwiss.gamma_ztwiss.get_parameter_at_element()twiss.get_parameter_at_z()twiss.get_twiss_at_element()twiss.get_twiss_at_z()twiss.get_twiss_dict()twiss.initialise_directory()twiss.interpolate()twiss.kinetic_energytwiss.lattice_nametwiss.load_directory()twiss.mean_cptwiss.mean_xtwiss.mean_ytwiss.muxtwiss.muytwiss.ptwiss.plot()twiss.propertiestwiss.q_over_ctwiss.read_GPT_twiss_files()twiss.read_HDF5_twiss_file()twiss.read_astra_twiss_files()twiss.read_cheetah_twiss_files()twiss.read_elegant_twiss_files()twiss.read_gdf_twiss_files()twiss.read_genesis_twiss_files()twiss.read_ocelot_twiss_files()twiss.read_ocelot_twiss_files_hdf()twiss.read_opal_twiss_files()twiss.read_sdds_file()twiss.read_xsuite_twiss_files()twiss.reset_dicts()twiss.rest_masstwiss.stwiss.save_HDF5_twiss_file()twiss.sddsindextwiss.set_E0()twiss.sigma_cptwiss.sigma_ptwiss.sigma_ttwiss.sigma_xtwiss.sigma_xptwiss.sigma_ytwiss.sigma_yptwiss.sigma_ztwiss.sort()twiss.stat()twiss.ttwiss.validate_fields()twiss.z
twissParameter
- simba.Modules.optimisation package
- simba.Modules.plotting package
- Submodules
- simba.Modules.plotting.latticeDraw module
- simba.Modules.plotting.multiAxisPlot module
- simba.Modules.plotting.multiPlot module
- simba.Modules.plotting.plotting module
ASTRA_TW_FieldMap()add_fieldmaps_to_axes()add_magnets_to_axes()fieldmap_data()find_nearest()general_plot()getattrsplit()load_elements()magnet_plotting_datamagnet_plotting_data.aperture()magnet_plotting_data.beam_position_monitor()magnet_plotting_data.dipole()magnet_plotting_data.full_rectangle()magnet_plotting_data.half_rectangle()magnet_plotting_data.quadrupole()magnet_plotting_data.screen()magnet_plotting_data.sextupole()magnet_plotting_data.wall_current_monitor()
plot()plot_fieldmaps()trans()
- Module contents
Submodules
simba.Modules.MathParser module
- class MathParser(vars, math=True)[source]
Bases:
objectBasic parser with local variable and math functions
- Parameters:
vars (mapping) – mapping object where obj[name] -> numerical value
math (bool, optional) – if True (default) all math function are added in the same name space
Example
data = {‘r’: 3.4, ‘theta’: 3.141592653589793} parser = MathParser(data) assert parser.parse(‘r*cos(theta)’) == -3.4 data[‘theta’] =0.0 assert parser.parse(‘r*cos(theta)’) == 3.4
simba.Modules.SDDSFile module
- class SDDSColumn(name=None, data=[], unit='', type=2, symbol='', formatstring='', fieldlength=0, description='')[source]
Bases:
SDDSObject- property data
- class SDDSFile(index=1, ascii=False)[source]
Bases:
object- add_column(name, data, type=2, unit='', symbol='', formatstring='', fieldlength=0, description='')[source]
- add_columns(name, data, type, unit, symbol, formatstring=None, fieldlength=None, description=None)[source]
- add_parameter(name, data, type=2, unit='', symbol='', formatstring='', fieldlength=0, description='')[source]
- add_parameters(name, data, type, unit, symbol, formatstring=None, fieldlength=None, description=None)[source]
- property data
- property index
- class SDDSObject(index=1, name=None, data=[], unit='', type=2, symbol='', formatstring='', fieldlength=0, description='')[source]
Bases:
Munch- property data
- property description
- property fieldlength
- property formatstring
- property name
- property symbol
- property type
- property unit
- class SDDSParameter(name=None, data=[], unit='', type=2, symbol='', formatstring='', fieldlength=0, description='')[source]
Bases:
SDDSObject- property data
- property fieldlength
- class SDDS_Types(value)[source]
Bases:
IntEnumAn enumeration.
- SDDS_ASCII = 2
- SDDS_BINARY = 1
- SDDS_CHARACTER = 9
- SDDS_DOUBLE = 2
- SDDS_FLOAT = 3
- SDDS_INT16 = 6
- SDDS_INT32 = 4
- SDDS_LONG = 4
- SDDS_LONGDOUBLE = 1
- SDDS_NUM_TYPES = 9
- SDDS_REAL32 = 3
- SDDS_REAL64 = 2
- SDDS_SHORT = 6
- SDDS_STRING = 8
- SDDS_UINT16 = 7
- SDDS_UINT32 = 5
- SDDS_ULONG = 5
- SDDS_USHORT = 7
simba.Modules.constants module
simba.Modules.gdf_beam module
- class gdf_beam(filename)[source]
Bases:
Munch- property positions: dict
- property screens: dict
- sorted_nicely(unsorted_list, dict_key=None)[source]
Sort the given iterable in the way that humans expect.
- Parameters:
unsorted_list (
list)dict_key (
Optional[str])
- Return type:
list
- property times: dict
- property touts: dict
simba.Modules.gdf_emit module
simba.Modules.id_number module
simba.Modules.id_number_server module
- class zmqServer(port=5557)[source]
Bases:
Thread- run()[source]
Method representing the thread’s activity.
You may override this method in a subclass. The standard run() method invokes the callable object passed to the object’s constructor as the target argument, if any, with sequential and keyword arguments taken from the args and kwargs arguments, respectively.
simba.Modules.merge_two_dicts module
simba.Modules.pmd_units module
Simple units functionality for the openPMD beamphysics records.
- For more advanced units, use a package like Pint:
- nice_array(a)[source]
Returns a scaled array, the scaling, and a unit prefix
Example
nice_array( np.array([2e-10, 3e-10]) )
- Returns:
(array([200., 300.]), 1e-12, ‘p’)
- nice_scale_prefix(scale)[source]
Returns a nice factor and a SI prefix string
Example
scale = 2e-10
f, u = nice_scale_prefix(scale)
- class pmd_unit(unitSymbol='', unitSI=0, unitDimension=(0, 0, 0, 0, 0, 0, 0))[source]
Bases:
objectParams
unitSymbol: Native units name unitSI: Conversion factor to the the correspontign SI unit unitDimension: SI Base Exponents
- Base unit dimensions are defined as:
Base dimension | exponents. | SI unit —————- —————– ——- length : (1,0,0,0,0,0,0) m mass : (0,1,0,0,0,0,0) kg time : (0,0,1,0,0,0,0) s current : (0,0,0,1,0,0,0) A temperture : (0,0,0,0,1,0,0) K mol : (0,0,0,0,0,1,0) mol luminous : (0,0,0,0,0,0,1) cd
Example
pmd_unit(‘eV’, 1.602176634e-19, (2, 1, -2, 0, 0, 0, 0)) defines that an eV is 1.602176634e-19 of base units m^2 kg/s^2, which is a Joule (J)
- If unitSI=0 (default), init with a known symbol:
pmd_unit(‘T’)
- returns:
pmd_unit(‘T’, 1, (0, 1, -2, -1, 0, 0, 0))
- Simple equalities are provided:
u1 == u2
Returns True if the params are all the same.
- property unitDimension
- property unitSI
- property unitSymbol
- read_dataset_and_unit_h5(h5, expected_unit=None, convert=True)[source]
Reads a dataset that has openPMD unit attributes.
expected_unit can be a pmd_unit object, or a known unit str. Examples: ‘kg’, ‘J’, ‘eV’
If expected_unit is given, will check that the units are compatible.
If convert, the data will be returned with the expected_units.
- Returns a tuple:
np.array, pmd_unit
simba.Modules.symmlinks module
simba.Modules.units module
- class UnitValue(input_array, units=None, dtype=None)[source]
Bases:
ndarraySubclass of ndarray MUST be initialized with a numpy array as first argument.
- mean(axis=None, dtype=None, out=None, keepdims=False, *, where=True)[source]
Returns the average of the array elements along given axis.
Refer to numpy.mean for full documentation.
See also
numpy.meanequivalent function
- property nice
- nounits = ['sin', 'cos', 'tan', 'arcsin', 'arccos', 'arctan', 'arctan2']
- std(axis=None, dtype=None, out=None, ddof=0, keepdims=False, *, where=True)[source]
Returns the standard deviation of the array elements along given axis.
Refer to numpy.std for full documentation.
See also
numpy.stdequivalent function
- sum(axis=None, dtype=None, out=None, keepdims=False, initial=0, where=True)[source]
Return the sum of the array elements over the given axis.
Refer to numpy.sum for full documentation.
See also
numpy.sumequivalent function
- property val
- collect_units(unit_powers)[source]
Collects units into numerator ands denominator and uses ‘*’ and ‘/’ correctly
- expand_units(unit_list, power_factor=1)[source]
Takes a list of units (normally numerator or denominator) and collects units and powers Returns units (‘a^x’) and unitnames ((‘a’,x))
- nice_array(a)[source]
Returns a scaled array, the scaling, and a unit prefix
Example
nice_array( np.array([2e-10, 3e-10]) )
- Returns:
(array([200., 300.]), 1e-12, ‘p’)
- nice_scale_prefix(scale)[source]
Returns a nice factor and a SI prefix string
Example
scale = 2e-10
f, u = nice_scale_prefix(scale)
- set_nice_array(a, prefix)[source]
Returns a scaled array, the scaling, for a unit prefix
Example
set_nice_array( np.array([2e-3, 3e-3]), prefix=”m”)
- Returns:
(array([2., 3.]), 1e-3, ‘m’)
- unit_fraction(string)[source]
split a tring into numerator and denominator taking into account () - input is string in form ‘a^x*b/c^y’
- unit_power_multiply(string1, string2, power_factor=1)[source]
Takes two strings in the form (‘a’, x) and (‘a’, y) and returns (‘a’, (x+y))
Module contents
Simframe Modules
Modules to handle particle beams, electromagnetic fields, matrices, plotting, optimisation and Twiss parameters, along with various utility functions.
- Classes:
beam: Handles particle distributions, including
various analysis functions and the loading and writing of files to and from various formats.
field: Handles electromagnetic field distributions,
including the loading and writing of files to and from various formats.
matrices: Handles particle tracking matrices of
various orders.
twiss: Handles beam twiss parameters produced by
simulations and joins them together.
with units attached; used in many of these modules.
Other classes are defined in this submodule, but most of them are for expert use only.