Skip to content

Handle scans with @signal specified as 2D image #29

@DanPorter

Description

@DanPorter

Example file:
/dls/i06/data/2026/cm44142-2/i06-369302.nxs

cmd scan t 1 1 1 medipix 1
@axes /entry/medipix/t
@signal /entry/medipix/data
detector medipix
@axes shape (1, )
@signal shape (512, 512)

Currently scan.get_plot_data fails when reading:

scan.get_plot_axis("signal")
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
Cell In[10], line 1
----> 1 scan.get_plot_axis("signal")

File /dls_sw/apps/mmg_toolbox/latest/mmg_toolbox/mmg_toolbox/nexus/nexus_scan.py:242, in NexusScan.get_plot_axis(self, axis_name, reduce_shape, flatten)
    230 """
    231 Return plot axis data and label for given axis name
    232 
   (...)
    239 :return: (data, label) tuple
    240 """
    241 with self.load_hdf() as hdf:
--> 242     return self._get_plot_axis(hdf, axis_name, reduce_shape=reduce_shape, flatten=flatten)

File /dls_sw/apps/mmg_toolbox/latest/mmg_toolbox/mmg_toolbox/nexus/nexus_scan.py:224, in NexusScan._get_plot_axis(self, hdf, axis_name, reduce_shape, flatten)
    222         data = np.sum(data, axis=(-1, -2))
    223     if np.shape(data) != shape:
--> 224         raise ValueError(f"2+D Arrays must have same shape: {axis_name}{np.shape(data)} != {shape}")
    225 if flatten:
    226     data = np.reshape(data, -1)

ValueError: 2+D Arrays must have same shape: signal(512, 512) != (1,)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions