Commit 253ff75d authored by payno's avatar payno
Browse files

[plot] move ft plot to XasOnjectViewer

parent 62f3a148
......@@ -44,77 +44,17 @@ from silx.gui.plot import LegendSelector
import xas.core.process.pymca.ft
from orangecontrib.xas.process import _ProcessForOrangeMixIn, \
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 _normalized_exafs, _ft_window_plot
from xas.gui.XasObjectViewer import _ft_intensity_plot, _ft_imaginary_plot
from orangecontrib.xas.progress import QProgress
from orangecontrib.xas.utils import Converter
_logger = logging.getLogger(__file__)
def _normalized_exafs(spectrum):
assert isinstance(spectrum, Spectrum)
missing_keys = spectrum.get_missing_keys(('EXAFSKValues', 'EXAFSNormalized'))
if missing_keys:
_logger.error('missing keys:', missing_keys,
'unable to compute normalized EXAFS')
return None
if spectrum["KWeight"]:
if spectrum["KWeight"] == 1:
ylabel = "EXAFS Signal * k"
else:
ylabel = "EXAFS Signal * k^%d" % spectrum["KWeight"]
else:
ylabel = "EXAFS Signal"
idx = (spectrum["EXAFSKValues"] >= spectrum["KMin"]) & \
(spectrum["EXAFSKValues"] <= spectrum["KMax"])
return _CurveOperation(x=spectrum["EXAFSKValues"][idx],
y=spectrum["EXAFSNormalized"][idx],
legend="Normalized EXAFS",
ylabel=ylabel)
def _ft_window_plot(spectrum):
assert isinstance(spectrum, Spectrum)
missing_keys = spectrum.ft.get_missing_keys(('K', 'WindowWeight'))
if missing_keys:
_logger.error('missing keys:', missing_keys,
'unable to compute normalized EXAFS')
return None
return _CurveOperation(x=spectrum.ft['K'],
y=spectrum.ft["WindowWeight"],
legend="FT Window",
yaxis="right",
color="red")
def _ft_intensity_plot(spectrum):
assert isinstance(spectrum, Spectrum)
missing_keys = spectrum.ft.get_missing_keys(('FTRadius', 'FTIntensity'))
if missing_keys:
_logger.error('missing keys:', missing_keys, 'unable to compute spectrum plot')
return
return _CurveOperation(x=spectrum.ft['FTRadius'],
y=spectrum.ft['FTIntensity'],
legend="FT Intensity")
def _ft_imaginary_plot(spectrum):
assert isinstance(spectrum, Spectrum)
missing_keys = spectrum.ft.get_missing_keys(('FTRadius', 'FTImaginary'))
if missing_keys:
_logger.error('missing keys:', missing_keys, 'unable to compute spectrum plot')
return
return _CurveOperation(x=spectrum.ft['FTRadius'],
y=spectrum.ft['FTImaginary'],
legend="FT Imaginary",
color="red")
class FTWindow(qt.QMainWindow):
def __init__(self, parent=None):
qt.QMainWindow.__init__(self, parent)
......
......@@ -564,54 +564,120 @@ def _plot_knots(obj, **kwargs):
yaxis=None, color='green', linestyle="", symbol="o")
def _exafs_signal_plot(spectrum, **kwargs):
if not isinstance(spectrum, Spectrum):
def _exafs_signal_plot(obj, **kwargs):
if not isinstance(obj, Spectrum):
return None
missing_keys = spectrum.get_missing_keys(('EXAFSKValues', 'EXAFSSignal'))
missing_keys = obj.get_missing_keys(('EXAFSKValues', 'EXAFSSignal'))
if missing_keys:
_logger.error('missing keys:', missing_keys, 'unable to compute exafs signal plot')
return
k = spectrum["EXAFSKValues"]
if "KMin" not in spectrum:
spectrum["KMin"] = k.min()
if "KMax" not in spectrum:
spectrum["KMax"] = k.max()
idx = (spectrum["EXAFSKValues"] >= spectrum["KMin"]) & \
(spectrum["EXAFSKValues"] <= spectrum["KMax"])
x = spectrum["EXAFSKValues"][idx]
y = spectrum["EXAFSSignal"][idx]
k = obj["EXAFSKValues"]
if "KMin" not in obj:
obj["KMin"] = k.min()
if "KMax" not in obj:
obj["KMax"] = k.max()
idx = (obj["EXAFSKValues"] >= obj["KMin"]) & \
(obj["EXAFSKValues"] <= obj["KMax"])
x = obj["EXAFSKValues"][idx]
y = obj["EXAFSSignal"][idx]
return _CurveOperation(x=x, y=y, legend="EXAFSSignal")
def _exafs_postedge_plot(spectrum, **kwargs):
if not isinstance(spectrum, Spectrum):
def _exafs_postedge_plot(obj, **kwargs):
if not isinstance(obj, Spectrum):
return None
missing_keys = spectrum.get_missing_keys(('EXAFSKValues', 'PostEdgeB'))
missing_keys = obj.get_missing_keys(('EXAFSKValues', 'PostEdgeB'))
if missing_keys:
_logger.error('missing keys:', missing_keys, 'unable to compute exafs postedge plot')
return
k = spectrum["EXAFSKValues"]
if "KMin" not in spectrum:
spectrum["KMin"] = k.min()
if "KMax" not in spectrum:
spectrum["KMax"] = k.max()
k = obj["EXAFSKValues"]
if "KMin" not in obj:
obj["KMin"] = k.min()
if "KMax" not in obj:
obj["KMax"] = k.max()
idx = (spectrum["EXAFSKValues"] >= spectrum["KMin"]) & \
(spectrum["EXAFSKValues"] <= spectrum["KMax"])
idx = (obj["EXAFSKValues"] >= obj["KMin"]) & \
(obj["EXAFSKValues"] <= obj["KMax"])
x = spectrum["EXAFSKValues"][idx]
y = spectrum["PostEdgeB"][idx]
x = obj["EXAFSKValues"][idx]
y = obj["PostEdgeB"][idx]
return _CurveOperation(x=x, y=y, legend="PostEdge")
def _exafs_knots_plot(spectrum, **kwargs):
if not isinstance(spectrum, Spectrum):
def _exafs_knots_plot(obj, **kwargs):
if not isinstance(obj, Spectrum):
return None
missing_keys = spectrum.get_missing_keys(('KnotsX', 'KnotsY'))
missing_keys = obj.get_missing_keys(('KnotsX', 'KnotsY'))
if missing_keys:
_logger.error('missing keys:', missing_keys, 'unable to compute exafs knot plot')
return
x = spectrum["KnotsX"]
y = spectrum["KnotsY"]
x = obj["KnotsX"]
y = obj["KnotsY"]
return _CurveOperation(x=x, y=y, legend="Knots", linestyle="", symbol="o")
def _normalized_exafs(obj, **kwargs):
if not isinstance(obj, Spectrum):
return None
assert isinstance(obj, Spectrum)
missing_keys = obj.get_missing_keys(('EXAFSKValues', 'EXAFSNormalized'))
if missing_keys:
_logger.error('missing keys:', missing_keys,
'unable to compute normalized EXAFS')
return None
if obj["KWeight"]:
if obj["KWeight"] == 1:
ylabel = "EXAFS Signal * k"
else:
ylabel = "EXAFS Signal * k^%d" % obj["KWeight"]
else:
ylabel = "EXAFS Signal"
idx = (obj["EXAFSKValues"] >= obj["KMin"]) & \
(obj["EXAFSKValues"] <= obj["KMax"])
return _CurveOperation(x=obj["EXAFSKValues"][idx],
y=obj["EXAFSNormalized"][idx],
legend="Normalized EXAFS",
ylabel=ylabel)
def _ft_window_plot(obj, **kwargs):
if not isinstance(obj, Spectrum):
return None
missing_keys = obj.ft.get_missing_keys(('K', 'WindowWeight'))
if missing_keys:
_logger.error('missing keys:', missing_keys,
'unable to compute normalized EXAFS')
return None
return _CurveOperation(x=obj.ft['K'],
y=obj.ft["WindowWeight"],
legend="FT Window",
yaxis="right",
color="red")
def _ft_intensity_plot(obj, **kwargs):
assert isinstance(obj, Spectrum)
missing_keys = obj.ft.get_missing_keys(('FTRadius', 'FTIntensity'))
if missing_keys:
_logger.error('missing keys:', missing_keys, 'unable to compute spectrum plot')
return
return _CurveOperation(x=obj.ft['FTRadius'],
y=obj.ft['FTIntensity'],
legend="FT Intensity")
def _ft_imaginary_plot(obj, **kwargs):
assert isinstance(obj, Spectrum)
missing_keys = obj.ft.get_missing_keys(('FTRadius', 'FTImaginary'))
if missing_keys:
_logger.error('missing keys:', missing_keys, 'unable to compute spectrum plot')
return
return _CurveOperation(x=obj.ft['FTRadius'],
y=obj.ft['FTImaginary'],
legend="FT Imaginary",
color="red")
\ No newline at end of file
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