sirepo.template package¶
Templates are used to configure codes
- copyright:
Copyright (c) 2016-2022 RadiaSoft LLC. All Rights Reserved.
- license:
Submodules¶
sirepo.template.activait module¶
sirepo.template.canvas module¶
sirepo.template.code_variable module¶
Code variables.
- copyright:
Copyright (c) 2020 RadiaSoft LLC. All Rights Reserved.
- license:
- class sirepo.template.code_variable.CodeVar(variables, evaluator, case_insensitive=False)[source]¶
Bases:
object
- class sirepo.template.code_variable.CodeVarDeleteIterator(code_var, name)[source]¶
Bases:
ModelIterator
- class sirepo.template.code_variable.CodeVarIterator(code_var, data, schema)[source]¶
Bases:
ModelIterator
sirepo.template.controls module¶
sirepo.template.cortex module¶
sirepo.template.elegant module¶
sirepo.template.elegant_command_importer module¶
sirepo.template.elegant_command_parser module¶
elegant command parser.
- copyright:
Copyright (c) 2016 RadiaSoft LLC. All Rights Reserved.
- license:
sirepo.template.elegant_common module¶
sirepo.template.elegant_lattice_importer module¶
sirepo.template.elegant_lattice_parser module¶
elegant lattice parser.
- copyright:
Copyright (c) 2015 RadiaSoft LLC. All Rights Reserved.
- license:
sirepo.template.epicsllrf module¶
sirepo.template.flash module¶
sirepo.template.flash_parser module¶
Flash Config parser.
- copyright:
Copyright (c) 2021 RadiaSoft LLC. All Rights Reserved.
- license:
sirepo.template.flash_views module¶
Flash Config parser.
- copyright:
Copyright (c) 2021 RadiaSoft LLC. All Rights Reserved.
- license:
sirepo.template.genesis module¶
sirepo.template.hdf5_util module¶
sirepo.template.hellweg module¶
sirepo.template.hellweg_dump_reader module¶
Hellweg dump parser.
- copyright:
Copyright (c) 2017 RadiaSoft LLC. All Rights Reserved.
- license:
- class sirepo.template.hellweg_dump_reader.TBeamHeader[source]¶
Bases:
Structure- beam_current¶
Structure/Union member
- beam_h¶
Structure/Union member
- beam_lmb¶
Structure/Union member
- input_current¶
Structure/Union member
- class sirepo.template.hellweg_dump_reader.TDimension[source]¶
Bases:
Structure- Nx¶
Structure/Union member
- Ny¶
Structure/Union member
- Nz¶
Structure/Union member
- class sirepo.template.hellweg_dump_reader.TField[source]¶
Bases:
Structure- r¶
Structure/Union member
- th¶
Structure/Union member
- z¶
Structure/Union member
- class sirepo.template.hellweg_dump_reader.TFieldMap2D[source]¶
Bases:
Structure- Dim¶
Structure/Union member
- Field¶
Structure/Union member
- Piv¶
Structure/Union member
- class sirepo.template.hellweg_dump_reader.THeader[source]¶
Bases:
Structure- NParticles¶
Structure/Union member
- NPoints¶
Structure/Union member
- class sirepo.template.hellweg_dump_reader.TParticle[source]¶
Bases:
Structure- Th¶
Structure/Union member
- g¶
Structure/Union member
- gb¶
Structure/Union member
- lost¶
Structure/Union member
- phi¶
Structure/Union member
- r¶
Structure/Union member
- z¶
Structure/Union member
- class sirepo.template.hellweg_dump_reader.TPivot[source]¶
Bases:
Structure- X¶
Structure/Union member
- Y¶
Structure/Union member
- Z¶
Structure/Union member
- class sirepo.template.hellweg_dump_reader.TStructure[source]¶
Bases:
Structure- AF¶
Structure/Union member
- B¶
Structure/Union member
- Bmap¶
Structure/Union member
- CellNumber¶
Structure/Union member
- E¶
Structure/Union member
- P¶
Structure/Union member
- Ra¶
Structure/Union member
- Rp¶
Structure/Union member
- alpha¶
Structure/Union member
- betta¶
Structure/Union member
- dF¶
Structure/Union member
- drift¶
Structure/Union member
- jump¶
Structure/Union member
- ksi¶
Structure/Union member
- lmb¶
Structure/Union member
sirepo.template.impactt module¶
sirepo.template.impactt_parser module¶
sirepo.template.impactx module¶
sirepo.template.jspec module¶
sirepo.template.lattice module¶
Lattice utilities.
- copyright:
Copyright (c) 2019 RadiaSoft LLC. All Rights Reserved.
- license:
- class sirepo.template.lattice.ElementIterator(filename_map, formatter)[source]¶
Bases:
ModelIteratorIterate all fields, adding any set to non-default values to the results.
- IS_DISABLED_FIELD = 'isDisabled'¶
- class sirepo.template.lattice.InputFileIterator(sim_data, update_filenames=True)[source]¶
Bases:
ModelIteratorIterate and extract all InputFile filenames.
- class sirepo.template.lattice.LatticeIterator(filename_map, formatter)[source]¶
Bases:
ElementIteratorIterate all lattice elements/fields which are not set to the default value.
- class sirepo.template.lattice.LatticeParser(sim_data)[source]¶
Bases:
object- COMMAND_PREFIX = 'command_'¶
- class sirepo.template.lattice.LatticeUtil(data, schema)[source]¶
Bases:
object- iterate_models(iterator, name=None)[source]¶
Iterate the models in the named container. By default the commands and elements containers are iterated.
- render_lattice(fields, quote_name=False, want_semicolon=False, want_name=True, want_var_assign=False, madx_name=False, comment='//')[source]¶
Render lattice elements.
- class sirepo.template.lattice.ModelIterator[source]¶
Bases:
objectBase class for model iterators with stubbed out methods. When iterate_models() is called, the iterator calls are made:
it.start(model) foreach field in model:
it.field(model, field_schema, field)
it.end(model)
- class sirepo.template.lattice.UpdateIterator(update_func)[source]¶
Bases:
ModelIterator
sirepo.template.line_parser module¶
Simple line parser.
Parses a line of input one character at a time.
- copyright:
Copyright (c) 2016 RadiaSoft LLC. All Rights Reserved.
- license:
sirepo.template.madx module¶
sirepo.template.madx_converter module¶
sirepo.template.madx_parser module¶
MAD-X parser.
- copyright:
Copyright (c) 2020 RadiaSoft LLC. All Rights Reserved.
- license:
- class sirepo.template.madx_parser.MadXParser[source]¶
Bases:
LatticeParser
sirepo.template.myapp module¶
sirepo.template.omega module¶
sirepo.template.opal module¶
sirepo.template.opal_parser module¶
OPAL parser.
- copyright:
Copyright (c) 2020 RadiaSoft LLC. All Rights Reserved.
- license:
- class sirepo.template.opal_parser.OpalParser[source]¶
Bases:
LatticeParser
sirepo.template.openmc module¶
sirepo.template.openmc_util module¶
sirepo.template.particle_beam module¶
sirepo.template.radia module¶
sirepo.template.radia_util module¶
sirepo.template.raydata module¶
sirepo.template.sdds_util module¶
sirepo.template.shadow module¶
sirepo.template.silas module¶
sirepo.template.srw module¶
sirepo.template.srw_common module¶
SRW simulation_db/template/sim_data independent routines
- copyright:
Copyright (c) 2019 RadiaSoft LLC. All Rights Reserved.
- license:
sirepo.template.srw_debug module¶
sirepo.template.srw_fixup module¶
sirepo.template.srw_importer module¶
sirepo.template.srw_shadow module¶
sirepo.template.srwl_uti_brightness module¶
sirepo.template.template_common module¶
Common execution template.
- copyright:
Copyright (c) 2015 RadiaSoft LLC. All Rights Reserved.
- license:
- sirepo.template.template_common.INPUT_BASE_NAME = 'in.json'¶
Input json file
- class sirepo.template.template_common.JobCmdFile(**kwargs)[source]¶
Bases:
PKDictReturned by dispatched job commands
analysis_job_dispatch, stateless_compute_dispatch, and stateful_compute_dispatch support file returns.
- class sirepo.template.template_common.ModelUnits(unit_def)[source]¶
Bases:
objectConvert model fields from native to sirepo format, or from sirepo to native format.
- Examples::
- def _xpas(value, is_native):
# custom field conversion code would go here return value
- mu = ModelUnits({
- ‘CHANGREF’: {
‘XCE’: ‘cm_to_m’, ‘YCE’: ‘cm_to_m’, ‘ALE’: ‘deg_to_rad’, ‘XPAS’: _xpas,
},
}) m = mu.scale_from_native(‘CHANGREF’, {
‘XCE’: 2, ‘YCE’: 0, ‘ALE’: 8, ‘XPAS’: ‘#20|20|20’,
}) assert m[‘XCE’] == 2e-2 assert ModelUnits.scale_value(2, ‘cm_to_m’, True) == 2e-2 assert ModelUnits.scale_value(0.02, ‘cm_to_m’, False) == 2
- sirepo.template.template_common.NUMERIC_RE = re.compile('^\\s*(\\-|\\+)?(\\d+|(\\d*(\\.\\d*)))([eE][+-]?\\d+)?\\s*$')¶
Test if value is numeric text
- exception sirepo.template.template_common.NoH5PathError[source]¶
Bases:
KeyErrorThe given path into an h5 file does not exist
- sirepo.template.template_common.OUTPUT_BASE_NAME = 'out'¶
Output json file
- sirepo.template.template_common.PARAMETERS_PYTHON_FILE = 'parameters.py'¶
Python file (not all simulations)
- class sirepo.template.template_common.ParticleEnergy[source]¶
Bases:
objectComputes the energy related fields for a particle from one field. Units:
mass [GeV/c^2] pc [GeV/c] energy [GeV] brho [Tm]
- ENERGY_PRIORITY = {'impactx': ['energy'], 'madx': ['energy', 'pc', 'gamma', 'beta', 'brho'], 'opal': ['gamma', 'energy', 'pc']}¶
- PARTICLE_MASS_AND_CHARGE = {'antiproton': [0.938272046, -1], 'electron': [0.000510998928, -1], 'muon': [0.1056583755, -1], 'positron': [0.000510998928, 1], 'proton': [0.938272046, 1]}¶
- SPEED_OF_LIGHT = 299792458¶
- sirepo.template.template_common.RUN_LOG = 'run.log'¶
stderr and stdout
- sirepo.template.template_common.compute_field_range(args, compute_range, run_dir)[source]¶
Computes the fieldRange values for all parameters across all animation files. Caches the value on the animation input file. compute_range() is called to read the simulation specific datafiles and extract the ranges by field.
- sirepo.template.template_common.compute_plot_color_and_range(plots, plot_colors=None, fixed_y_range=None)[source]¶
For parameter plots, assign each plot a color and compute the full y_range. If a fixed range is provided, use that instead
- sirepo.template.template_common.file_extension_ok(file_path, white_list=None, black_list=['py', 'pyc'])[source]¶
Determine whether a file has an acceptable extension
- Parameters:
- Returns:
True If white_list non-empty: True if the file’s extension matches any in the list, otherwise False If white_list is empty: False if the file’s extension matches any in black_list, otherwise True
- Return type:
If file is a directory
- sirepo.template.template_common.flatten_data(d, res, prefix='')[source]¶
Takes a nested dictionary and converts it to a single level dictionary with flattened keys.
- sirepo.template.template_common.heatmap(values, model, plot_fields=None, weights=None)[source]¶
Computes a report histogram (x_range, y_range, z_matrix) for a report model.
- sirepo.template.template_common.histogram_bins(nbins)[source]¶
Ensure the histogram count is in a valid range
- sirepo.template.template_common.parameter_plot(x, plots, model, plot_fields=None, plot_colors=None)[source]¶
- sirepo.template.template_common.parse_enums(enum_schema)[source]¶
Returns a list of enum values, keyed by enum name.
- sirepo.template.template_common.read_sequential_result(run_dir)[source]¶
Read result data file from simulation
- Parameters:
run_dir (py.path) – where to find output
- Returns:
result
- Return type:
- sirepo.template.template_common.render_jinja(sim_type, v, name='parameters.py', jinja_env=None)[source]¶
Render the values into a jinja template.
- sirepo.template.template_common.subprocess_output(cmd, env=None)[source]¶
Run cmd and return output or None, logging errors.
- sirepo.template.template_common.text_data_file(filename, run_dir)[source]¶
Return a datafile with a .txt extension so the text/plain mimetype is used.
- sirepo.template.template_common.validate_model(model_data, model_schema, enum_info)[source]¶
Ensure the value is valid for the field type. Scales values as needed.
- sirepo.template.template_common.validate_models(model_data, model_schema)[source]¶
Validate top-level models in the schema. Returns enum_info.
- sirepo.template.template_common.write_dict_to_h5(d, file_path, h5_path=None)[source]¶
Store the contents of a dict in an h5 file starting at the provided path. Stores the data recursively so that
{a: A, b: {c: C, d: D}}
- maps the data to paths
<h5_path>/a -> A <h5_path>/b/c -> C <h5_path>/b/d -> D
h5_to_dict() performs the reverse process
sirepo.template.transfer_mat_bl module¶
sirepo.template.warppba module¶
sirepo.template.warpvnd module¶
sirepo.template.zgoubi module¶
sirepo.template.zgoubi_importer module¶
sirepo.template.zgoubi_parser module¶
zgoubi input file parser.
l:copyright: Copyright (c) 2018 RadiaSoft LLC. All Rights Reserved. :license: http://www.apache.org/licenses/LICENSE-2.0.html