Commit f96da673 authored by Thomas Vincent's avatar Thomas Vincent
Browse files

Only returns 1D dataset as normalizers

parent 7e07a8ae
......@@ -250,29 +250,28 @@ class XsocsH5(XsocsH5Base):
@_process_entry
def normalizers(self, entry):
"""Returns dataset in measurement that might be used to normalize data
"""Returns names of dataset in measurement that can be used to normalize data
It returns names of scalar values and 1D datasets with same number
of elements as images that are available in the measurement group
It returns names of 1D datasets with same number of elements as images
that are available in the measurement group.
:return: Dictionary of {name: data} that might be normalizers
:rtype: collections.OrderedDict
:return: List of dataset names in measurement that might be normalizers
:rtype: List[str]
"""
normalizers = OrderedDict()
normalizers = []
nb_images = self.n_images(entry)
path = self.measurement_tpl.format(entry) + '/'
with self._get_file() as h5_file:
for name, node in h5_file[path].items():
if isinstance(node, _h5py.Dataset) and node.dtype.kind in 'iuf':
if (isinstance(node, _h5py.Dataset) and
node.dtype.kind in 'iuf' and
node.ndim == 1 and
node.shape[0] == nb_images):
# Only get (u)int and float datasets
if node.ndim == 0:
# single scalar, make an array of it
normalizers[name] = _np.array([node[()]] * nb_images)
elif node.ndim == 1 and node.shape[0] == nb_images:
# same number of values as number of images
normalizers[name] = node[()]
# with same number of values as number of images
normalizers.append(name)
return normalizers
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment