From e155e9ba455e00aef7d79e477b3449bb1db56c98 Mon Sep 17 00:00:00 2001
From: Egor Sobolev <egor.sobolev@xfel.eu>
Date: Thu, 27 Feb 2025 00:48:39 +0100
Subject: [PATCH] Add background estimation parameters to find_center script

---
 src/geomtools/powder/find_center.py | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/src/geomtools/powder/find_center.py b/src/geomtools/powder/find_center.py
index 1df6428..e65261d 100644
--- a/src/geomtools/powder/find_center.py
+++ b/src/geomtools/powder/find_center.py
@@ -43,6 +43,10 @@ def main(argv=None):
                         help="Detector layout")
     parser.add_argument("-c", "--calibrant", required=True,
                         choices=CALIBRANTS, help="Calibrant")
+    parser.add_argument("-s", "--sigma", type=float, default=2,
+                        help="The width of gaussian filter")
+    parser.add_argument("--snr", type=float, default=1.5,
+                        help="Relative threshold for background removal")
     parser.add_argument("-o", "--output", default=".",
                         help="Output directory")
     parser.add_argument("powder_data",
@@ -95,8 +99,10 @@ def main(argv=None):
 
     rings = get_calibrant(args.calibrant)
     borders = BORDER_MASK[detector_type](num_modules)
-    pw = PowderDiffraction(geom, rings, clen, lmd,
-                           border_mask=~borders, make_shadow_mask=True)
+    pw = PowderDiffraction(
+        geom, rings, clen, lmd, sigma=args.sigma, snr=args.snr,
+        border_mask=~borders, make_shadow_mask=True
+    )
     pw.fit(img_mean, mask, num_frames)
     pw.refinement_info()
 
-- 
GitLab