FAIRmat-NFDI / pynxtools

https://fairmat-nfdi.github.io/pynxtools/
Apache License 2.0
13 stars 8 forks source link

[Bug]: read_nexus cannot process files with fixed-length strings #420

Closed rettigl closed 2 months ago

rettigl commented 2 months ago

Contact Details

rettig@fhi-berlin.mpg.de

What happened?

When reading a file with read_nexus, that contains fixed-length strings, these are returned as byte arrays, and the program terminates.

Relevant entries in the file look like: grafik

Relevant log output

rettig@pcr840:..AreaB/transformations_testing> read_nexus -f NXmpes_liquid\ test\ -\ 2024-07-16.nxs 
Traceback (most recent call last):
  File "/mnt/pcshare/users/Laurenz/AreaB/transformations_testing/.pyenv/bin/read_nexus", line 8, in <module>
    sys.exit(main())
  File "/mnt/pcshare/users/Laurenz/AreaB/transformations_testing/.pyenv/lib/python3.8/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
  File "/mnt/pcshare/users/Laurenz/AreaB/transformations_testing/.pyenv/lib/python3.8/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
  File "/mnt/pcshare/users/Laurenz/AreaB/transformations_testing/.pyenv/lib/python3.8/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/mnt/pcshare/users/Laurenz/AreaB/transformations_testing/.pyenv/lib/python3.8/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
  File "/mnt/pcshare/users/Laurenz/AreaB/transformations_testing/pynxtools/src/pynxtools/nexus/nexus.py", line 843, in main
    nexus_helper.process_nexus_master_file(None)
  File "/mnt/pcshare/users/Laurenz/AreaB/transformations_testing/pynxtools/src/pynxtools/nexus/nexus.py", line 777, in process_nexus_master_file
    self.full_visit(self.in_file, self.in_file, "", self.visit_node)
  File "/mnt/pcshare/users/Laurenz/AreaB/transformations_testing/pynxtools/src/pynxtools/nexus/nexus.py", line 761, in full_visit
    self.full_visit(root, child, full_name, func)
  File "/mnt/pcshare/users/Laurenz/AreaB/transformations_testing/pynxtools/src/pynxtools/nexus/nexus.py", line 756, in full_visit
    func(name, hdf_node)
  File "/mnt/pcshare/users/Laurenz/AreaB/transformations_testing/pynxtools/src/pynxtools/nexus/nexus.py", line 700, in visit_node
    process_node(hdf_node, "/" + hdf_name, self.parser, self.logger)
  File "/mnt/pcshare/users/Laurenz/AreaB/transformations_testing/pynxtools/src/pynxtools/nexus/nexus.py", line 384, in process_node
    f"===== GROUP (/{hdf_path} "
  File "/mnt/pcshare/users/Laurenz/AreaB/transformations_testing/pynxtools/src/pynxtools/nexus/nexus.py", line 59, in get_nx_class_path
    get_nx_class_path(get_hdf_info_parent(hdf_info))
TypeError: can only concatenate str (not "numpy.bytes_") to str
rettigl commented 2 months ago

Solved via #428