Skip to content
Snippets Groups Projects
Commit ff7cd862 authored by Egor Sobolev's avatar Egor Sobolev
Browse files

Fix the use of detector source

parent 98965fa2
No related branches found
No related tags found
1 merge request!3Center refinement using powder diffraction data
...@@ -79,8 +79,7 @@ class ImageAgg: ...@@ -79,8 +79,7 @@ class ImageAgg:
tm0 = time.perf_counter() tm0 = time.perf_counter()
print(f"[{self._rank:2d}] {modno:3d}: ", end="") print(f"[{self._rank:2d}] {modno:3d}: ", end="")
source_id = source_pattern.format( source_id = source_pattern.format(modno)
detector_id=self.detector_id, modno=modno)
dc = dc_img.select( dc = dc_img.select(
[(source_id, "image.data"), (source_id, "image.mask")], [(source_id, "image.data"), (source_id, "image.mask")],
require_all=True require_all=True
......
...@@ -181,11 +181,7 @@ def main(argv=None): ...@@ -181,11 +181,7 @@ def main(argv=None):
modules = args.modules modules = args.modules
if modules is None: if modules is None:
re_pattern = re.compile( re_pattern = re.compile(
"^" + "^" + det_source_pattern.replace("*", r"(?P<modno>\d+)") + "$")
source_pattern.format(
detector_id=detector_id, modno=r"(?P<modno>\d+)") +
"$"
)
matches = (re_pattern.match(s) for s in dc_img.all_sources) matches = (re_pattern.match(s) for s in dc_img.all_sources)
modules = sorted(int(m["modno"]) for m in matches if m is not None) modules = sorted(int(m["modno"]) for m in matches if m is not None)
num_modules = len(modules) num_modules = len(modules)
...@@ -217,11 +213,11 @@ def main(argv=None): ...@@ -217,11 +213,11 @@ def main(argv=None):
mpi_print() mpi_print()
mpi_print("Rounding threshold:", rounding_threshold) mpi_print("Rounding threshold:", rounding_threshold)
det_source_pattern = det_source_pattern.replace("*", "{}")
if args.layout is None: if args.layout is None:
px_area = None px_area = None
for modno in modules: for modno in modules:
source_id = source_pattern.format( source_id = det_source_pattern.format(modno)
detector_id=detector_id, modno=modno)
if source_id in dc_img.all_sources: if source_id in dc_img.all_sources:
break break
shape = dc_img[source_id, "image.data"].shape[1:] shape = dc_img[source_id, "image.data"].shape[1:]
...@@ -245,7 +241,7 @@ def main(argv=None): ...@@ -245,7 +241,7 @@ def main(argv=None):
rounding_threshold, px_area=px_area) rounding_threshold, px_area=px_area)
agg.prepare(output_fn, mask=mask0, comm=comm, conditions=conditions) agg.prepare(output_fn, mask=mask0, comm=comm, conditions=conditions)
agg.compute(dc_img, source_pattern) agg.compute(dc_img, det_source_pattern)
agg.flush() agg.flush()
tm1 = time.perf_counter() tm1 = time.perf_counter()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment