Commit b919d547 authored by Julia Garriga Ferrer's avatar Julia Garriga Ferrer
Browse files

[core][dataset] Modify dimension values to be adictionary with key the dimensions names

parent 9a0ccab7
...@@ -89,7 +89,7 @@ class Dataset(qt.QObject): ...@@ -89,7 +89,7 @@ class Dataset(qt.QObject):
self.dark_filename = dark_filename self.dark_filename = dark_filename
self.filenames = filenames self.filenames = filenames
self.__dims = AcquisitionDims() self.__dims = AcquisitionDims()
self._dimensions_values = None self._dimensions_values = {}
# Initialize data # Initialize data
self._file_series = fabio.open_series(first_filename=raw_filename, self._file_series = fabio.open_series(first_filename=raw_filename,
...@@ -325,7 +325,7 @@ class Dataset(qt.QObject): ...@@ -325,7 +325,7 @@ class Dataset(qt.QObject):
unique values. unique values.
""" """
self.__dims.clear() self.__dims.clear()
self._dimensions_values = None self._dimensions_values = {}
keys = numpy.array(list(self.metadata[0].get_keys(kind))) keys = numpy.array(list(self.metadata[0].get_keys(kind)))
values = numpy.array([[data.get_value(kind=kind, name=key)[0] for data values = numpy.array([[data.get_value(kind=kind, name=key)[0] for data
...@@ -357,18 +357,17 @@ class Dataset(qt.QObject): ...@@ -357,18 +357,17 @@ class Dataset(qt.QObject):
:returns: array_like :returns: array_like
""" """
if self._dimensions_values is None: if not self._dimensions_values:
data = self.metadata data = self.metadata
# Use only metadata of high intensity data # Use only metadata of high intensity data
if self._filter_data: if self._filter_data:
data = numpy.array(self.metadata)[self.threshold] data = numpy.array(self.metadata)[self.threshold]
values = numpy.empty((self.__dims.ndim, len(data))) for dimension in self.__dims:
for row, metadata_frame in enumerate(data): values = numpy.empty((len(data)))
for dimension in self.__dims: for row, metadata_frame in enumerate(data):
val = metadata_frame.get_value(kind=dimension[1].kind, name=dimension[1].name) values[row] = (metadata_frame.get_value(kind=dimension[1].kind,
values[dimension[0]][row] = val[0] name=dimension[1].name)[0])
self._dimensions_values[dimension[1].name] = values
self._dimensions_values = values
return self._dimensions_values return self._dimensions_values
def __deepcopy__(self, memo): def __deepcopy__(self, memo):
......
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