sirepo.sim_data package¶
Type-based simulation operations
- copyright:
Copyright (c) 2019 RadiaSoft LLC. All Rights Reserved.
- license:
- class sirepo.sim_data.SimDataBase[source]¶
Bases:
object- ANALYSIS_ONLY_FIELDS = frozenset({})¶
- LIB_DIR = 'lib'¶
- WATCHPOINT_REPORT = 'watchpointReport'¶
- WATCHPOINT_REPORT_RE = re.compile('^watchpointReport(\\d+)$')¶
- classmethod compute_job_hash(data, qcall)[source]¶
Hash fields related to data and set computeJobHash
Only needs to be unique relative to the report, not globally unique so MD5 is adequate. Long and cryptographic hashes make the cache checks slower.
- classmethod compute_model(model_or_data)[source]¶
Compute model for this model_or_data
- Parameters:
() (model_or_data) – analysis model
- Returns:
name of compute model for report
- Return type:
- classmethod does_api_reply_with_file(api, method)[source]¶
Identify which job_api calls expect files
- classmethod fixup_old_data(data, qcall, **kwargs)[source]¶
Update model data to latest schema
Modifies data in place.
- Parameters:
data (dict) – simulation
- classmethod frame_id(data, response, model, index)[source]¶
Generate a frame_id from values (unit testing)
- classmethod lib_file_abspath(basename, data=None, qcall=None)[source]¶
Returns full, unique paths of simulation files
- classmethod lib_file_name_without_type(basename)[source]¶
Strip the file type prefix
See lib_file_name which prefixes with
model-field.- Parameters:
basename – lib file name with type
- Returns:
basename without type prefix
- Return type:
- classmethod lib_file_names_for_type(file_type, qcall=None)[source]¶
Return sorted list of files which match file_type
- classmethod lib_file_read_binary(basename, qcall=None)[source]¶
Get contents of basename from lib as bytes
- classmethod lib_file_resource_path(basename)[source]¶
Location of lib file in source distribution
- Parameters:
basename (str) – complete name of lib file
- Returns:
Absolute path to file in source distribution
- Return type:
py.path
- classmethod lib_file_save_from_url(url, model_name, field)[source]¶
Fetch url and save to lib
Path to save to is lib_file_name_with_model_field is called with the basename of url.
- classmethod lib_file_write(basename, path_or_content, qcall=None)[source]¶
Save content to basename in lib
- classmethod lib_files_from_other_user(data, other_lib_dir, qcall)[source]¶
Copy auxiliary files to other user
Does not copy resource files. Only works locally.
- Parameters:
data (dict) – simulation db
other_lib_dir (py.path) – source directory
- classmethod lib_files_to_run_dir(data, run_dir)[source]¶
Copy auxiliary files to run_dir
- Parameters:
data (dict) – simulation db
run_dir (py.path) – where to copy to
- classmethod model_defaults(name)[source]¶
Returns a set of default model values from the schema.
- Some special cases:
if the data type is “UUID” and the default value is empty, set the value to a new UUID string
if the data type is “RandomId” and the default value is empty, set the value to a new Base62 string
if the data type has the form “model.zzz”, set the value to the default value of model “zzz”
- Parameters:
name (str) – model name
- classmethod parse_jid(data, uid)[source]¶
A Job is a tuple of user, sid, and compute_model.
A jid is words and dashes.
- classmethod parse_model(obj)[source]¶
Find the model in the arg
Looks for frameReport, report, and modelName. Might be a compute or analysis model.
- classmethod poll_seconds(data)[source]¶
Client poll period for simulation status
TODO(robnagler) needs to be encapsulated
- classmethod put_sim_file(sim_id, src_file_name, dst_basename)[source]¶
Write a file to the simulation’s database directory
- classmethod resource_path(filename)[source]¶
Static resource (package_data) file for simulation
- Returns:
absolute path to file
- Return type:
py.path.local
- classmethod sim_db_client()[source]¶
Low-level for sim_db_file ops for job agents
Used to manipulate sim db files in job agent. Care should be taken to avoid inefficiencies as these are remote requests. Typically, these are done in job_cmd, not job_agent, because operations are synchronous.
- Returns:
interface to sirepo.sim_db_file
- Return type:
- classmethod sim_db_read_sim(sim_id, sim_type=None, qcall=None)[source]¶
Read simulation sdata for sim_id
Calls simulation_db.read_simulation_json
- classmethod sim_db_save_sim(sdata, qcall=None)[source]¶
Save sdata to simulation db.
Calls simulation_db.save_simulation_json
- Parameters:
sdata (PKDict) – what to write
qcall (quest.API) – quest [None]
- Returns:
updated sdata
- Return type:
PKDict
- classmethod sim_file_basenames(data)[source]¶
List of files needed for this simulation
- Returns:
basenames of sim repo dir
- Return type:
- classmethod sim_files_to_run_dir(data, run_dir)[source]¶
Copy files from sim repo dir to run_dir
Calls sim_file_basenames to get list of sim files.
- Parameters:
data (PKDict) – used to identify simulation
run_dir (py.path) – directory to write to
- classmethod sim_run_dir_prepare(run_dir, data=None)[source]¶
Create and install files, update parameters, and generate command.
Copies files into the simulation directory (
run_dir) Updates the parameters indataand save. Generate the pkcli command.
- classmethod sim_run_input(run_dir, checked=True)[source]¶
Read input from run dir
- Parameters:
run_dir (py.path) – directory containing input file
checked (bool) – raise if not found [True]
- Returns:
sim input data or None if not checked
- Return type:
PKDict
- classmethod sim_run_input_fixup(data)[source]¶
Fixup data for simulation input
- Parameters:
data (PKDict) – for a run or whole sim data
- Returns:
fixed up data
- Return type:
PKDict
- classmethod sim_run_input_path(run_dir)[source]¶
Generate path from run_dir
- Parameters:
run_dir (py.path) – directory containing input file
- Returns:
path to run input
- Return type:
py.path
- sirepo.sim_data.audit_proprietary_lib_files(qcall, force=False, sim_types=None, uid=None)[source]¶
Add/removes proprietary files based on a user’s roles
For example, add the Flash tarball if user has the flash role.
- sirepo.sim_data.parse_frame_id(frame_id)[source]¶
Parse the frame_id and return it along with self
- Parameters:
frame_id (str) – values separated by “*”
- Returns:
frame_args SimDataBase: sim_data object for this simulationType
- Return type:
PKDict
- sirepo.sim_data.resource_path(filename)[source]¶
Path to common (not specific to sim type) resource file
- sirepo.sim_data.template_globals(sim_type=None)[source]¶
Initializer for templates
- Usage::
_SIM_DATA, SIM_TYPE, _SCHEMA = sirepo.sim_data.template_globals()
Submodules¶
sirepo.sim_data.activait module¶
sirepo.sim_data.adm module¶
simulation data operations
- copyright:
Copyright (c) 2019 RadiaSoft LLC. All Rights Reserved.
- license:
sirepo.sim_data.canvas module¶
simulation data operations
- copyright:
Copyright (c) 2024 RadiaSoft LLC. All Rights Reserved.
- license:
sirepo.sim_data.controls module¶
sirepo.sim_data.cortex module¶
simulation data operations
- copyright:
Copyright (c) 2025 RadiaSoft LLC. All Rights Reserved.
- license:
sirepo.sim_data.elegant module¶
elegant simulation data functions
- copyright:
Copyright (c) 2019 RadiaSoft LLC. All Rights Reserved.
- license:
sirepo.sim_data.epicsllrf module¶
simulation data operations
- copyright:
Copyright (c) 2023 RadiaSoft LLC. All Rights Reserved.
- license:
sirepo.sim_data.flash module¶
simulation data operations
- copyright:
Copyright (c) 2019 RadiaSoft LLC. All Rights Reserved.
- license:
- class sirepo.sim_data.flash.SimData[source]¶
Bases:
SimDataBase- COMPILE_LOG = 'compile.log'¶
- FLASH_PAR_FILE = 'flash.par'¶
- SETUP_LOG = 'setup.log'¶
- SETUP_PARAMS_SCHEMA_FILE = 'setup_params.json'¶
sirepo.sim_data.genesis module¶
simulation data operations
- copyright:
Copyright (c) 2020 RadiaSoft LLC. All Rights Reserved.
- license:
sirepo.sim_data.hellweg module¶
simulation data operations
- copyright:
Copyright (c) 2019 RadiaSoft LLC. All Rights Reserved.
- license:
sirepo.sim_data.impactt module¶
simulation data operations :copyright: Copyright (c) 2024 RadiaSoft LLC. All Rights Reserved. :license: http://www.apache.org/licenses/LICENSE-2.0.html
sirepo.sim_data.impactx module¶
simulation data operations :copyright: Copyright (c) 2024 RadiaSoft LLC. All Rights Reserved. :license: http://www.apache.org/licenses/LICENSE-2.0.html
sirepo.sim_data.jspec module¶
sirepo.sim_data.jupyterhublogin module¶
simulation data operations
- copyright:
Copyright (c) 2020 RadiaSoft LLC. All Rights Reserved.
- license:
- class sirepo.sim_data.jupyterhublogin.SimData[source]¶
Bases:
SimDataBase
sirepo.sim_data.lattice module¶
Common simulation data operations for lattice apps :copyright: Copyright (c) 2025 RadiaSoft LLC. All Rights Reserved. :license: http://www.apache.org/licenses/LICENSE-2.0.html
sirepo.sim_data.madx module¶
simulation data operations
- copyright:
Copyright (c) 2020 RadiaSoft LLC. All Rights Reserved.
- license:
sirepo.sim_data.myapp module¶
simulation data operations
- copyright:
Copyright (c) 2019 RadiaSoft LLC. All Rights Reserved.
- license:
sirepo.sim_data.omega module¶
simulation data operations
- copyright:
Copyright (c) 2023 RadiaSoft LLC. All Rights Reserved.
- license:
sirepo.sim_data.opal module¶
opal simulation data operations
- copyright:
Copyright (c) 2019 RadiaSoft LLC. All Rights Reserved.
- license:
sirepo.sim_data.openmc module¶
simulation data operations
- copyright:
Copyright (c) 202 RadiaSoft LLC. All Rights Reserved.
- license:
- class sirepo.sim_data.openmc.SimData[source]¶
Bases:
SimDataBase- INPUT_DAGMC = 'DAGMC'¶
- INPUT_MCNP = 'MCNP'¶
- INPUT_STEP = 'STEP'¶
- classmethod fixup_old_data(data, qcall, **kwargs)[source]¶
Update model data to latest schema
Modifies data in place.
- Parameters:
data (dict) – simulation
- classmethod get_geometry_input_filenames(data)[source]¶
Get the dagmc and possibly STEP or MCNP filenames
- Parameters:
data (PKDict) – simulation data
- Returns:
Tuple of the dagmc filename. And either the
- Return type:
original STEP or MCNP file the dagmc was generated from or None if the dagmc wasn’t generated from an intermediate file.
sirepo.sim_data.radia module¶
simulation data operations
- copyright:
Copyright (c) 2019 RadiaSoft LLC. All Rights Reserved.
- license:
- class sirepo.sim_data.radia.SimData[source]¶
Bases:
SimDataBase- ANALYSIS_ONLY_FIELDS = frozenset({'alpha', 'bgColor', 'color', 'colorMap', 'name', 'notes', 'scaling'})¶
sirepo.sim_data.raydata module¶
simulation data operations
- copyright:
Copyright (c) 2020 RadiaSoft LLC. All Rights Reserved.
- license:
- class sirepo.sim_data.raydata.SimData[source]¶
Bases:
SimDataBase
sirepo.sim_data.shadow module¶
sirepo.sim_data.silas module¶
SILAS simulation data operations
- copyright:
Copyright (c) 2020 RadiaSoft LLC. All Rights Reserved.
- license:
- class sirepo.sim_data.silas.SimData[source]¶
Bases:
SimDataBase- ANALYSIS_ONLY_FIELDS = frozenset({'colorMap'})¶
- SOURCE_REPORTS = frozenset({'laserPulse2Animation', 'laserPulseAnimation'})¶
sirepo.sim_data.srw module¶
simulation data operations
- copyright:
Copyright (c) 2019 RadiaSoft LLC. All Rights Reserved.
- license:
- class sirepo.sim_data.srw.SimData[source]¶
Bases:
SimDataBase- ANALYSIS_ONLY_FIELDS = frozenset({'aspectRatio', 'colorMap', 'copyCharacteristic', 'horizontalOffset', 'horizontalSize', 'intensityPlotsWidth', 'maxIntensityLimit', 'minIntensityLimit', 'notes', 'plotAxisX', 'plotAxisY', 'plotAxisY2', 'plotScale', 'rotateAngle', 'rotateReshape', 'showPlotSize', 'useIntensityLimits', 'usePlotRange', 'verticalOffset', 'verticalSize'})¶
- EXPORT_RSOPT = 'exportRsOpt'¶
- ML_OUTPUT = 'results.h5'¶
- ML_REPORT = 'machineLearningAnimation'¶
- SRW_FILE_TYPE_EXTENSIONS = {'arbitraryField': ['dat', 'txt'], 'mirror': ['dat', 'txt'], 'multiElectronAnimation-coherentModesFile': ['h5'], 'sample': ['tif', 'tiff', 'png', 'bmp', 'gif', 'jpg', 'jpeg'], 'undulatorTable': ['zip']}¶
- SRW_RUN_ALL_MODEL = 'simulation'¶
- classmethod does_api_reply_with_file(api, method)[source]¶
Identify which job_api calls expect files
- classmethod fixup_old_data(data, qcall, **kwargs)[source]¶
Fixup data to match the most recent schema.
- classmethod lib_file_name_without_type(filename)[source]¶
Strip the file type prefix
See lib_file_name which prefixes with
model-field.- Parameters:
basename – lib file name with type
- Returns:
basename without type prefix
- Return type:
- classmethod lib_file_names_for_type(file_type, qcall=None)[source]¶
Return sorted list of files which match file_type
- classmethod sim_type()¶
- classmethod srw_find_closest_angle(angle, allowed_angles)[source]¶
Find closest string value from the input list to the specified angle (in radians).
sirepo.sim_data.warppba module¶
simulation data operations
- copyright:
Copyright (c) 2019 RadiaSoft LLC. All Rights Reserved.
- license:
sirepo.sim_data.warpvnd module¶
simulation data operations
- copyright:
Copyright (c) 2019 RadiaSoft LLC. All Rights Reserved.
- license:
- class sirepo.sim_data.warpvnd.SimData[source]¶
Bases:
SimDataBase- ANALYSIS_ONLY_FIELDS = frozenset({'axes', 'color', 'colorMap', 'impactColorMap', 'notes', 'slice'})¶
sirepo.sim_data.zgoubi module¶
simulation data operations
- copyright:
Copyright (c) 2019 RadiaSoft LLC. All Rights Reserved.
- license: