Given any number of different dpf fields of data (for the same time and mesh scoping), how do you create one hdf5 file that contains all this combined information?
Answer, with help from Ayush:
def create_h5_file(path, *args): """ Create a .h5 file to the given path from the data provided (DPF field/Fileds Container) """ try: hdf5_op = dpf.operators.serialization.serialize_to_hdf5() # operator instantiation hdf5_op.inputs.file_path.connect(path) for i, data in enumerate(args): hdf5_op.connect(i + 3, data) hdf5_op.inputs.export_floats.connect(False) # maintain double precision hdf5_op.run() return True except Exception as e: return False # Define 3 differents sets of data to combine into 1 hdf5 file. disp_op = dpf.operators.result.displacement() disp_op.inputs.data_sources.connect(data_sources) disp_op.inputs.mesh_scoping.connect(mesh_scoping) disp_op.inputs.time_scoping.connect(time_scoping) nd_disps = disp_op.outputs.fields_container.get_data() node_coords_op = dpf.operators.mesh.node_coordinates() node_coords_op.inputs.mesh.connect(mesh_from_scoping) nd_coords=node_coords_op.outputs.coordinates_as_field.get_data() tfs_op = dpf.operators.metadata.time_freq_provider() tfs_op.inputs.data_sources.connect(data_sources) tfs = tfs_op.outputs.time_freq_support.get_data() # Write all fields into one .h5 file out_path = r"D:\working_dir\combined.h5" create_h5_file(out_path, nd_disps, nd_coords, tfs)
@Eric Stamper refer to this post.
https://discuss.ansys.com/discussion/4374/how-can-i-convert-a-file-rst-to-h5dpf-format