Skip to content

storing wrong alternative name as local data #40

@DanPorter

Description

@DanPorter

When evaluating a string from a nexus file using the alternative names expression, the wrong name is stored, resulting in future evaluations taking the incorrect value.

For example:

import hdfmap

f1 = '/dls/i16/data/2025/cm40634-15/1114142.nxs'
f2 = '/dls/i16/data/2025/cm40634-15/1114141.nxs'

m = hdfmap.create_nexus_map(f1)

with hdfmap.load_hdf(f1) as nxs:
    scan_command1 = m.get_data(nxs, 'scan_command')
    cmd1 = m.eval(nxs, '(cmd|scan_command)')
    path1 = m.eval(nxs, '_(cmd|scan_command)')
    print(f"Scan command1: {scan_command1}")
    print(f"         cmd1: {cmd1}")
    print(f"        path1: {path1}")
    print(f"'{path1}' in f2: {path1 in nxs}")
print(m._local_data)
with hdfmap.load_hdf(f2) as nxs:
    scan_command2 = m.get_data(nxs, 'scan_command')
    cmd2 = m.eval(nxs, '(cmd|scan_command)')
    path2 = m.eval(nxs, '_(cmd|scan_command)')
    print(f"Scan command2: {scan_command2}")
    print(f"         cmd2: {cmd2}")
    print(f"        path2: {path2}")
    print(f"'{path2}' in f2: {path2 in nxs}")

Results:

Scan command1: scan stokes_fly (0,5.0,10.0,15.0,20.0,25.0) xmapMca 10 pil3_100k 10
         cmd1: flyscan stokes 0 30 5 xmapMca 10 pil3_100k 10
        path1: /entry/user_input/cmd
'/entry/user_input/cmd' in f2: True
{'cmd': 'flyscan stokes 0 30 5 xmapMca 10 pil3_100k 10', 'filepath': '/dls/i16/data/2025/cm40634-15/1114142.nxs', 'filename': '1114142.nxs', '_cmd': '/entry/user_input/cmd'}
Scan command2: scan stokes 30 0 5 xmapMca 10 pil3_100k 10
         cmd2: flyscan stokes 0 30 5 xmapMca 10 pil3_100k 10
        path2: /entry/user_input/cmd
'/entry/user_input/cmd' in f2: False

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions