def explore(fpath): _, ext = splitext(fpath) ftype = 'data' if ext in ('.h5', '.hdf5') else 'simulation' print "Using %s file: '%s'" % (ftype, fpath) if ftype == 'data': h5in = populate_registry(fpath) h5out = None entity, period = None, None else: simulation = Simulation.from_yaml(fpath) h5in, h5out, periodic_globals = simulation.load() ent_name = simulation.default_entity entity = entity_registry[ent_name] if ent_name is not None else None period = simulation.start_period + simulation.periods - 1 try: c = Console(entity, period) c.run() finally: h5in.close() if h5out is not None: h5out.close()
def explore(fpath): _, ext = splitext(fpath) ftype = 'data' if ext in ('.h5', '.hdf5') else 'simulation' print("Using %s file: '%s'" % (ftype, fpath)) if ftype == 'data': globals_def = populate_registry(fpath) data_source = H5Data(None, fpath) h5in, _, globals_data = data_source.load(globals_def, registry.entity_registry) h5out = None entity, period = None, None else: simulation = Simulation.from_yaml(fpath) h5in, h5out, globals_data = simulation.load() entity = simulation.console_entity period = simulation.start_period + simulation.periods - 1 globals_def = simulation.globals_def try: c = Console(entity, period, globals_def, globals_data) c.run() finally: h5in.close() if h5out is not None: h5out.close()