Skip to content

Commit

Permalink
Add getStartingPositionnersGroup function
Browse files Browse the repository at this point in the history
  • Loading branch information
mspito committed Aug 29, 2024
1 parent 55ae83c commit add44bb
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
22 changes: 22 additions & 0 deletions src/PyMca5/PyMcaCore/NexusTools.py
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,28 @@ def getPositionersGroup(h5file, path):
positioners = group
return positioners

def getStartingPositionersGroup(h5file, path):
"""
Retrieve the start positioners group associated to a path
retrieving them from the same entry.
It assumes they are either in:
- NXentry/NXinstrument/positioners_start or
"""
entry_path = getEntryName(path, h5file=h5file)
instrument = getNXClassGroups(h5file, entry_path, ["NXinstrument", b"NXinstrument"], single=True)
positioners = None
if len(instrument):
instrument = instrument[0]
for key in instrument.keys():
if key in ["positioners_start", b"positioners_start"]:
positioners = instrument[key]
if not isGroup(positioners):
positioners = None
return positioners

def getMeasurementGroup(h5file, path):
"""
Retrieve the measurement group associated to a path
Expand Down
4 changes: 3 additions & 1 deletion src/PyMca5/PyMcaGui/io/hdf5/NexusInfo.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import h5py

from PyMca5.PyMcaGui import PyMcaQt as qt
from PyMca5.PyMcaCore.NexusTools import getStartingPositionersGroup

from . import HDF5Info


Expand Down Expand Up @@ -94,7 +96,7 @@ def get_motor_positions(hdf5File, node):
if not isinstance(nxentry, h5py.Group):
return dict()

nxpositioners = nxentry.get("instrument/positioners_start", None)
nxpositioners = getStartingPositionersGroup(hdf5File, nxentry_name)
if nxpositioners is None or not isinstance(nxpositioners, h5py.Group):
return dict()

Expand Down

0 comments on commit add44bb

Please sign in to comment.