DPF creates an h5 file when I add an Imported Temperature condition in Mechanical. How do I read the data out of that file?
The file is named "LoadMapping<Object_ID>_Data.h5"
The result is written as "target_data_<Object_ID>" in the h5 file, we need to use the custom read operator:
import re import os from ansys.dpf import core as dpf dpf.start_local_server(ansys_path=r"C:\Program Files\ANSYS Inc\v252") nid = 481 file_name = "LoadMapping70_Data.h5" h5 = os.path.join(r"…", file_name) ds = dpf.DataSources() ds.set_result_file_path(h5, "h5dpf") ts = dpf.Scoping() ts.ids = [1, 2] # Input time-steps object_id = int(re.search(r'\d+', file_name).group()) result_name = f"target_data_{object_id}" # Read Custom Result custom_res = dpf.Operator("hdf5::h5dpf::custom") custom_res.inputs.data_sources.connect(ds) custom_res.inputs.result_name.connect(result_name) custom_res.inputs.time_scoping.connect(ts) my_field_or_fields_container = custom_res.outputs.field_or_fields_container_as_fields_container() print(my_field_or_fields_container) for i in ts.ids: temp = my_field_or_fields_container.get_field_by_time_id(i).get_entity_data_by_id(nid) print(temp)