How to export voxel data using python API?
-
I normally just get it from the h5 input file if you know where it is (in Acoustics it's under Meshes, then eventually in a dataset called voxels - you can use HDF5View to examine your input file).
Some (untested) code to get you started:
import h5py import s4l_v1 as s4l def geth5Dataset(h5f, group_name, dataset_name): def find_dataset(name): if dataset_name in name: return name with h5py.File(h5f, 'r') as f: k = f[group_name].visit(find_dataset) return f[group_name + '/' + k][()] def getVoxels(h5f): return geth5Dataset(h5f, 'Meshes', 'voxels') sim_idx = 0 # Simulation number sim = s4l.document.AllSimulations[sim_idx] file_name = sim.GetInputFileName() file_path = "c:/file_path/" vox = getVoxels(file_path + file_name) -
I normally just get it from the h5 input file if you know where it is (in Acoustics it's under Meshes, then eventually in a dataset called voxels - you can use HDF5View to examine your input file).
Some (untested) code to get you started:
import h5py import s4l_v1 as s4l def geth5Dataset(h5f, group_name, dataset_name): def find_dataset(name): if dataset_name in name: return name with h5py.File(h5f, 'r') as f: k = f[group_name].visit(find_dataset) return f[group_name + '/' + k][()] def getVoxels(h5f): return geth5Dataset(h5f, 'Meshes', 'voxels') sim_idx = 0 # Simulation number sim = s4l.document.AllSimulations[sim_idx] file_name = sim.GetInputFileName() file_path = "c:/file_path/" vox = getVoxels(file_path + file_name)@montanaro I've tried it and it worked. Thank you very much!
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login