load hdf5

16 views
Skip to first unread message

Alejandro Stewart

unread,
Dec 1, 2020, 9:11:07 AM12/1/20
to pyNastran Discuss
 Hi all, I have been trying to reach model or results from hdf files without succes.  I dont really know if my approach is right. For the bdf it fails  and for the op2 nothing is loaded.

code:
from pyNastran.bdf.bdf import BDF
from pyNastran.op2.op2 import OP2
from pyNastran.bdf.bdf_interface.hdf5_loader import load_bdf_from_hdf5_file
import h5py as h5
bdf=BDF()
op2=OP2()
f = h5.File('placa.h5', 'r')
bdf.load_hdf5_filename('placa.h5')# this neves works
op2.load_hdf5_filename('placa.h5')# nothing is retrieved here
op2.load_hdf5_file(f) # try from another angle....
op2.write_f06('test.f06') #have I read something?


output:
WARNING: hdf5_loader.py:225           skipping hdf5 load for INDEX
WARNING: hdf5_loader.py:225           skipping hdf5 load for NASTRAN
Traceback (most recent call last):
  File "G:/WORK_ALEJANDRO/32.Antesala-NEO/Virtual_CentOs/compartido/test_hdf5/read_hdf_bdf.py", line 8, in <module>
    bdf.load_hdf5_filename('placa.h5')
  File "G:\WORK_ALEJANDRO\32.Antesala-NEO\Virtual_CentOs\compartido\test_hdf5\pyNastran\bdf\bdf.py", line 958, in load_hdf5_filename
    self.load_hdf5_file(hdf5_file)
  File "G:\WORK_ALEJANDRO\32.Antesala-NEO\Virtual_CentOs\compartido\test_hdf5\pyNastran\bdf\bdf.py", line 973, in load_hdf5_file
    load_bdf_from_hdf5_file(h5_file, self)
  File "G:\WORK_ALEJANDRO\32.Antesala-NEO\Virtual_CentOs\compartido\test_hdf5\pyNastran\bdf\bdf_interface\hdf5_loader.py", line 228, in load_bdf_from_hdf5_file
    cards_to_read = _cast(h5_file['cards_to_read'])
  File "h5py\_objects.pyx", line 54, in h5py._objects.with_phil.wrapper
  File "h5py\_objects.pyx", line 55, in h5py._objects.with_phil.wrapper
  File "C:\ProgramData\Anaconda3\lib\site-packages\h5py\_hl\group.py", line 264, in __getitem__
    oid = h5o.open(self.id, self._e(name), lapl=self._lapl)
  File "h5py\_objects.pyx", line 54, in h5py._objects.with_phil.wrapper
  File "h5py\_objects.pyx", line 55, in h5py._objects.with_phil.wrapper
  File "h5py\h5o.pyx", line 190, in h5py.h5o.open
KeyError: "Unable to open object (object 'cards_to_read' doesn't exist)"

Process finished with exit code 1

This bothers me a lot as it sees to skip the h5 info and looks for cards_to_read which isn´t in the hdf5 file:

Model and h5 file are attached.

Alejandro
test_hdf5.zip

Alejandro Stewart

unread,
Dec 1, 2020, 9:16:33 AM12/1/20
to pyNastran Discuss
Content of the h5:

Alejandro Stewart

unread,
Dec 1, 2020, 9:49:29 AM12/1/20
to pyNastran Discuss
javaw_l0ab3B7a29.png

Alejandro Stewart

unread,
Dec 1, 2020, 10:01:25 AM12/1/20
to pyNastran Discuss
Sorry, the first traceback was after I commented a raise  statement. for the current code I get the following  :
Traceback (most recent call last):
  File "G:/WORK_ALEJANDRO/32.Antesala-NEO/Virtual_CentOs/compartido/test_hdf5/read_hdf_bdf.py", line 8, in <module>
    bdf.load_hdf5_filename('placa.h5')
  File "G:\WORK_ALEJANDRO\32.Antesala-NEO\Virtual_CentOs\compartido\test_hdf5\pyNastran\bdf\bdf.py", line 958, in load_hdf5_filename
    self.load_hdf5_file(hdf5_file)
  File "G:\WORK_ALEJANDRO\32.Antesala-NEO\Virtual_CentOs\compartido\test_hdf5\pyNastran\bdf\bdf.py", line 973, in load_hdf5_file
    load_bdf_from_hdf5_file(h5_file, self)
  File "G:\WORK_ALEJANDRO\32.Antesala-NEO\Virtual_CentOs\compartido\test_hdf5\pyNastran\bdf\bdf_interface\hdf5_loader.py", line 226, in load_bdf_from_hdf5_file
WARNING: hdf5_loader.py:225           skipping hdf5 load for INDEX
    raise RuntimeError('skipping hdf5 load for %s' % key)
RuntimeError: skipping hdf5 load for INDEX

Steven Doyle

unread,
Dec 2, 2020, 5:37:42 PM12/2/20
to pyNastran Discuss
Alejandro,

The HDF5 format that is supported is that which is written out by pyNastran, not by MSC.  It's an alternative to pickle.  The MSC format is planned for the future, but hasn't been started.

You save it using:
model.export_hdf5_filename(hdf5_filename)

--
You received this message because you are subscribed to the Google Groups "pyNastran Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pynastran-disc...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pynastran-discuss/92644b5b-0d33-460d-a003-2ff99d6b4f86n%40googlegroups.com.

Alejandro Stewart

unread,
Dec 3, 2020, 4:55:21 AM12/3/20
to pyNastran Discuss
Thank you Steve.
Reply all
Reply to author
Forward
0 new messages