Commit b84008eb authored by Henri Payno's avatar Henri Payno
Browse files

[ewoks integration][core] add optional_input_names

parent 344e09a0
Pipeline #53267 passed with stages
in 9 minutes and 31 seconds
......@@ -133,7 +133,11 @@ _USE_MULTIPROCESSING_POOL = False
class Larch_autobk(
Process, name="autobk", input_names=["xas_obj"], output_names=["xas_obj"]
Process,
name="autobk",
input_names=["xas_obj"],
output_names=["xas_obj"],
optional_input_names=["autobk"],
):
def set_properties(self, properties):
if "_larchSettings" in properties:
......@@ -144,8 +148,9 @@ class Larch_autobk(
if xas_obj is None:
raise ValueError("xas_obj should be provided")
_xas_obj = self.getXasObject(xas_obj=xas_obj)
if self._settings:
_xas_obj.configuration["autobk"] = self._settings
if self.inputs.autobk:
self.setConfiguration(self.inputs.autobk)
_xas_obj.configuration["autobk"] = self.inputs.autobk
self._advancement.reset(max_=_xas_obj.n_spectrum)
self._advancement.startProcess()
......
......@@ -124,7 +124,11 @@ _USE_MULTIPROCESSING_POOL = False
class Larch_mback(
Process, name="mback", input_names=["xas_obj"], output_names=["xas_obj"]
Process,
name="mback",
input_names=["xas_obj"],
output_names=["xas_obj"],
optional_input_names=["mback"],
):
def set_properties(self, properties):
if "_larchSettings" in properties:
......@@ -135,8 +139,10 @@ class Larch_mback(
if xas_obj is None:
raise ValueError("xas_obj should be provided")
_xas_obj = self.getXasObject(xas_obj=xas_obj)
if self._settings:
_xas_obj.configuration["mback"] = self._settings
if self.inputs.mback:
self.setConfiguration(self.inputs.mback)
_xas_obj.configuration["mback"] = self.inputs.mback
elif "mback" not in _xas_obj.configuration:
_xas_obj.configuration["mback"] = {}
......
......@@ -133,7 +133,11 @@ _USE_MULTIPROCESSING_POOL = False
class Larch_mback_norm(
Process, name="mback_norm", input_names=["xas_obj"], output_names=["xas_obj"]
Process,
name="mback_norm",
input_names=["xas_obj"],
output_names=["xas_obj"],
optional_input_names=["mback_norm"],
):
def set_properties(self, properties):
if "_larchSettings" in properties:
......@@ -144,8 +148,9 @@ class Larch_mback_norm(
if xas_obj is None:
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
if self.inputs.mback_norm:
self.setConfiguration(self.inputs.mback_norm)
_xas_obj.configuration["mback_norm"] = self.inputs.mback_norm
self._advancement.reset(max_=_xas_obj.n_spectrum)
self._advancement.startProcess()
......
......@@ -129,7 +129,11 @@ _USE_MULTIPROCESSING_POOL = False
class Larch_pre_edge(
Process, name="pre_edge", input_names=["xas_obj"], output_names=["xas_obj"]
Process,
name="pre_edge",
input_names=["xas_obj"],
output_names=["xas_obj"],
optional_input_names=["pre_edge"],
):
def set_properties(self, properties):
if "_larchSettings" in properties:
......@@ -141,8 +145,9 @@ class Larch_pre_edge(
raise ValueError("xas_obj should be provided")
self._xas_obj = self.getXasObject(xas_obj=xas_obj)
_xas_obj = self._xas_obj
if self._settings:
_xas_obj.configuration["pre_edge"] = self._settings
if self.inputs.pre_edge:
self.setConfiguration(self.inputs.pre_edge)
_xas_obj.configuration["pre_edge"] = self.inputs.pre_edge
self._advancement.reset(max_=_xas_obj.n_spectrum)
self._advancement.startProcess()
......
......@@ -156,7 +156,11 @@ _USE_MULTIPROCESSING_POOL = False
class Larch_xftf(
Process, name="xftf", input_names=["xas_obj"], output_names=["xas_obj"]
Process,
name="xftf",
input_names=["xas_obj"],
output_names=["xas_obj"],
optional_input_names=["xftf"],
):
def __init__(self, **kwargs):
super().__init__(**kwargs)
......@@ -173,9 +177,11 @@ class Larch_xftf(
if xas_obj is None:
raise ValueError("xas_obj should be provided")
_xas_obj = self.getXasObject(xas_obj=xas_obj)
if self._settings:
_xas_obj.configuration["xftf"] = self._settings
if self.inputs.xftf:
self.setConfiguration(self.inputs.xftf)
_xas_obj.configuration["xftf"] = self.inputs.xftf
elif "xftf" not in _xas_obj.configuration:
self.setConfiguration({})
_xas_obj.configuration["xftf"] = {}
self._advancement.reset(max_=_xas_obj.n_spectrum)
......
......@@ -144,7 +144,11 @@ _USE_MULTIPROCESSING_POOL = False
class PyMca_exafs(
Process, name="exafs", input_names=["xas_obj"], output_names=["xas_obj"]
Process,
name="exafs",
input_names=["xas_obj"],
output_names=["xas_obj"],
optional_input_names=["exafs"],
):
"""Process spectra for exafs and get information about the processing
advancement"""
......@@ -158,8 +162,9 @@ class PyMca_exafs(
if xas_obj is None:
raise ValueError("xas_obj should be provided")
_xas_obj = self.getXasObject(xas_obj=xas_obj)
if self._settings:
_xas_obj.configuration["EXAFS"] = self._settings
if self.inputs.exafs:
self.setConfiguration(self.inputs.exafs)
_xas_obj.configuration["EXAFS"] = self.inputs.exafs
self._advancement.reset(max_=_xas_obj.n_spectrum)
self._advancement.startProcess()
......
......@@ -148,7 +148,13 @@ _USE_MULTIPROCESSING_POOL = False
# note: we cannot use multiprocessing pool with pypushflow for now.
class PyMca_ft(Process, name="ft", input_names=["xas_obj"], output_names=["xas_obj"]):
class PyMca_ft(
Process,
name="ft",
input_names=["xas_obj"],
output_names=["xas_obj"],
optional_input_names=["ft"],
):
def set_properties(self, properties):
if "_pymcaSettings" in properties:
self._settings = properties["_pymcaSettings"]
......@@ -165,8 +171,10 @@ class PyMca_ft(Process, name="ft", input_names=["xas_obj"], output_names=["xas_o
if xas_obj is None:
raise ValueError("xas_obj should be provided")
_xas_obj = self.getXasObject(xas_obj=xas_obj)
if self._settings:
_xas_obj.configuration["FT"] = self._settings
if self.inputs.ft:
self.setConfiguration(self.inputs.ft)
_xas_obj.configuration["FT"] = self.inputs.ft
self._advancement.reset(max_=_xas_obj.n_spectrum)
self._advancement.startProcess()
......
......@@ -137,7 +137,11 @@ _USE_MULTIPROCESSING_POOL = False
class PyMca_k_weight(
Process, name="k weight", input_names=["xas_obj"], output_names=["xas_obj"]
Process,
name="k weight",
input_names=["xas_obj"],
output_names=["xas_obj"],
optional_input_names=["k_weight"],
):
def set_properties(self, properties):
if "_kWeightSetting" in properties:
......@@ -146,11 +150,6 @@ class PyMca_k_weight(
del _properties["_kWeightSetting"]
self.setConfiguration(_properties)
def _k_weight(self):
if "k_weight" in self._settings:
return self._settings["k_weight"]
return None
def run(self):
"""
......@@ -163,8 +162,10 @@ class PyMca_k_weight(
if xas_obj is None:
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()
if self.inputs.k_weight:
self.setConfiguration({"k_weight": self.inputs.k_weight})
_xas_obj.configuration["SET_KWEIGHT"] = self.inputs.k_weight
if "SET_KWEIGHT" not in _xas_obj.configuration:
_logger.warning(
......
......@@ -123,7 +123,11 @@ _USE_MULTIPROCESSING_POOL = False
class PyMca_normalization(
Process, name="normalization", input_names=["xas_obj"], output_names=["xas_obj"]
Process,
name="normalization",
input_names=["xas_obj"],
output_names=["xas_obj"],
optional_input_names=["normalization"],
):
def set_properties(self, properties):
if "_pymcaSettings" in properties:
......@@ -147,8 +151,9 @@ class PyMca_normalization(
_logger.error("Energy not specified, unable to normalize spectra")
return
if self._settings:
_xas_obj.configuration["Normalization"] = self._settings
if self.inputs.normalization:
self.setConfiguration(self.inputs.normalization)
_xas_obj.configuration["Normalization"] = self.inputs.normalization
self._advancement.reset(max_=_xas_obj.n_spectrum)
self._advancement.startProcess()
self._pool_process(xas_obj=_xas_obj)
......
# coding: utf-8
# /*##########################################################################
#
# Copyright (c) 2017-2019 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.
#
# ###########################################################################*/
"""some utils function for executing reprocessing"""
__authors__ = ["H. Payno"]
__license__ = "MIT"
__date__ = "07/18/2019"
import importlib
import logging
from silx.io.utils import h5py_read_dataset
_logger = logging.getLogger(__name__)
def get_process_instance_frm_h5_desc(desc):
"""
:param dict desc: description of the process to instanciate
:return: instance of the process to execute, configured from the description
"""
assert "program" in desc
assert "class_instance" in desc
tmp = h5py_read_dataset(desc["class_instance"]).split(".")
module_name = ".".join(tmp[:-1])
class_name = tmp[-1]
try:
_module = importlib.import_module(module_name)
instance = getattr(_module, class_name)()
except Exception as e:
_logger.warning(
" ".join(("Fail to instanciate", module_name, class_name, "reason is", e))
)
instance = None
else:
if "configuration" in desc:
instance.setConfiguration(desc["configuration"])
return instance
......@@ -184,7 +184,7 @@ class AutobkOW(_ProcessForOrangeMixIn, OWWidget):
self._window.xasObjViewer.setWindowTitle("spectra")
# manage settings
larch_settings = static_input.get("autobk", None)
larch_settings = self.static_input.get("autobk", None)
if larch_settings is None:
larch_settings = self._larchSettings
if larch_settings != dict():
......
......@@ -162,7 +162,7 @@ class Mback_normOW(
self._window.xasObjViewer.setWindowTitle("spectra")
# manage settings
larch_settings = static_input.get("mback_norm", None)
larch_settings = self.static_input.get("mback_norm", None)
if larch_settings is None:
larch_settings = self._larchSettings
if larch_settings != dict():
......
......@@ -180,10 +180,6 @@ class NoiseOW(
"e_max": self.e_max,
},
}
window_size = Setting(int(-1))
polynomial_order = Setting(int(-1))
e_min = Setting(int(-1))
e_max = Setting(int(-1))
def _setProgressValue(self, value):
self._progress.widget.progressBarSet(value)
......
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