def run(parameters=None, input_file=None, logger=None): path = str(Path(__file__).resolve().parent) fname = path + "/defaults.in" defaults = misc.read_json(fname, "Reading defaults from: {}", logger) if type(parameters) is str: parameters = misc.read_json(parameters, "Reading input from: {}", logger) elif parameters is None: logger.error("Give some parameters (dict or string (path))") defaults.update(parameters) parameters = defaults mesh_file = parameters[JCCODES.MESH] output_to = parameters[JCCODES.OUTPUTTO] gas_emission_base = parameters["gas_emission_base"] gas_emission_scale = parameters["gas_emission_scale"] pnoise_scale = parameters["pnoise_scale"] pnoise_offset = parameters["pnoise_offset"] octaves = parameters["octaves"] persistence = parameters["persistence"] m_gas = parameters["m_gas"] T_gas = parameters["T_gas"] gen.execute(mesh_file, output_to, gas_emission_base, gas_emission_scale, pnoise_scale, pnoise_offset, octaves, persistence, m_gas, T_gas, logger)
def run_gas_sim(from_face, to_face, input_from=None, output_postfix=None): import gas_sim path = os.path.dirname(os.path.abspath(__file__)) fname = path + "/defaults.in" defaults = misc.read_json(fname, txt="Reading defaults from: {}") if input_from is not None: parameters = misc.read_json(input_from, txt="Reading input from: {}") defaults.update(parameters) parameters = defaults if output_postfix is not None: parameters[ JCCODES.OUTPUTTO] = parameters[JCCODES.OUTPUTTO] + output_postfix gas_sim.init_and_run( from_face, to_face, parameters[ "mesh_scale"], ##scale of the mesh [obj space to km] parameters[JCCODES.MESH], ##read mesh from this file parameters["outflow_rates"], ##Outflow file parameters["T_gas"], ##Temperature of the gas parameters["R_gas"], ##Specific gas constant parameters["nBounds"], ##How many boundaries parameters["lower_corner_ind"], parameters["upper_corner_ind"], parameters["sample_points"], parameters["bbox_lower"], parameters["bbox_upper"], parameters[JCCODES.OUTPUTTO], parameters["gas_flow_scale"], parameters["sim_common"]["rot_mat"], parameters["sim_common"]["comet_location"], parameters["chunk_sizes"])
def prepare_output_for_sispo(model_name, aux_info): import bpy obj = bpy.data.objects[model_name] data = None if type(aux_info) is dict: data = aux_info elif type(aux_info) is str: with open(aux_info) as json_file: data = misc.read_json(aux_info) obj.dimensions = data["dimensions"] #Set shader parameters mat = bpy.data.materials.get('volumeScatterer') tilingNode = mat.node_tree.nodes.get("resolution") tilingNode.outputs[0].default_value = data["resolution"] tilingNode = mat.node_tree.nodes.get("tiles_x") tilingNode.outputs[0].default_value = data["tiles_x"] tilingNode = mat.node_tree.nodes.get("tiles_y") tilingNode.outputs[0].default_value = data["tiles_y"] new_img = bpy.data.images.load(filepath=data["tiles_file"]) tilingNode = mat.node_tree.nodes.get("tiles_file") tilingNode.image = new_img
def run(parameters, input_file=None, logger=None): import convert_to_exr as converter path = os.path.dirname(os.path.abspath(__file__)) fname = path + "/defaults.in" defaults = misc.read_json(fname, txt="Reading defaults from: {}") if (input_file is not None): parameters = misc.read_json(input_file, txt="Reading input from: {}") defaults.update(parameters) parameters = defaults output_file = parameters[JCCODES.OUTPUTFOLDER] + parameters["output_dmap"] #aux_info = parameters[JCCODES.OUTPUTFOLDER]+parameters["aux_info"] print(parameters) converter.run(parameters["bbox_lcorner"], parameters["bbox_ucorner"], parameters["resolution"], parameters["dust_particle_field"], parameters["trajectory"], parameters[JCCODES.MESH], output_file, parameters[JCCODES.OUTPUTTO], 1)
def run(parameters=None, empty=None, logger=None): path = os.path.dirname(os.path.abspath(__file__)) fname = path + "/defaults.in" defaults = misc.read_json(fname, "Reading defaults from: {}", logger) if type(parameters) is str: parameters = misc.read_json(parameters, "Reading input from: {}", logger) elif parameters is None: logger.error("Give some parameters (dict or string (path))") defaults.update(parameters) parameters = defaults n_processes = int(parameters[JCCODES.NPROCESSES]) n_particles = parameters["n_particles"] job_size = np.ceil(n_particles * 1.0 / n_processes) pids = [] logger.info("Running {} processes".format(n_processes)) output_files = [] for i in range(0, n_processes): postfix = "_{}".format(i) output_files.append("{}{}".format(parameters[JCCODES.OUTPUTTO], postfix)) normalization = 1.0 / n_processes p = Process(target=run_program, args=(parameters, job_size, output_files[-1], normalization)) logger.debug(output_files[-1]) p.start() pids.append(p) sleep_time = 5.0 logger.info("waiting processes to finish: start polling") misc.wait_processes(pids, sleep_time, logger) logger.info("particle simulation finished, combining results") arg1 = parameters[JCCODES.OUTPUTTO] arg2 = output_files p = Process(target=run_combine, args=(arg1, arg2)) p.start() pids.append(p) misc.wait_processes(pids, sleep_time, logger) logger.info("results combined")
def __init__(self, input_data=None, defaults=None, logger=None): if defaults is None: defaults = str(Path(__file__).resolve().parent)+"/data/defaults.in" if logger is None: logging.basicConfig(format='%(levelname)s:%(message)s', level=logging.DEBUG) self.logger = logging.getLogger(__name__) else: self.logger = logger # read default values data = misc.read_json(defaults, "Reading defaults from: {}", self.logger) # read given input and override values from default if input_data is not None: if type(input_data) is str: data2 = misc.read_json(input_data, "Reading input from: {}", self.logger) data.update(data2) elif type(input_data) is dict: data.update(input_data) self.parse_paths(data) self.data = data["JetCreator"] self.data_h = data