def snapshot(cuds, filename): """ Save a snapshot of the cuds object using the default visualisation. Parameters ---------- cuds : {ABCMesh, ABCParticles, ABCLattice} The CUDS dataset to be shown. filename : string The filename to use for the output file. Raises ------ TypeError: If the container type is not supported by the engine. """ if isinstance(cuds, ABCParticles): with temp_particles_filename() as temp_xyz_filename: create_xyz_file(cuds, temp_xyz_filename) run_aviz([temp_xyz_filename, "-snapq"]) snapshot_dir = os.path.dirname(os.path.realpath(temp_xyz_filename)) snapshot_file = _find_png(snapshot_dir) shutil.copyfile(snapshot_file, filename) elif isinstance(cuds, ABCLattice) or isinstance(cuds, ABCMesh): raise TypeError("Only Particles can be shown by AViz") else: msg = "Provided object {} is not of any known cuds type" raise TypeError(msg.format(type(cuds)))
def show(cuds): """ Show a CUDS container. Parameters ---------- cuds : {ABCMesh, ABCParticles, ABCLattice} The CUDS dataset to be shown. Raises ------ TypeError: If the container type is not supported by the engine. """ if isinstance(cuds, ABCParticles): with temp_particles_filename() as filename: create_xyz_file(cuds, filename) run_aviz(filename) elif isinstance(cuds, ABCLattice) or isinstance(cuds, ABCMesh): raise TypeError("Only Particles can be shown by AViz") else: msg = 'Provided object {} is not of any known cuds type' raise TypeError(msg.format(type(cuds)))