-
Notifications
You must be signed in to change notification settings - Fork 97
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
27 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,7 +32,7 @@ | |
__contact__ = "[email protected]" | ||
__license__ = "MIT" | ||
__copyright__ = "European Synchrotron Radiation Facility, Grenoble, France" | ||
__date__ = "04/07/2024" | ||
__date__ = "20/12/2024" | ||
|
||
import unittest | ||
import logging | ||
|
@@ -46,7 +46,7 @@ | |
from ..integrator.azimuthal import AzimuthalIntegrator | ||
from ..containers import Integrate1dResult | ||
from ..containers import Integrate2dResult | ||
from ..io.integration_config import ConfigurationReader | ||
from ..io.integration_config import ConfigurationReader, WorkerConfig | ||
from ..io.ponifile import PoniFile | ||
from .. import detector_factory | ||
from . import utilstest | ||
|
@@ -557,6 +557,15 @@ def test_v3_equal_to_v4(self): | |
poni_v4_from_config = PoniFile(data=config_v4) | ||
self.assertEqual(poni_v3_from_config.as_dict(), poni_v4_from_config.as_dict(), "PONI dictionaries from config match") | ||
|
||
def test_dataclass(self): | ||
test_files = "0.14_verson0.json id11_v0.json id13_v0.json id15_1_v0.json id15_v0.json id16_v3.json id21_v0.json version0.json version3.json version4.json" | ||
for fn in test_files.split(): | ||
js = utilstest.UtilsTest.getimage(fn) | ||
with utilstest.TestLogging(logger='pyFAI.io.integrarion_config', warning=0): | ||
# with self.assertLogs('pyFAI.io.integrarion_config', level='WARNING') as cm: | ||
wc = WorkerConfig.load(js) | ||
self.assertEqual(wc, WorkerConfig.from_dict(wc.as_dict()), f"Idempotent {fn}") | ||
|
||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -82,7 +82,7 @@ | |
__contact__ = "[email protected]" | ||
__license__ = "MIT" | ||
__copyright__ = "European Synchrotron Radiation Facility, Grenoble, France" | ||
__date__ = "03/07/2024" | ||
__date__ = "20/12/2024" | ||
__status__ = "development" | ||
|
||
import threading | ||
|
@@ -463,10 +463,11 @@ def set_config(self, config, consume_keys=False): | |
consumed when used. | ||
""" | ||
config = integration_config.normalize(config, inplace=consume_keys, do_raise=False) | ||
print(config) | ||
_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_file", "") | ||
filename = config.pop("mask_image", "") | ||
apply_process = config.pop("do_mask", True) | ||
if filename and apply_process: | ||
try: | ||
|
@@ -478,24 +479,24 @@ 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", "") | ||
filename = config.pop("dark_current_image", "") | ||
apply_process = config.pop("do_dark", True) | ||
if filename and apply_process: | ||
filenames = _normalize_filenames(filename) | ||
method = "mean" | ||
data = _reduce_images(filenames, method=method) | ||
self.ai.detector.set_darkcurrent(data) | ||
self.dark_current_image = "%s(%s)" % (method, ",".join(filenames)) | ||
self.dark_current_image = filenames #"%s(%s)" % (method, ",".join(filenames)) | ||
|
||
# Do it here while we have to store metadata | ||
filename = config.pop("flat_field", "") | ||
filename = config.pop("flat_field_image", "") | ||
apply_process = config.pop("do_flat", True) | ||
if filename and apply_process: | ||
filenames = _normalize_filenames(filename) | ||
method = "mean" | ||
data = _reduce_images(filenames, method=method) | ||
self.ai.detector.set_flatfield(data) | ||
self.flat_field_image = "%s(%s)" % (method, ",".join(filenames)) | ||
self.flat_field_image = filenames# "%s(%s)" % (method, ",".join(filenames)) | ||
|
||
# Uses it anyway in case do_2D is customed after the configuration | ||
value = config.pop("nbpt_azim", None) | ||
|