From bda046f3e7698d0800fa2e5b4441e8c97a728b33 Mon Sep 17 00:00:00 2001
From: Robert Rosca <robert.rosca@xfel.eu>
Date: Tue, 9 Feb 2021 11:40:23 +0100
Subject: [PATCH] Fix unset variables, fix mutable keyword argument

---
 cal_tools/cal_tools/agipdlib.py  | 5 ++++-
 cal_tools/cal_tools/lpdlib.py    | 2 +-
 cal_tools/cal_tools/metrology.py | 2 +-
 3 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/cal_tools/cal_tools/agipdlib.py b/cal_tools/cal_tools/agipdlib.py
index 050bf902c..35aedb6fd 100644
--- a/cal_tools/cal_tools/agipdlib.py
+++ b/cal_tools/cal_tools/agipdlib.py
@@ -148,7 +148,7 @@ class AgipdCorrections:
     def __init__(self, max_cells, max_pulses,
                  h5_data_path="INSTRUMENT/SPB_DET_AGIPD1M-1/DET/{}CH0:xtdf/",
                  h5_index_path="INDEX/SPB_DET_AGIPD1M-1/DET/{}CH0:xtdf/",
-                 corr_bools={}):
+                 corr_bools: Optional[dict] = None):
         """
         Initialize an AgipdCorrections Class
 
@@ -194,6 +194,9 @@ class AgipdCorrections:
 
         """
 
+        if corr_bools is None:
+            corr_bools = {}
+
         # Data description
         self.h5_data_path = h5_data_path
         self.h5_index_path = h5_index_path
diff --git a/cal_tools/cal_tools/lpdlib.py b/cal_tools/cal_tools/lpdlib.py
index 054cebb74..dbf86d33f 100644
--- a/cal_tools/cal_tools/lpdlib.py
+++ b/cal_tools/cal_tools/lpdlib.py
@@ -88,7 +88,7 @@ class LpdCorrections:
         self.do_ff = do_ff
         filter_modules = []
         self.filter_cells = [0, 1] if channel in filter_modules else []
-        self.cnl = True  # correct_non_linear
+        self.cnl = correct_non_linear
         self.karabo_data_mode = karabo_data_mode
         self.linear_between = linear_between
         self.mark_nonlin = mark_non_lin_region
diff --git a/cal_tools/cal_tools/metrology.py b/cal_tools/cal_tools/metrology.py
index 8a6c0affc..6c7e807d9 100644
--- a/cal_tools/cal_tools/metrology.py
+++ b/cal_tools/cal_tools/metrology.py
@@ -338,7 +338,7 @@ def returnPositioned2(geometry_file, modules, dquads):
         for i in range(numberOfTiles):
             # This is the top left corner of the tile with
             # respect to the top left corner of the supermodule
-            y0, x0 = bottomRightCornerCoordinates[i] + dquads[q]
+            y0, x0 = bottomRightCornerCoordinates[i] + dquads[q] - offset  # TODO: check subtraction of offsets works as expected
             x0 *= 2
             y0 *= 2
             td = tileData[i][:,:,:]
-- 
GitLab