Commit 339eb267 authored by Henri Payno's avatar Henri Payno
Browse files

[larch] normalize mback and mback_norm

parent 7bdd85d0
Pipeline #13323 failed with stage
in 4 minutes and 35 seconds
......@@ -38,50 +38,15 @@ from silx.gui.plot import LegendSelector
import xas.core.process.larch.mback
from orangecontrib.xas.process import _ProcessForOrangeMixIn
from orangecontrib.xas.process import ProcessRunnable
from xas.core.types import XASObject, Spectrum
from xas.gui.XasObjectViewer import XasObjectViewer, _CurveOperation, ViewType
from xas.core.types import XASObject
from xas.gui.XasObjectViewer import XasObjectViewer, ViewType
from xas.gui.larch.mback import _MBackParameters
from orangecontrib.xas.progress import QProgress
from xas.gui.XasObjectViewer import _plot_norm, _plot_raw, _plot_fpp, _plot_f2
_logger = logging.getLogger(__file__)
def _plot_raw(spectrum):
assert isinstance(spectrum, Spectrum)
if spectrum.mu is None:
_logger.error('mu not existing')
return
return _CurveOperation(x=spectrum.energy, y=spectrum.mu,
legend='raw spectrum', color='grey')
def _plot_norm(spectrum):
assert isinstance(spectrum, Spectrum)
if spectrum.norm is None:
_logger.error('norm not computed')
return
return _CurveOperation(x=spectrum.energy, y=spectrum.norm,
legend='norm spectrum', color='blue')
def _plot_fpp(spectrum):
assert isinstance(spectrum, Spectrum)
if not hasattr(spectrum, 'fpp'):
_logger.error('fpp has not been computed yet')
return
return _CurveOperation(x=spectrum.energy, y=spectrum.fpp, legend='fpp',
color='red')
def _plot_f2(spectrum):
assert isinstance(spectrum, Spectrum)
if not hasattr(spectrum, 'f2'):
_logger.error('f2 has not been computed yet')
return
return _CurveOperation(x=spectrum.energy, y=spectrum.f2, legend='f2',
color='orange')
class MbackWindow(qt.QMainWindow):
def __init__(self, parent=None):
qt.QMainWindow.__init__(self, parent)
......
......@@ -38,31 +38,15 @@ from silx.gui.plot import LegendSelector
import xas.core.process.larch.mback_norm
from orangecontrib.xas.process import _ProcessForOrangeMixIn
from orangecontrib.xas.process import ProcessRunnable
from xas.core.types import XASObject, Spectrum
from xas.gui.XasObjectViewer import XasObjectViewer, _CurveOperation, ViewType
from xas.core.types import XASObject
from xas.gui.XasObjectViewer import XasObjectViewer, ViewType
from xas.gui.XasObjectViewer import _plot_norm, _plot_raw, _plot_fpp, _plot_f2
from xas.gui.larch.mback import _MBackParameters
from orangecontrib.xas.progress import QProgress
_logger = logging.getLogger(__file__)
def _plot_fpp(spectrum):
assert isinstance(spectrum, Spectrum)
if not hasattr(spectrum, 'fpp'):
_logger.error('fpp has not been computed yet')
return
return _CurveOperation(x=spectrum.energy, y=spectrum.fpp, legend='fpp')
def _plot_f2(spectrum):
assert isinstance(spectrum, Spectrum)
if not hasattr(spectrum, 'f2'):
_logger.error('f2 has not been computed yet')
return
return _CurveOperation(x=spectrum.energy, y=spectrum.f2, legend='f2')
class Mback_normWindow(qt.QMainWindow):
def __init__(self, parent=None):
qt.QMainWindow.__init__(self, parent)
......@@ -93,7 +77,7 @@ class Mback_normWindow(qt.QMainWindow):
self.xasObjViewer._mapView.keySelectionDocker)
# plot settings
for ope in (_plot_fpp, _plot_f2):
for ope in (_plot_fpp, _plot_f2, _plot_raw, _plot_norm):
self.xasObjViewer._spectrumViews[0].addCurveOperation(ope)
self.setWindowFlags(qt.Qt.Widget)
......@@ -115,7 +99,7 @@ class Mback_normOW(_ProcessForOrangeMixIn, OWWidget):
Widget used for signal extraction
"""
name = "mback norm"
id = "orange.widgets.xas.larch.mback_norm"
id = "orange.widgets.xas.larch.mback.Mback_normOW"
description = "simplified version of MBACK to Match mu(E) data for " \
"tabulated f''(E) for normalization"
icon = "icons/mback_norm.svg"
......
......@@ -114,10 +114,9 @@ class Larch_mback_norm(Process):
self._advancement.startProcess()
self._pool_process(xas_obj=_xas_obj)
self._advancement.endProcess()
data_keys = ["mback_mu", "edge_step_poly", "edge_step_mback",
"norm_mback"]
data_keys = ["mback_mu", "norm_mback"]
if _xas_obj.n_spectrum > 0 and hasattr(_xas_obj.spectra[0], 'edge_step'):
data_keys += ['edge_step', 'norm']
data_keys += ['norm']
self.register_process(_xas_obj, data_keys=data_keys)
return _xas_obj
......
......@@ -225,6 +225,7 @@ class XASObject(object):
value = spectrum[subkeys[0]]
for subkey in subkeys[1:]:
value = value[subkey]
assert len(value) == array.shape[0]
array[:, i_spectrum] = value
return array.reshape((len(getattr(spectra[0], relative_to)),
......
......@@ -386,4 +386,31 @@ def _plot_edge(spectrum):
if not hasattr(spectrum, 'e0'):
_logger.error('e0 has not been computed yet')
return
return _XMarkerOperation(x=spectrum.e0, legend='edge', color='yellow')
\ No newline at end of file
return _XMarkerOperation(x=spectrum.e0, legend='edge', color='yellow')
def _plot_raw(spectrum):
assert isinstance(spectrum, Spectrum)
if spectrum.mu is None:
_logger.error('mu not existing')
return
return _CurveOperation(x=spectrum.energy, y=spectrum.mu,
legend='raw spectrum', color='grey')
def _plot_fpp(spectrum):
assert isinstance(spectrum, Spectrum)
if not hasattr(spectrum, 'fpp'):
_logger.error('fpp has not been computed yet')
return
return _CurveOperation(x=spectrum.energy, y=spectrum.fpp, legend='fpp',
color='red')
def _plot_f2(spectrum):
assert isinstance(spectrum, Spectrum)
if not hasattr(spectrum, 'f2'):
_logger.error('f2 has not been computed yet')
return
return _CurveOperation(x=spectrum.energy, y=spectrum.f2, legend='f2',
color='orange')
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