Commit 716ec33c authored by Thomas Vincent's avatar Thomas Vincent
Browse files

Add method to get measurement dataset that might be used to normalize

parent 8bac60c2
......@@ -248,6 +248,34 @@ class XsocsH5(XsocsH5Base):
path = self.measurement_tpl.format(entry) + '/' + measurement
return self._get_array_data(path)
@_process_entry
def normalizers(self, entry):
"""Returns dataset in measurement that might 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
:return: Dictionary of {name: data} that might be normalizers
:rtype: collections.OrderedDict
"""
normalizers = OrderedDict()
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':
# 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[()]
return normalizers
@contextmanager
@_process_entry
def image_dset_ctx(self,
......
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