From 40c699b9dd7f80c0f2adf83e7b03e9c021b65f92 Mon Sep 17 00:00:00 2001
From: ahmedk <karim.ahmed@xfel.eu>
Date: Fri, 12 May 2023 09:29:03 +0200
Subject: [PATCH] remove the hack for specific proposal to
 remove_bias_voltage_if_zero flag

---
 notebooks/pnCCD/Correct_pnCCD_NBC.ipynb | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/notebooks/pnCCD/Correct_pnCCD_NBC.ipynb b/notebooks/pnCCD/Correct_pnCCD_NBC.ipynb
index 30998a4e4..1762af6bd 100644
--- a/notebooks/pnCCD/Correct_pnCCD_NBC.ipynb
+++ b/notebooks/pnCCD/Correct_pnCCD_NBC.ipynb
@@ -49,6 +49,7 @@
     "cal_db_interface = \"tcp://max-exfl016:8015\" # calibration DB interface to use\n",
     "cal_db_timeout = 300000 # timeout on caldb requests\n",
     "creation_time = \"\"  # The timestamp to use with Calibration DB. Required Format: \"YYYY-MM-DD hh:mm:ss\" e.g. 2019-07-04 11:02:41\n",
+    "remove_bias_voltage_if_zero = True  # This flag enables removing bias voltage from the conditions if a 0 value is read from RAW data. This is useful when the corresponding constants for old RAW had no bias voltage because of a mistake in control data. e.g. p002857\n",
     "\n",
     "# Booleans for selecting corrections to apply.\n",
     "only_offset = False # Only, apply offset.\n",
@@ -97,7 +98,6 @@
     "from pathlib import Path\n",
     "warnings.filterwarnings('ignore')\n",
     "\n",
-    "import h5py\n",
     "import matplotlib.pyplot as plt\n",
     "import numpy as np\n",
     "import pasha as psh\n",
@@ -172,7 +172,6 @@
     "\n",
     "# extract control data\n",
     "step_timer.start()\n",
-    "bias_voltage = 0\n",
     "ctrl_data = pnccdlib.PnccdCtrl(run_dc, karabo_id)\n",
     "if bias_voltage == 0.:\n",
     "    bias_voltage = ctrl_data.get_bias_voltage()\n",
@@ -313,11 +312,10 @@
     "if relgain:\n",
     "    constant_names += [\"RelativeGainCCD\"]\n",
     "\n",
-    "# Adding a hack for data of proposal p002857.\n",
-    "# As it had no recorded bias voltage values.\n",
-    "# This is not an acceptable value,\n",
-    "# which means it was most probably a mistake during operation. \n",
-    "if bias_voltage == 0 and \"p002857/\" in str(in_folder):\n",
+    "# An old proposal could have had 0 bias voltage,\n",
+    "# hence the dark injected constants in the past could be missing bias voltage.\n",
+    "# For example proposal 002857\n",
+    "if bias_voltage == 0 and remove_bias_voltage_if_zero:\n",
     "    bias_voltage = None\n",
     "\n",
     "pnccd_cal = PNCCD_CalibrationData(\n",
-- 
GitLab