From 86fa6eb592ff428db150d048831cddcfa5941e6c Mon Sep 17 00:00:00 2001 From: ahmedk <karim.ahmed@xfel.eu> Date: Thu, 22 Jun 2023 15:18:45 +0200 Subject: [PATCH] convert f8 nan before converting to uint32 --- notebooks/LPD/LPD_Correct_Fast.ipynb | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/notebooks/LPD/LPD_Correct_Fast.ipynb b/notebooks/LPD/LPD_Correct_Fast.ipynb index d9ff08114..bed0e0d22 100644 --- a/notebooks/LPD/LPD_Correct_Fast.ipynb +++ b/notebooks/LPD/LPD_Correct_Fast.ipynb @@ -345,6 +345,12 @@ "def prepare_constants(wid, index, aggregator):\n", " consts = const_data.get(aggregator, {})\n", " def _prepare_data(calibration_name, dtype):\n", + " # Some old BadPixels constants have <f8 dtype.\n", + " # Convert nan to float 0 to avoid having 2147483648 after\n", + " # converting float64 to uint32.\n", + " if \"BadPixels\" in calibration_name:\n", + " consts[calibration_name] = np.nan_to_num(\n", + " consts[calibration_name], nan=0.0)\n", " return consts[calibration_name] \\\n", " .transpose(constant_order[calibration_name]) \\\n", " .astype(dtype, copy=True) # Make sure array is contiguous.\n", -- GitLab