Commit 0c962c23 authored by Henri Payno's avatar Henri Payno
Browse files

[xasobject] update relative to the fact _spectra_volume now manage pymca and larch properties

parent c0dd740e
......@@ -78,7 +78,7 @@ class AutobkWindow(qt.QMainWindow):
qt.QMainWindow.__init__(self, parent)
# xas object viewer
mapKeys = ['Mu', 'bkg', 'chie', 'k', 'chi', 'e0']
mapKeys = ['mu', 'bkg', 'chie', 'k', 'chi', 'e0']
self.xasObjViewer = XasObjectViewer(mapKeys=mapKeys)
self.xasObjViewer._spectrumViews[0]._plot.getXAxis().setLabel("Energy (eV)")
self.xasObjViewer._spectrumViews[0]._plot.getYAxis().setLabel("Absorption (a.u.)")
......
......@@ -54,7 +54,7 @@ class MbackWindow(qt.QMainWindow):
qt.QMainWindow.__init__(self, parent)
# xas object viewer
mapKeys = ['Mu', 'fpp', 'f2']
mapKeys = ['mu', 'fpp', 'f2']
self.xasObjViewer = XasObjectViewer(mapKeys=mapKeys)
self.xasObjViewer._spectrumViews[0]._plot.getXAxis().setLabel("Energy (eV)")
self.setCentralWidget(self.xasObjViewer)
......
......@@ -54,7 +54,7 @@ class Mback_normWindow(qt.QMainWindow):
qt.QMainWindow.__init__(self, parent)
# xas object viewer
mapKeys = ['Mu', 'fpp', 'f2']
mapKeys = ['mu', 'mback_mu', 'norm']
self.xasObjViewer = XasObjectViewer(mapKeys=mapKeys)
self.xasObjViewer._spectrumViews[0]._plot.getXAxis().setLabel("Energy (eV)")
self.setCentralWidget(self.xasObjViewer)
......
......@@ -56,7 +56,7 @@ class _PreEdgeWindow(qt.QMainWindow):
qt.QMainWindow.__init__(self, parent)
# xas object viewer
mapKeys = ['Mu', 'norm', 'norm_area']
mapKeys = ['mu', 'norm', 'norm_area']
self.xasObjViewer = XasObjectViewer(mapKeys=mapKeys)
self.xasObjViewer._spectrumViews[0]._plot.getXAxis().setLabel("Energy (eV)")
self.setCentralWidget(self.xasObjViewer)
......
......@@ -102,7 +102,7 @@ class MbackWindow(qt.QMainWindow):
qt.QMainWindow.__init__(self, parent)
# xas object viewer
mapKeys = ['Mu', 'chir', 'chir_mag', 'chir_re', 'chir_im', 'chir_pha']
mapKeys = ['mu', 'chir', 'chir_mag', 'chir_re', 'chir_im', 'chir_pha']
self.xasObjViewer = XasObjectViewer(mapKeys=mapKeys)
self.xasObjViewer._spectrumViews[0]._plot.getXAxis().setLabel("Energy (eV)")
self.setCentralWidget(self.xasObjViewer)
......
......@@ -102,8 +102,8 @@ def _exafs_knots_plot(spectrum):
class ExafsWindow(qt.QMainWindow):
def __init__(self, parent=None):
qt.QMainWindow.__init__(self, parent)
mapKeys = ['Mu', 'EXAFS/EXAFSKValues', 'EXAFS/EXAFSSignal',
'EXAFS/PostEdgeB']
mapKeys = ['mu', 'EXAFS.EXAFSKValues', 'EXAFS.EXAFSSignal',
'EXAFS.PostEdgeB']
self.xasObjViewer = XasObjectViewer(mapKeys=mapKeys)
self.xasObjViewer._spectrumViews[0]._plot.getXAxis().setLabel("K")
self.xasObjViewer._spectrumViews[0]._plot.getYAxis().setLabel("Normalized Units")
......
......@@ -55,7 +55,7 @@ class NormalizationWindow(qt.QMainWindow):
qt.QMainWindow.__init__(self, parent)
# xas object viewer
mapKeys = ['Mu', 'NormalizedMu', 'NormalizedSignal', 'NormalizedBackground']
mapKeys = ['mu', 'NormalizedMu', 'NormalizedSignal', 'NormalizedBackground']
self.xasObjViewer = XasObjectViewer(mapKeys=mapKeys)
self.xasObjViewer._spectrumViews[0]._plot.getXAxis().setLabel("Energy (eV)")
self.xasObjViewer._spectrumViews[0]._plot.getYAxis().setLabel("Absorption (a.u.)")
......
......@@ -113,8 +113,7 @@ class Larch_autobk(Process):
self._pool_process(xas_obj=_xas_obj)
self._advancement.endProcess()
self.register_process(_xas_obj,
data_keys=('bkg', 'chie', 'k', 'chi', 'e0',
'autobk_details'))
data_keys=('bkg', ))
return _xas_obj
def _pool_process(self, xas_obj):
......
......@@ -112,8 +112,7 @@ class Larch_mback(Process):
self._advancement.startProcess()
self._pool_process(xas_obj=_xas_obj)
self._advancement.endProcess()
self.register_process(_xas_obj, data_keys=("fpp",
"f2"))
self.register_process(_xas_obj, data_keys=("fpp", "f2"))
return _xas_obj
def _pool_process(self, xas_obj):
......
......@@ -112,9 +112,7 @@ class Larch_pre_edge(Process):
self.register_process(_xas_obj,
data_keys=('flat', 'dmude', 'edge_step_poly',
'norm', 'norm_area', 'post_edge',
'edge', 'pre_edge_details', 'e0',
'atsym', 'edge_step_area', 'edge_step',
'norm_poly', 'pre_edge'))
'pre_edge_details', 'e0'))
return _xas_obj
def _pool_process(self, xas_obj):
......
......@@ -111,8 +111,8 @@ class Larch_xftf(Process):
self._pool_process(xas_obj=_xas_obj)
self._advancement.endProcess()
self.register_process(_xas_obj,
data_keys=('chir_im', 'chir_re', 'chir_mag', 'r'),
relative_to='r')
data_keys=('chir_im', 'chir_re', 'chir_mag',
'r'))
return _xas_obj
def _pool_process(self, xas_obj):
......
......@@ -93,7 +93,7 @@ class Process(object):
else:
return None
def register_process(self, xas_obj, data_keys, relative_to='energy'):
def register_process(self, xas_obj, data_keys):
"""
Store the current process in the linked h5 file if any,
output data stored will be the one defined by the data_keys
......@@ -106,6 +106,15 @@ class Process(object):
if xas_obj.has_linked_file():
_data = {}
for key in data_keys:
relative_to = None
if key in ('flat', 'fpp', 'f2', 'dmude', 'norm', 'norm_area',
'post_edge', 'bkg', 'energy', 'mback_mu',
'norm_mback', 'Energy', 'Mu', "NormalizedEnergy",
"NormalizedMu", "NormalizedSignal", "EXAFSKValues",
"EXAFSSignal"):
relative_to = 'energy'
elif key in ('chir_re', 'chir_im', 'chir_mag', 'r'):
relative_to = 'r'
try:
_data[key] = XASObject._spectra_volume(xas_obj.spectra,
key=key,
......@@ -113,5 +122,6 @@ class Process(object):
dim_2=xas_obj.dim2,
relative_to=relative_to)
except KeyError:
pass
mess = '%s: unable to store %s, parameter not found' % (self.name, key)
_logger.error(mess)
xas_obj.register_processing(process=self, data=_data)
......@@ -158,9 +158,9 @@ class PyMca_ft(Process):
self._advancement.startProcess()
self._pool_process(xas_obj=_xas_obj)
self._advancement.endProcess()
self.register_process(_xas_obj, data_keys=("FTRadius",
"FTIntensity",
"FTImaginary"))
self.register_process(_xas_obj, data_keys=("ft.FTRadius",
"ft.FTIntensity",
"ft.FTImaginary"))
return _xas_obj
def _pool_process(self, xas_obj):
......
......@@ -139,8 +139,8 @@ class PyMca_normalization(Process):
self._pool_process(xas_obj=_xas_obj)
self._advancement.endProcess()
self.register_process(_xas_obj, data_keys=("NormalizedEnergy",
"NormalizedMu",
"NormalizedSignal"))
"NormalizedMu",
"NormalizedSignal"))
return _xas_obj
def _pool_process(self, xas_obj):
......
......@@ -68,7 +68,7 @@ class TestRoi(unittest.TestCase):
def testApplyRoi(self):
"""Test output of the roi process"""
original_spectra = self.xas_obj._spectra_volume(spectra=self.xas_obj.spectra,
key='Mu',
key='mu',
dim_1=self.xas_obj.dim1,
dim_2=self.xas_obj.dim2).copy()
assert original_spectra.shape == (16, 100, 30)
......@@ -77,7 +77,7 @@ class TestRoi(unittest.TestCase):
res_xas_obj = xas_roi(self.xas_obj)
self.assertEqual(res_xas_obj.n_spectrum, 20*10)
reduces_spectra = res_xas_obj._spectra_volume(spectra=res_xas_obj.spectra,
key='Mu',
key='mu',
dim_1=res_xas_obj.dim1,
dim_2=res_xas_obj.dim2).copy()
assert reduces_spectra.shape == (16, 20, 10)
......
......@@ -194,7 +194,7 @@ class XASObject(object):
res = {
'configuration': self.configuration,
'spectra': XASObject._spectra_volume(spectra=self.spectra,
key='Mu',
key='mu',
dim_1=self.dim1,
dim_2=self.dim2),
'energy': self.energy,
......@@ -217,7 +217,7 @@ class XASObject(object):
def absorbed_beam(self):
return XASObject._spectra_volume(spectra=self.spectra,
key='Mu',
key='mu',
dim_1=self.dim1,
dim_2=self.dim2)
......@@ -444,7 +444,8 @@ class XASObject(object):
recognized_process = xas.io.get_xasproc(self.linked_h5_file,
entry=self.__entry_name)
know_process = ('pymca_normalization', 'pymca_exafs', 'pymca_ft',
'pymca_k_weight')
'pymca_k_weight', 'larch_autobk', 'larch_mback',
'larch_mback_norm', 'larch_pre_edge', 'larch_xftf')
def filter_recognized_process(process_list):
res = []
......
......@@ -47,7 +47,7 @@ class ROISelector(qt.QWidget):
self.setLayout(qt.QVBoxLayout())
# TODO: if data starts to be quiet large then we can load only part of
# if. There is some code to do this on tomwer.
self._xas_object_map = MapViewer(keys=['Mu',])
self._xas_object_map = MapViewer(keys=['mu',])
self.layout().addWidget(self._xas_object_map)
self._plot = self._xas_object_map.getPlot()
......
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