Commit 142fc36e authored by payno's avatar payno
Browse files

[process][register_processing] group results into a 'results' group

rename parameter 'data' in 'write_xas_proc' to 'results'
parent f9d9b79d
Pipeline #39326 passed with stages
in 8 minutes and 24 seconds
......@@ -192,7 +192,7 @@ class Process(object):
_data[key] = res
else:
raise ValueError()
xas_obj.register_processing(process=self, data=_data)
xas_obj.register_processing(process=self, results=_data)
def addCallback(self, callback):
self._callbacks.append(callback)
......@@ -452,14 +452,14 @@ class XASObject(object):
self.__processing_index += 1
return self.__processing_index
def register_processing(self, process, data) -> None:
def register_processing(self, process, results) -> None:
"""
Register one process for the current xas object. This require to having
link a h5file to this object
:param process: process to be registred
:type: :class:`.Process`
:param data: result of the processing. If there is more than one
:param results: result of the processing. If there is more than one
result then a dictionary with the key under which result
should be saved and a numpy.ndarray
:type: Union[numpy.ndarray,dict]
......@@ -469,7 +469,7 @@ class XASObject(object):
entry=self.__entry_name,
processing_order=self.get_next_processing_index(),
process=process,
data=data,
results=results,
overwrite=True,
)
......
......@@ -538,8 +538,12 @@ class _QDimComboBox(qt.QComboBox):
self.addItem(Dim.Z_DIM.value)
def setDim(self, dim):
dim = Dim.from_value(dim)
assert dim in (Dim.X_DIM, Dim.Y_DIM, Dim.Z_DIM)
try:
dim = Dim.from_value(dim)
except Exception as e:
_logger.warning(e)
dim = Dim.X_DIM
index = self.findText(dim.value)
assert index >= 0
self.setCurrentIndex(index)
......
......@@ -242,7 +242,7 @@ def read_xas(
def write_xas_proc(
h5_file, entry, process, data, processing_order, data_path="/", overwrite=True
h5_file, entry, process, results, processing_order, data_path="/", overwrite=True
):
"""
Write a xas :class:`.Process` into .h5
......@@ -251,7 +251,7 @@ def write_xas_proc(
:param str entry: entry name
:param process: process executed
:type: :class:`.Process`
:param data: process result data
:param results: process result data
:type: numpy.ndarray
:param processing_order: processing order of treatment
:type: int
......@@ -289,10 +289,10 @@ def write_xas_proc(
nx_data.attrs["signal"] = "data"
nx_process_path = nx_process.name
if isinstance(data, numpy.ndarray):
data_ = {"data": data}
if isinstance(results, numpy.ndarray):
data_ = {"data": results}
else:
data_ = data
data_ = results
def get_interpretation(my_data):
"""Return hdf5 attribute for this type of data"""
......@@ -326,7 +326,8 @@ def write_xas_proc(
nx_process[key_path].attrs["interpretation"] = interpretation
for key, value in data_.items():
save_key(key_path=key, value=value)
key_path = "/".join(("results", key))
save_key(key_path=key_path, value=value)
if process.getConfiguration() is not None:
h5_path = "/".join((nx_process_path, "configuration"))
......@@ -513,7 +514,7 @@ if __name__ == "__main__":
h5_file=h5_file,
entry="scan1",
process=process_norm,
data=process_data,
results=process_data,
processing_order=1,
)
process_exafs = PyMca_exafs()
......@@ -522,6 +523,6 @@ if __name__ == "__main__":
h5_file=h5_file,
entry="scan1",
process=process_exafs,
data=process_data2,
results=process_data2,
processing_order=2,
)
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