def _create_example(example): data = simulation_db.save_new_example(example) # ensure all datafiles for the new example exist in the sim lib dir for f in template_common.lib_files(data): if not f.exists(): r = template_common.resource_dir(data.simulationType).join(f.basename) assert r.exists(), 'Example missing resource file: {}'.format(f) pkio.mkdir_parent_only(f) r.copy(f)
def examples(app): files = pkio.walk_tree( template_common.resource_dir(app).join(_EXAMPLE_DIR), re.escape(JSON_SUFFIX) + '$', ) #TODO(robnagler) Need to update examples statically before build # and assert on build # example data is not fixed-up to avoid performance problems when searching examples by name # fixup occurs during save_new_example() return [open_json_file(app, path=str(f), fixup=False) for f in files]
def examples(app): files = pkio.walk_tree( template_common.resource_dir(app).join(_EXAMPLE_DIR), re.escape(JSON_SUFFIX) + '$', ) #TODO(robnagler) Need to update examples statically before build # and assert on build # example data is not fixed-up to avoid performance problems when searching examples by name # fixup occurs during save_new_example() return [open_json_file(app, path=str(f), fixup=False) for f in files]
def default_data(sim_type): """New simulation base data Args: sim_type (str): simulation type Returns: dict: simulation data """ return open_json_file( sim_type, path=template_common.resource_dir(sim_type).join( 'default-data{}'.format(JSON_SUFFIX), ), )
def default_data(sim_type): """New simulation base data Args: sim_type (str): simulation type Returns: dict: simulation data """ return open_json_file( sim_type, path=template_common.resource_dir(sim_type).join( 'default-data{}'.format(JSON_SUFFIX), ), )
u"""Common values for elegant :copyright: Copyright (c) 2017 RadiaSoft LLC. All Rights Reserved. :license: http://www.apache.org/licenses/LICENSE-2.0.html """ from __future__ import absolute_import, division, print_function from pykern.pkdebug import pkdp, pkdc, pkdlog from sirepo.template import template_common import os import subprocess #: Application name SIM_TYPE = 'elegant' #: Where to get files RESOURCE_DIR = template_common.resource_dir(SIM_TYPE) def sort_elements_and_beamlines(data): models = data['models'] data['models']['elements'] = sorted(models['elements'], key=lambda el: el['type']) data['models']['elements'] = sorted(models['elements'], key=lambda el: (el['type'], el['name'].lower())) data['models']['beamlines'] = sorted(models['beamlines'], key=lambda b: b['name'].lower()) def subprocess_env(): """Adds RPN_DEFNS to os.environ
import struct import time import werkzeug import zipfile try: # pydicom is changing to pydicom in 1.0 import pydicom as dicom except ImportError: import dicom RTSTRUCT_EXPORT_FILENAME = 'rtstruct.dcm' RTDOSE_EXPORT_FILENAME = 'dose.dcm' PRESCRIPTION_FILENAME = 'prescription.json' SIM_TYPE = 'rs4pi' WANT_BROWSER_FRAME_CACHE = True RESOURCE_DIR = template_common.resource_dir(SIM_TYPE) DOSE_CALC_SH = 'dose_calc.sh' DOSE_CALC_OUTPUT = 'Full_Dose.h5' _DICOM_CLASS = { 'CT_IMAGE': '1.2.840.10008.5.1.4.1.1.2', 'RT_DOSE': '1.2.840.10008.5.1.4.1.1.481.2', 'RT_STRUCT': '1.2.840.10008.5.1.4.1.1.481.3', 'DETATCHED_STUDY': '1.2.840.10008.3.1.2.3.1', } _BEAMLIST_FILENAME = 'beamlist_72deg.txt' _DICOM_DIR = 'dicom' _DICOM_MAX_VALUE = 1000 _DICOM_MIN_VALUE = -1000 _DOSE_DICOM_FILE = RTDOSE_EXPORT_FILENAME _DOSE_FILE = 'dose3d.dat' _EXPECTED_ORIENTATION = np.array([1, 0, 0, 0, 1, 0])