From e534235a6fa89453bccb7671566a676b54652f5b Mon Sep 17 00:00:00 2001 From: Jerome Kieffer Date: Fri, 20 Dec 2024 17:10:16 +0100 Subject: [PATCH] Polish a bit further ... --- src/pyFAI/gui/test/test_integrate_widget.py | 2 +- src/pyFAI/gui/widgets/WorkerConfigurator.py | 288 +++++++++----------- src/pyFAI/io/integration_config.py | 67 +++-- src/pyFAI/io/ponifile.py | 42 +-- src/pyFAI/test/test_integrate_config.py | 8 +- src/pyFAI/test/test_worker.py | 1 + src/pyFAI/worker.py | 6 +- 7 files changed, 192 insertions(+), 222 deletions(-) diff --git a/src/pyFAI/gui/test/test_integrate_widget.py b/src/pyFAI/gui/test/test_integrate_widget.py index 4e1104143..a7f5f5b07 100644 --- a/src/pyFAI/gui/test/test_integrate_widget.py +++ b/src/pyFAI/gui/test/test_integrate_widget.py @@ -32,7 +32,7 @@ __contact__ = "valentin.valls@esrf.fr" __license__ = "MIT" __copyright__ = "European Synchrotron Radiation Facility, Grenoble, France" -__date__ = "16/10/2020" +__date__ = "20/12/2024" import unittest import logging diff --git a/src/pyFAI/gui/widgets/WorkerConfigurator.py b/src/pyFAI/gui/widgets/WorkerConfigurator.py index a697c880b..b86233031 100644 --- a/src/pyFAI/gui/widgets/WorkerConfigurator.py +++ b/src/pyFAI/gui/widgets/WorkerConfigurator.py @@ -4,7 +4,7 @@ # Project: Azimuthal integration # https://github.com/silx-kit/pyFAI # -# Copyright (C) 2013-2021 European Synchrotron Radiation Facility, Grenoble, France +# Copyright (C) 2013-2024 European Synchrotron Radiation Facility, Grenoble, France # # Principal author: Jérôme Kieffer (Jerome.Kieffer@ESRF.eu) # @@ -33,14 +33,14 @@ __contact__ = "Jerome.Kieffer@ESRF.eu" __license__ = "MIT" __copyright__ = "European Synchrotron Radiation Facility, Grenoble, France" -__date__ = "22/07/2024" +__date__ = "20/12/2024" __status__ = "development" import logging import json import os.path import collections - +import numpy logger = logging.getLogger(__name__) from silx.gui import qt @@ -61,6 +61,9 @@ from ...io.ponifile import PoniFile from ...io import integration_config from ... import method_registry +from ...containers import PolarizationDescription +from ... import detector_factory +from ...integrator import load_engines class _WorkerModel(object): @@ -241,7 +244,6 @@ def getConfig(self): :return: dict with all information. """ - def splitFiles(filenames): """In case files was provided with comma. @@ -253,56 +255,43 @@ def splitFiles(filenames): return None return [name.strip() for name in filenames.split("|")] - config = collections.OrderedDict() - - # file-version - config["application"] = "pyfai-integrate" - config["version"] = 4 - - # geometry - config["poni"] = self.getPoniDict() - + wc = integration_config.WorkerConfig(application="pyfai-integrate", + poni=self.getPoniDict()) # pre-processing - config["do_mask"] = bool(self.do_mask.isChecked()) - config["mask_file"] = str_(self.mask_file.text()).strip() - config["do_dark"] = bool(self.do_dark.isChecked()) - config["dark_current"] = splitFiles(self.dark_current.text()) - config["do_flat"] = bool(self.do_flat.isChecked()) - config["flat_field"] = splitFiles(self.flat_field.text()) - config["do_polarization"] = bool(self.do_polarization.isChecked()) - config["polarization_factor"] = float_(self.polarization_factor.value()) - config["do_dummy"] = bool(self.do_dummy.isChecked()) - config["val_dummy"] = self._float("val_dummy", None) - config["delta_dummy"] = self._float("delta_dummy", None) + if self.do_mask.isChecked(): + wc.mask_image = str_(self.mask_file.text()).strip() + if self.do_dark.isChecked(): + wc.dark_current_image = splitFiles(self.dark_current.text()) + if self.do_flat.isChecked(): + wc.flat_field_image = splitFiles(self.flat_field.text()) + if self.do_polarization.isChecked(): + wc.polarization_factor = PolarizationDescription(float_(self.polarization_factor.value()), 0.0) + if self.do_dummy.isChecked(): + wc.val_dummy = self._float("val_dummy", None) + wc.delta_dummy = self._float("delta_dummy", None) # integration - config["do_2D"] = bool(self.do_2D.isChecked()) - value = self.__getRadialNbpt() - if value is not None: - config["nbpt_rad"] = value - - value = self.__getAzimuthalNbpt() - if value is not None: - config["nbpt_azim"] = value - - config["unit"] = str(self.radial_unit.model().value()) - config["do_radial_range"] = bool(self.do_radial_range.isChecked()) - config["radial_range_min"] = self._float("radial_range_min", None) - config["radial_range_max"] = self._float("radial_range_max", None) - config["do_azimuthal_range"] = bool(self.do_azimuthal_range.isChecked()) - config["azimuth_range_min"] = self._float("azimuth_range_min", None) - config["azimuth_range_max"] = self._float("azimuth_range_max", None) + if self.do_2D.isChecked(): + wc.nbpt_azim = self.__getAzimuthalNbpt() + wc.nbpt_rad = self.__getRadialNbpt() + wc.unit = str(self.radial_unit.model().value()) + if self.do_radial_range.isChecked(): + wc.radial_range = [self._float("radial_range_min", -numpy.inf), + self._float("radial_range_max", numpy.inf)] + if self.do_azimuthal_range.isChecked(): + wc.azimuth_range = [self._float("azimuth_range_min", -numpy.inf), + self._float("azimuth_range_max", numpy.inf)] # processing-config - config["chi_discontinuity_at_0"] = bool(self.chi_discontinuity_at_0.isChecked()) - config["do_solid_angle"] = bool(self.do_solid_angle.isChecked()) - config["error_model"] = self.error_model.currentData() + wc.chi_discontinuity_at_0 = bool(self.chi_discontinuity_at_0.isChecked()) + wc.do_solid_angle = bool(self.do_solid_angle.isChecked()) + wc.error_model = self.error_model.currentData() method = self.__method if method is not None: - config["method"] = method.split, method.algo, method.impl + wc.method = (method.split, method.algo, method.impl) if method.impl == "opencl": - config["opencl_device"] = self.__openclDevice + wc.opencl_device = self.__openclDevice if self.do_normalization.isChecked(): value = self.normalization_factor.text() @@ -312,21 +301,20 @@ def splitFiles(filenames): except ValueError: value = None if value not in [1.0, None]: - config["normalization_factor"] = value + wc.normalization_factor = value value = self.monitor_name.text() if value != "": value = str(value) - config["monitor_name"] = value + wc.monitor_name = value if self.integrator_name.currentText() == "sigma_clip_ng": - config["do_2D"] = False - config["integrator_name"] = "sigma_clip_ng" - config["extra_options"] = {"thres" : float(self.sigmaclip_threshold.text()), - "max_iter" : float(self.sigmaclip_maxiter.text()), - } - - return config + wc.nbpt_azim = 1 + wc.integrator_method = "sigma_clip_ng" + wc.extra_options = {"thres" : float(self.sigmaclip_threshold.text()), + "max_iter" : float(self.sigmaclip_maxiter.text()), + } + return wc.as_dict() def setConfig(self, dico): """Setup the widget from its description @@ -334,16 +322,20 @@ def setConfig(self, dico): :param dico: dictionary with description of the widget :type dico: dict """ - dico = dico.copy() - dico = integration_config.normalize(dico, inplace=True) + def normalizeFiles(filenames): + """Normalize different versions of the filename list. + + FIXME: The file brower will not work, but the returned config will + be valid + """ + if filenames is None: + return "" + if isinstance(filenames, list): + return "|".join(filenames) + filenames = filenames.strip() + return filenames - version = dico.pop("version") - if version >= 2: - application = dico.pop("application", None) - if application != "pyfai-integrate": - logger.error("It is not a configuration file from pyFAI-integrate.") - if version > 4: - logger.error("Configuration file %d too recent. This version of pyFAI maybe too old to read the configuration", version) + wc = integration_config.WorkerConfig.from_dict(dico, inplace=False) # Clean up the GUI self.setDetector(None) @@ -355,135 +347,103 @@ def setConfig(self, dico): self.__geometryModel.rotation2().setValue(None) self.__geometryModel.rotation3().setValue(None) - # patch for version 4 - poni_dict = dico.get("poni", None) - if isinstance(poni_dict, dict) and version > 3: + poni_dict = wc.poni + if isinstance(poni_dict, dict): if "wavelength" in poni_dict: - value = poni_dict.pop("wavelength") - self.__geometryModel.wavelength().setValue(value) + self.__geometryModel.wavelength().setValue(poni_dict["wavelength"]) if "dist" in poni_dict: - value = poni_dict.pop("dist") - self.__geometryModel.distance().setValue(value) + self.__geometryModel.distance().setValue(poni_dict["dist"]) if "poni1" in poni_dict: - value = poni_dict.pop("poni1") - self.__geometryModel.poni1().setValue(value) + self.__geometryModel.poni1().setValue(poni_dict["poni1"]) if "poni2" in poni_dict: - value = poni_dict.pop("poni2") - self.__geometryModel.poni2().setValue(value) + self.__geometryModel.poni2().setValue(poni_dict["poni2"]) if "rot1" in poni_dict: - value = poni_dict.pop("rot1") - self.__geometryModel.rotation1().setValue(value) + self.__geometryModel.rotation1().setValue(poni_dict["rot1"]) if "rot2" in poni_dict: - value = poni_dict.pop("rot2") - self.__geometryModel.rotation2().setValue(value) + self.__geometryModel.rotation2().setValue(poni_dict["rot2"]) if "rot3" in poni_dict: - value = poni_dict.pop("rot3") - self.__geometryModel.rotation3().setValue(value) - - # For older versions (<4) - if "wavelength" in dico: - value = dico.pop("wavelength") - self.__geometryModel.wavelength().setValue(value) - if "dist" in dico: - value = dico.pop("dist") - self.__geometryModel.distance().setValue(value) - if "poni1" in dico: - value = dico.pop("poni1") - self.__geometryModel.poni1().setValue(value) - if "poni2" in dico: - value = dico.pop("poni2") - self.__geometryModel.poni2().setValue(value) - if "rot1" in dico: - value = dico.pop("rot1") - self.__geometryModel.rotation1().setValue(value) - if "rot2" in dico: - value = dico.pop("rot2") - self.__geometryModel.rotation2().setValue(value) - if "rot3" in dico: - value = dico.pop("rot3") - self.__geometryModel.rotation3().setValue(value) - - reader = integration_config.ConfigurationReader(dico) + self.__geometryModel.rotation3().setValue(poni_dict["rot3"]) - # detector - detector = reader.pop_detector() - self.setDetector(detector) - - def normalizeFiles(filenames): - """Normalize different versions of the filename list. - FIXME: The file brower will not work, but the returned config will - be valid - """ - if filenames is None: - return "" - if isinstance(filenames, list): - return "|".join(filenames) - filenames = filenames.strip() - return filenames + #reader = integration_config.ConfigurationReader(dico) - setup_data = collections.OrderedDict() - setup_data["val_dummy"] = lambda a: self.val_dummy.setText(str_(a)) - setup_data["delta_dummy"] = lambda a: self.delta_dummy.setText(str_(a)) - setup_data["mask_file"] = lambda a: self.__model.maskFileModel.setFilename(str_(a)) - setup_data["dark_current"] = lambda a: self.__model.darkFileModel.setFilename(normalizeFiles(a)) - setup_data["flat_field"] = lambda a: self.__model.flatFileModel.setFilename(normalizeFiles(a)) - setup_data["polarization_factor"] = self.polarization_factor.setValue - setup_data["nbpt_rad"] = lambda a: self.nbpt_rad.setText(str_(a)) - setup_data["nbpt_azim"] = lambda a: self.nbpt_azim.setText(str_(a)) - setup_data["chi_discontinuity_at_0"] = self.chi_discontinuity_at_0.setChecked - setup_data["radial_range_min"] = lambda a: self.radial_range_min.setText(str_(a)) - setup_data["radial_range_max"] = lambda a: self.radial_range_max.setText(str_(a)) - setup_data["azimuth_range_min"] = lambda a: self.azimuth_range_min.setText(str_(a)) - setup_data["azimuth_range_max"] = lambda a: self.azimuth_range_max.setText(str_(a)) - setup_data["do_solid_angle"] = self.do_solid_angle.setChecked - setup_data["do_dummy"] = self.do_dummy.setChecked - setup_data["do_dark"] = self.do_dark.setChecked - setup_data["do_flat"] = self.do_flat.setChecked - setup_data["do_polarization"] = self.do_polarization.setChecked - setup_data["do_mask"] = self.do_mask.setChecked - setup_data["do_radial_range"] = self.do_radial_range.setChecked - setup_data["do_azimuthal_range"] = self.do_azimuthal_range.setChecked - - for key, value in setup_data.items(): - if key in dico and (value is not None): - if key == "polarization_factor" and not isinstance(dico[key], (float, int)): - continue - value(dico.pop(key)) - - normalizationFactor = dico.pop("normalization_factor", None) - monitorName = dico.pop("monitor_name", None) - self.__setNormalization(normalizationFactor, monitorName) - - value = dico.pop("unit", None) + # detector + if "detector" in poni_dict: + detector = detector_factory(poni_dict["detector"], poni_dict.get("detector_config")) + self.setDetector(detector) + + self.val_dummy.setText(str_(wc.val_dummy)) + self.delta_dummy.setText(str_(wc.delta_dummy)) + self.__model.maskFileModel.setFilename(str_(wc.mask_image)) + self.__model.darkFileModel.setFilename(normalizeFiles(wc.dark_current_image)) + self.__model.flatFileModel.setFilename(normalizeFiles(wc.flat_field_image)) + if isinstance(wc.polarization_factor, float): + self.polarization_factor.setValue(wc.polarization_factor) + elif isinstance(wc.polarization_factor, (tuple, list)): + self.polarization_factor.setValue(wc.polarization_factor[0]) + self.nbpt_rad.setText(str_(wc.nbpt_rad)) + self.nbpt_azim.setText(str_(wc.nbpt_azim)) + self.chi_discontinuity_at_0.setChecked(wc.chi_discontinuity_at_0) + self.radial_range_min.setText(str_(wc.radial_range_min)) + self.radial_range_max.setText(str_(wc.radial_range_max)) + self.azimuth_range_min.setText(str_(wc.azimuth_range_min)) + self.azimuth_range_max.setText(str_(wc.azimuth_range_max)) + self.do_solid_angle.setChecked(wc.do_solid_angle) + self.do_dummy.setChecked(wc.do_dummy) + self.do_dark.setChecked(wc.do_dark) + self.do_flat.setChecked(wc.do_flat) + self.do_polarization.setChecked(wc.do_polarization) + self.do_mask.setChecked(wc.do_mask) + self.do_radial_range.setChecked(wc.do_radial_range) + self.do_azimuthal_range.setChecked(wc.do_azimuthal_range) + self.__setNormalization(wc.normalization_factor, wc.monitor_name) + + value = wc.unit if value is not None: unit = to_unit(value) self.radial_unit.model().setValue(unit) - value = dico.pop("error_model", None) + value = wc.error_model index = self.error_model.findData(value) self.error_model.setCurrentIndex(index) - method = reader.pop_method() + + dim = 2 if wc.do_2D else 1 + method = wc.method + target = wc.opencl_device + if isinstance(target, list): + target = tuple(target) + + if method is None: + lngm = load_engines.PREFERED_METHODS_2D[0] if dim==2 else load_engines.PREFERED_METHODS_1D[0] + method = lngm.method + elif isinstance(method, (str,)): + method = method_registry.Method.parsed(method) + method = method.fixed(dim=dim, target=target) + elif isinstance(method, (list, tuple)): + if len(method) == 3: + split, algo, impl = method + method = method_registry.Method(dim, split, algo, impl, target) + elif 3 < len(method) <= 5: + method = method_registry.Method(*method) + else: + raise TypeError(f"Method size {len(method)} is unsupported, method={method}.") + self.__setMethod(method) self.__setOpenclDevice(method.target) - self.do_2D.setChecked(method.dim == 2) + self.do_2D.setChecked(wc.do_2D) if self.__only1dIntegration: # Force unchecked self.do_2D.setChecked(False) - integrator_name = dico.pop("integrator_name", "integrate") + integrator_name = wc.integrator_method or "integrate" self.integrator_name.setCurrentText(integrator_name) - if integrator_name == "sigma_clip_ng": - extra_options = dico.pop("extra_options", {}) + if integrator_name.startswith("sigma_clip"): + extra_options = wc.extra_options or {} self.sigmaclip_threshold.setText(str(extra_options.get("thres", 5.0))) self.sigmaclip_maxiter.setText(str(extra_options.get("max_iter", 5))) - if len(dico) != 0: - for key, value in dico.items(): - logger.warning("json key '%s' unused", key) - self.__updateDisabledStates() def getOpenFileName(self, title): diff --git a/src/pyFAI/io/integration_config.py b/src/pyFAI/io/integration_config.py index 6c3c1ccc9..2f35ea9d2 100644 --- a/src/pyFAI/io/integration_config.py +++ b/src/pyFAI/io/integration_config.py @@ -291,9 +291,9 @@ def _patch_v4_to_v5(config): for key1, key2 in[("azimuth_range_min", "azimuthal_range_min"), ("azimuth_range_max", "azimuthal_range_max"), ('do_azimuthal_range', 'do_azimuth_range'), - ("flat_field_image","flat_field"), - ("dark_current_image", "dark_current"), - ("mask_image", "mask_file"), + ("flat_field", "flat_field_image"), + ("dark_current", "dark_current_image"), + ("mask_file", "mask_image"), ("val_dummy", "dummy")]: if key2 in config and not key1 in config: config[key1] = config.pop(key2) @@ -344,7 +344,7 @@ def normalize(config, inplace=False, do_raise=False, target_version=CURRENT_VERS class ConfigurationReader(object): - + "This class should be deprecated now ..." def __init__(self, config): ":param config: dictonary" self._config = config @@ -433,12 +433,13 @@ class WorkerConfig: chi_discontinuity_at_0: bool=False do_solid_angle: bool=True polarization_factor: PolarizationDescription = None + normalization_factor: float=1.0 val_dummy: float = None delta_dummy: float = None correct_solid_angle: bool = True - dark_current_image: str = None - flat_field_image: str = None - mask_image: str = None + dark_current: Union[str, list] = None + flat_field: Union[str, list] = None + mask_file: str = None error_model: ErrorModel = None method: object = None opencl_device: list = None @@ -447,6 +448,7 @@ class WorkerConfig: integrator_class: str = "AzimuthalIntegrator" integrator_method: str = None extra_options: dict = None + monitor_name: str = None OPTIONAL: ClassVar[list] = ["radial_range_min", "radial_range_max", "azimuth_range_min", "azimuth_range_max", "integrator_name", "do_poisson"] @@ -471,7 +473,6 @@ def from_dict(cls, dico, inplace=False): if not inplace: dico = copy.copy(dico) normalize(dico, inplace=True) - # for key,value in dico.items():print(key, value) to_init = {field.name:dico.pop(field.name) for field in fields(cls) if field.name in dico} @@ -481,7 +482,6 @@ def from_dict(cls, dico, inplace=False): dico.pop(key) for key in cls.OPTIONAL: if key in dico: - # print(key, dico[key]) value = dico.pop(key) self.__setattr__(key, value) if len(dico): @@ -503,7 +503,7 @@ def load(cls, filename): @property def do_2D(self): - return self.nbpt_azim > 1 + return False if self.nbpt_azim is None else self.nbpt_azim > 1 @property def do_azimuthal_range(self): @@ -514,7 +514,7 @@ def do_azimuthal_range(self): @property def azimuth_range_min(self): if self.azimuth_range: - self.azimuth_range[0] + return self.azimuth_range[0] else: return -numpy.inf @azimuth_range_min.setter @@ -525,7 +525,7 @@ def azimuth_range_min(self, value): @property def azimuth_range_max(self): if self.azimuth_range: - self.azimuth_range[1] + return self.azimuth_range[1] else: return numpy.inf @azimuth_range_max.setter @@ -543,7 +543,7 @@ def do_radial_range(self): @property def radial_range_min(self): if self.radial_range: - self.radial_range[0] + return self.radial_range[0] else: return -numpy.inf @radial_range_min.setter @@ -554,7 +554,7 @@ def radial_range_min(self, value): @property def radial_range_max(self): if self.radial_range: - self.radial_range[1] + return self.radial_range[1] else: return numpy.inf @radial_range_max.setter @@ -571,7 +571,7 @@ def integrator_name(self, value): @property def do_mask(self): - return self.mask_image is not None + return self.mask_file is not None @property def do_poisson(self): return int(self.error_model) == int(ErrorModel.POISSON) @@ -586,8 +586,41 @@ def dummy(self): def dummy(self, value): if value: self.val_dummy = float(value) if value is not None else value - - + @property + def do_dummy(self): + return self.val_dummy is not None + @property + def mask_image(self): + return self.mask_file + @mask_image.setter + def mask_image(self, value): + self.mask_file = None if not value else value + @property + def do_dark(self): + return bool(self.dark_current) + @property + def do_flat(self): + return bool(self.flat_field) + @property + def do_polarization(self): + if self.polarization_factor is None: + return False + if "__len__" in dir(self.polarization_factor): + return bool(self.polarization_factor) + else: + return True + @property + def dark_current_image(self): + return self.dark_current + @dark_current_image.setter + def dark_current_image(self, value): + self.dark_current = None if not value else value + @property + def flat_field_image(self): + return self.flat_field + @flat_field_image.setter + def flat_field_image(self, value): + self.flat_field = None if not value else value # @dataclass(slots=True) # class PixelwiseWorkerConfig: # """Configuration for pyFAI.worker.PixelwiseWorker diff --git a/src/pyFAI/io/ponifile.py b/src/pyFAI/io/ponifile.py index 0c4a9e33e..5c99cb0bf 100644 --- a/src/pyFAI/io/ponifile.py +++ b/src/pyFAI/io/ponifile.py @@ -270,39 +270,15 @@ def as_dict(self): return config def as_integration_config(self): - from .integration_config import normalize - config = { - "application" : "poni", - "version" : 4, - "poni" : dict(self.as_dict()), - "do_2D" : True, - "nbpt_rad" : 500, - "nbpt_azim" : 360, - "unit" : "q_nm^-1", - "do_mask" : False, - "mask_file" : None, - "do_flat" : False, - "flat_field" : None, - "do_dark" : False, - "dark_current" : None, - "method" : ("bbox", "csr", "cython"), - "do_dummy" : None, - "val_dummy" : None, - "delta_dummy" : None, - "do_solid_angle" : True, - "error_model" : None, - "do_radial_range" : False, - "radial_range_min" : None, - "radial_range_max" : None, - "do_azimuthal_range" : False, - "azimuth_range_min" : None, - "azimuth_range_max" : None, - "chi_discontinuity_at_0" : False, - "do_polarization" : False, - "normalization_factor" : 1.0, - } - return normalize(config=config) - + from .integration_config import WorkerConfig + wc = WorkerConfig(application="poni", + poni=dict(self.as_dict()), + nbpt_rad=500, + nbpt_azim=360, + unit="q_nm^-1", + method=("full", "csr", "cython"), + normalization_factor=1.0) + return wc @property def detector(self): diff --git a/src/pyFAI/test/test_integrate_config.py b/src/pyFAI/test/test_integrate_config.py index f239d2d0b..e2c6dca1d 100644 --- a/src/pyFAI/test/test_integrate_config.py +++ b/src/pyFAI/test/test_integrate_config.py @@ -60,15 +60,15 @@ def test_single_flatdark(self): config = {"dark_current": "abc", "flat_field": "abd"} config = integration_config.normalize(config) - self.assertEqual(config["dark_current_image"], "abc") - self.assertEqual(config["flat_field_image"], "abd") + self.assertEqual(config["dark_current"], "abc") + self.assertEqual(config["flat_field"], "abd") def test_coma_flatdark(self): config = {"dark_current": "a,b,c", "flat_field": "a,b,d"} config = integration_config.normalize(config) - self.assertEqual(config["dark_current_image"], ["a", "b", "c"]) - self.assertEqual(config["flat_field_image"], ["a", "b", "d"]) + self.assertEqual(config["dark_current"], ["a", "b", "c"]) + self.assertEqual(config["flat_field"], ["a", "b", "d"]) def test_pilatus(self): config = {"detector": "pilatus2m"} diff --git a/src/pyFAI/test/test_worker.py b/src/pyFAI/test/test_worker.py index 6e0799356..1fda10646 100644 --- a/src/pyFAI/test/test_worker.py +++ b/src/pyFAI/test/test_worker.py @@ -381,6 +381,7 @@ def test_flatdark(self): worker.set_config(config) data = numpy.ones(shape=self.shape) worker.process(data=data) + print(worker.ai.detector) self.assertTrue(numpy.isclose(worker.ai.detector.get_darkcurrent()[0, 0], (1 + 2 + 3) / 3)) self.assertTrue(numpy.isclose(worker.ai.detector.get_flatfield()[0, 0], (1 + 2 + 4) / 3)) diff --git a/src/pyFAI/worker.py b/src/pyFAI/worker.py index 5c565682c..03f3b64ce 100644 --- a/src/pyFAI/worker.py +++ b/src/pyFAI/worker.py @@ -467,7 +467,7 @@ def set_config(self, config, consume_keys=False): _init_ai(self.ai, config, consume_keys=True, read_maps=False) # Do it here before reading the AI to be able to catch the io - filename = config.pop("mask_image", "") + filename = config.pop("mask_file", "") apply_process = config.pop("do_mask", True) if filename and apply_process: try: @@ -479,7 +479,7 @@ def set_config(self, config, consume_keys=False): self.mask_image = filename # Do it here while we have to store metadata - filename = config.pop("dark_current_image", "") + filename = config.pop("dark_current", "") apply_process = config.pop("do_dark", True) if filename and apply_process: filenames = _normalize_filenames(filename) @@ -489,7 +489,7 @@ def set_config(self, config, consume_keys=False): self.dark_current_image = filenames #"%s(%s)" % (method, ",".join(filenames)) # Do it here while we have to store metadata - filename = config.pop("flat_field_image", "") + filename = config.pop("flat_field", "") apply_process = config.pop("do_flat", True) if filename and apply_process: filenames = _normalize_filenames(filename)