Commit 6fd0b898 authored by payno's avatar payno
Browse files

[process] update signature: remove xas_obj from the signature

parent 5cdb91b2
......@@ -100,7 +100,7 @@ class EnergyROIProcess(Process):
# print(xas_obj.__dict__)
return xas_obj
def run(self, xas_obj: Union[dict, XASObject] = None):
def run(self):
"""
:param xas_obj: object containing the configuration and spectra to process
......@@ -108,8 +108,9 @@ class EnergyROIProcess(Process):
:return: spectra dict
:rtype: :class:`.XASObject`
"""
xas_obj = self.inputs.xas_obj
if xas_obj is None:
xas_obj = self.inputs.xas_obj
raise ValueError("xas_obj should be provided")
_xas_obj = self.getXasObject(xas_obj=xas_obj)
# existing roi is priority. This is the case if called from pushworkflow
......
# coding: utf-8
# /*##########################################################################
#
# Copyright (c) 2016-2017 European Synchrotron Radiation Facility
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#
# ###########################################################################*/
__authors__ = ["H. Payno"]
__license__ = "MIT"
__date__ = "22/07/2021"
from ewokscore.task import Task
class IgnoreTask(Task):
def process(self):
print("*** ignore task {}".format(self))
class IgnoreOutput(Task):
"""Simple Ignore task when an input is provided but no output. Used
in the case of pure display widget.
..note: each OW should define it own task to insure a safe conversion to
ewoks
"""
class IgnoreInput(IgnoreTask):
_INPUT_NAMES = set([])
_OUTPUT_NAMES = set(["xas_obj"])
_INPUT_NAMES = set(["xas_obj"])
_OUTPUT_NAMES = set()
pass
# @staticmethod
# def registry_name():
# return "orangecontrib.est.widgets.utils.xas_input.XASInputOW"
#
class BlankTask(Task):
"""Simple black task which will copy received xas_obj from inputs to
outputs.
class IgnoreOrangeConversion(IgnoreTask):
pass
# @staticmethod
# def registry_name():
# return "orangecontrib.est.widgets.utils.converter.ConverterOW"
..note: each OW should define it own task to insure a safe conversion to
ewoks
"""
_INPUT_NAMES = set(["xas_obj"])
_OUTPUT_NAMES = set(["xas_obj"])
def run(self):
self.outputs.xas_obj = self.inputs.xas_obj
class IgnoreSavingPoint(IgnoreTask):
class IgnoreSavingPoint(BlankTask):
pass
# @staticmethod
# def registry_name():
# return "orangecontrib.est.widgets.utils.saving_point.SavingPointOW"
class IgnoreE0Calculation(IgnoreTask):
class IgnoreE0Calculation(BlankTask):
pass
# @staticmethod
# def registry_name():
# return "orangecontrib.est.widgets.utils.e0calculator.E0calculatorOW"
......@@ -104,6 +104,8 @@ class DumpXasObject(Process):
class ReadXasObject(Process):
_INPUT_NAMES = set()
_OUTPUT_NAMES = set(["xas_obj"])
def __init__(self, varinfo=None, **inputs):
......
......@@ -147,9 +147,10 @@ class Larch_autobk(Process):
if "_larchSettings" in properties:
self._settings = properties["_larchSettings"]
def run(self, xas_obj=None):
def run(self):
xas_obj = self.inputs.xas_obj
if xas_obj is None:
xas_obj = self.inputs.xas_obj
raise ValueError("xas_obj should be provided")
_xas_obj = self.getXasObject(xas_obj=xas_obj)
if self._settings:
_xas_obj.configuration["autobk"] = self._settings
......
......@@ -138,9 +138,10 @@ class Larch_mback(Process):
if "_larchSettings" in properties:
self._settings = properties["_larchSettings"]
def run(self, xas_obj=None):
def run(self):
xas_obj = self.inputs.xas_obj
if xas_obj is None:
xas_obj = self.inputs.xas_obj
raise ValueError("xas_obj should be provided")
_xas_obj = self.getXasObject(xas_obj=xas_obj)
if self._settings:
_xas_obj.configuration["mback"] = self._settings
......
......@@ -147,9 +147,10 @@ class Larch_mback_norm(Process):
if "_larchSettings" in properties:
self._settings = properties["_larchSettings"]
def run(self, xas_obj=None):
def run(self):
xas_obj = self.inputs.xas_obj
if xas_obj is None:
xas_obj = self.inputs.xas_obj
raise ValueError("xas_obj should be provided")
_xas_obj = self.getXasObject(xas_obj=xas_obj)
if self._settings:
_xas_obj.configuration["mback_norm"] = self._settings
......
......@@ -98,6 +98,8 @@ def process_spectr_pre_edge(
):
if opt_name in _conf:
opts[opt_name] = _conf[opt_name]
print("{{{{{{{{{{{{{{{{{{{{{")
print("configuration is", configuration)
if _DEBUG is True:
assert isinstance(spectrum, Group)
......@@ -143,9 +145,10 @@ class Larch_pre_edge(Process):
if "_larchSettings" in properties:
self._settings = properties["_larchSettings"]
def run(self, xas_obj=None):
def run(self):
xas_obj = self.inputs.xas_obj
if xas_obj is None:
xas_obj = self.inputs.xas_obj
raise ValueError("xas_obj should be provided")
self._xas_obj = self.getXasObject(xas_obj=xas_obj)
_xas_obj = self._xas_obj
if self._settings:
......
......@@ -173,9 +173,10 @@ class Larch_xftf(Process):
if "plot_settings" in properties:
self._plot_settings = properties["plot_settings"]
def run(self, xas_obj=None):
def run(self):
xas_obj = self.inputs.xas_obj
if xas_obj is None:
xas_obj = self.inputs.xas_obj
raise ValueError("xas_obj should be provided")
_xas_obj = self.getXasObject(xas_obj=xas_obj)
if self._settings:
_xas_obj.configuration["xftf"] = self._settings
......
......@@ -169,7 +169,7 @@ class NoiseProcess(Process):
if "polynomial_order" in properties:
self._polynomial_order = properties["polynomial_order"]
def run(self, xas_obj: Union[dict, XASObject] = None):
def run(self, xas_obj):
"""
:param xas_obj: object containing the configuration and spectra to process
......@@ -177,10 +177,10 @@ class NoiseProcess(Process):
:return: spectra dict
:rtype: :class:`.XASObject`
"""
xas_obj = self.inputs.xas_obj
if xas_obj is None:
xas_obj = self.inputs.xas_obj
raise ValueError("xas_obj should be provided")
_xas_obj = self.getXasObject(xas_obj=xas_obj)
if self._settings:
_xas_obj.configuration["noise"] = self._settings
......
......@@ -160,9 +160,10 @@ class PyMca_exafs(Process):
if "_pymcaSettings" in properties:
self.setConfiguration(properties["_pymcaSettings"])
def run(self, xas_obj=None):
def run(self):
xas_obj = self.inputs.xas_obj
if xas_obj is None:
xas_obj = self.inputs.xas_obj
raise ValueError("xas_obj should be provided")
_xas_obj = self.getXasObject(xas_obj=xas_obj)
if self._settings:
_xas_obj.configuration["EXAFS"] = self._settings
......
......@@ -163,7 +163,7 @@ class PyMca_ft(Process):
if "_pymcaSettings" in properties:
self._settings = properties["_pymcaSettings"]
def run(self, xas_obj=None):
def run(self):
"""
:param xas_obj: object containing the configuration and spectra to process
......@@ -171,8 +171,9 @@ class PyMca_ft(Process):
:return: spectra dict
:rtype: dict
"""
xas_obj = self.inputs.xas_obj
if xas_obj is None:
xas_obj = self.inputs.xas_obj
raise ValueError("xas_obj should be provided")
_xas_obj = self.getXasObject(xas_obj=xas_obj)
if self._settings:
_xas_obj.configuration["FT"] = self._settings
......
......@@ -158,7 +158,7 @@ class PyMca_k_weight(Process):
return self._settings["k_weight"]
return None
def run(self, xas_obj=None):
def run(self):
"""
:param xas_obj: object containing the configuration and spectra to process
......@@ -166,8 +166,9 @@ class PyMca_k_weight(Process):
:return: spectra dict
:rtype: :class:`.XASObject`
"""
xas_obj = self.inputs.xas_obj
if xas_obj is None:
xas_obj = self.inputs.xas_obj
raise ValueError("xas_obj should be provided")
_xas_obj = self.getXasObject(xas_obj=xas_obj)
if self._k_weight() is not None:
_xas_obj.configuration["SET_KWEIGHT"] = self._k_weight()
......
......@@ -138,7 +138,7 @@ class PyMca_normalization(Process):
if "_pymcaSettings" in properties:
self._settings = properties["_pymcaSettings"]
def run(self, xas_obj=None):
def run(self):
"""
:param xas_obj: object containing the configuration and spectra to process
......@@ -147,8 +147,9 @@ class PyMca_normalization(Process):
:return: updated XASObject
:rtype: :class:`.XASObject`
"""
xas_obj = self.inputs.xas_obj
if xas_obj is None:
xas_obj = self.inputs.xas_obj
raise ValueError("xas_obj should be provided")
_xas_obj = self.getXasObject(xas_obj)
if _xas_obj.energy is None:
......
......@@ -174,7 +174,7 @@ class ROIProcess(Process):
xas_obj.spectra.reshape((roi.size[1], roi.size[0]))
return xas_obj
def run(self, xas_obj: Union[dict, XASObject] = None):
def run(self, xas_obj):
"""
:param xas_obj: object containing the configuration and spectra to process
......@@ -182,8 +182,9 @@ class ROIProcess(Process):
:return: spectra dict
:rtype: :class:`.XASObject`
"""
xas_obj = self.inputs.xas_obj
if xas_obj is None:
xas_obj = self.inputs.xas_obj
raise ValueError("xas_obj should be provided")
_xas_obj = self.getXasObject(xas_obj=xas_obj)
# existing roi is priority. This is the case if called from pushworkflow
......
......@@ -147,4 +147,5 @@ class ProcessQThread(qt.QThread):
self._process_obj = process_obj
def run(self):
self._xas_obj = self._process_obj.run(self._xas_obj)
return
# self._xas_obj = self._process_obj({"xas_obj": self._xas_obj}).run()
Markdown is supported
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