From 55a15e69ca7c4938063832c32f29419bfff69b36 Mon Sep 17 00:00:00 2001
From: Egor Sobolev <egor.sobolev@xfel.eu>
Date: Mon, 22 Jul 2024 17:01:43 +0200
Subject: [PATCH] Create empty mask if there is no mask in crystfel geometry
 file

---
 src/geomtools/detector/crystfel_frm.py | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/src/geomtools/detector/crystfel_frm.py b/src/geomtools/detector/crystfel_frm.py
index 6ae4e1b..0319151 100644
--- a/src/geomtools/detector/crystfel_frm.py
+++ b/src/geomtools/detector/crystfel_frm.py
@@ -4,6 +4,9 @@ import pandas as pd
 from cfelpyutils.geometry import load_crystfel_geometry
 from natsort import natsorted
 
+from .geom import get_detector_shape
+
+
 HEADER_TEMPLATE = """\
 ; {detector} geometry file written by geomtools
 ; You may need to edit this file to add:
@@ -163,5 +166,8 @@ def read_crystfel_geom(filename, indexes=dict()):
                 (np.bitwise_and(mask, mask_goodbits) != mask_goodbits) |
                 (np.bitwise_and(mask, mask_badbits) != 0)
             )
+    else:
+        shape = get_detector_shape(panels)
+        mask = np.zeros(shape, bool)
 
     return panels, geom.beam, mask
-- 
GitLab