def run(config, mesh_name, sim_name): print("load data ...") mesh_grid, sim_config, mesh_config, sim_file, source_expr = load_results_and_mesh( mesh_name, sim_name) ventricular_system = [ dom["name"] for dom in mesh_config["domains"] if dom["name"] not in ["csf", "parenchyma"] ] T = sim_config["T"] num_steps = sim_config["num_steps"] movie_path = f"results/{mesh_name}_{sim_name}/movies/{config['name']}" try: os.mkdir(movie_path) except FileExistsError: pass dt = T / num_steps times = np.linspace(0, T, num_steps + 1) print("configure...") for sc in config["scenes"]: print(sc.keys()) if "scalar_bar" in sc["static"].keys(): sc["static"]["scalar_bar_args"] = scalar_bars[sc["static"].pop( "scalar_bar")] if sc["mesh_parts"] == "ventricular_system": sc["mesh_parts"] = ventricular_system if sc["mesh_parts"] == "all_fluid": sc["mesh_parts"] = ventricular_system + ["csf"] if "clim" in sc["static"].keys(): if sc["static"]["clim"] == "global": v_max = compute_glob_stat(max, mesh_grid, sc["var"], sc["mesh_parts"], range(num_steps), sim_file, mesh_config) v_min = compute_glob_stat(min, mesh_grid, sc["var"], sc["mesh_parts"], range(num_steps), sim_file, mesh_config) sc["static"]["clim"] = (v_min, v_max) # set image generator img_generator = lambda idx: plot_partial_3D(mesh_grid, idx, config["scenes"], sim_file, mesh_config, cpos=config["camera_pos"], interactive=False) create_movie(f"{movie_path}/{config['name']}", times, source_expr, img_generator, fps=config["fps"], interpolate_frames=config["interpolate_frames"])
axes[j, i].imshow(img) axes[j, i].set_title(f"t = {times[idx]:.3f} s", fontsize=26) axes[j, i].axis('off') fig.tight_layout() fig.savefig(path + "_array_plot.pdf") if __name__ == "__main__": print("start movie creation...") mesh_name = sys.argv[1] sim_name = sys.argv[2] movie_path = f"results/{mesh_name}_{sim_name}/movies/{name}" img_gen = ImageGenerator(mesh_name, sim_name) img_gen_func = lambda time_idx: img_gen.generate_image(time_idx) create_movie(f"{movie_path}/{name}", img_gen.times, img_gen.source_expr, img_gen_func, fps=fps, interpolate_frames=interpFrames) phase_times = [0.13, .35, 0.56, 0.8] #[2.2, 2.4, 2.6, 2.8, 3.0] img_gen = ImageGenerator(mesh_name, sim_name, times=phase_times) img_gen_func = lambda time_idx, view: img_gen.generate_image(time_idx, view=view) create_array_plot(f"{movie_path}/{name}", img_gen.time_indices, img_gen.source_expr, img_gen_func, img_gen.times)