From 748f4c2a47f119c7cf06a72404bdb6dc818c39f5 Mon Sep 17 00:00:00 2001 From: ahmedk <karim.ahmed@xfel.eu> Date: Thu, 8 Feb 2024 11:08:22 +0100 Subject: [PATCH] Small refactors and last piece of fix after testing for storing the right mask array --- .../Gotthard2/Correction_Gotthard2_NBC.ipynb | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/notebooks/Gotthard2/Correction_Gotthard2_NBC.ipynb b/notebooks/Gotthard2/Correction_Gotthard2_NBC.ipynb index 902be1ccd..ec806125d 100644 --- a/notebooks/Gotthard2/Correction_Gotthard2_NBC.ipynb +++ b/notebooks/Gotthard2/Correction_Gotthard2_NBC.ipynb @@ -247,7 +247,7 @@ "if not corr_receiver:\n", " # This part assumes this data_source structure: '{karabo_id}/DET/{receiver_name}:{output_channel}'\n", " if gh2_detector == \"25um\": # For 25um use virtual karabo_das for CALCAT data mapping.\n", - " corr_receiver = data_sources[0].split(\"/\")[-1].split(\":\")[0][:-2]\n", + " corr_receiver = data_sources[0].split(\"/\")[-1].split(\":\")[0]\n", " else:\n", " corr_receiver = data_sources[0].split(\"/\")[-1].split(\":\")[0]\n", " print(f\"Using {corr_receiver} as a receiver name for the corrected data.\")" @@ -443,10 +443,10 @@ "\n", " # Initialize GH2 data and gain arrays to store in corrected files.\n", " if gh2_detector == \"25um\":\n", - " dshape = dc[data_sources[0], \"data.adc\"].shape[:2]\n", - " data_stored = np.zeros((dshape + (1280 * 2,)), dtype=np.float32)\n", - " gain_stored = np.zeros((dshape + (1280 * 2,)), dtype=np.uint8)\n", - " mask_stored = np.zeros((dshape + (1280 * 2,)), dtype=np.uint32)\n", + " dshape_stored = (dc[data_sources[0], \"data.adc\"].shape[:2] + (1280 * 2,))\n", + " data_stored = np.zeros(dshape_stored, dtype=np.float32)\n", + " gain_stored = np.zeros(dshape_stored, dtype=np.uint8)\n", + " mask_stored = np.zeros(dshape_stored, dtype=np.uint32)\n", " else:\n", " data_stored, gain_stored, mask_stored = None, None, None\n", "\n", @@ -484,9 +484,7 @@ " gain_stored[..., i::2] = gain\n", " mask_stored[..., i::2] = mask\n", " else: # \"50um\"\n", - " data_stored = data_corr\n", - " gain_stored = gain\n", - " mask_stored = mask\n", + " data_stored, gain_stored, mask_stored = data_corr, gain, mask\n", "\n", " with DataFile(out_file, \"w\") as ofile:\n", " # Create INDEX datasets.\n", @@ -526,7 +524,7 @@ " f\"data.{field}\", data=dc[src, f\"data.{field}\"].ndarray(),\n", " chunks=(chunks_data, data_corr.shape[1])\n", " )\n", - " outp_source.create_compressed_key(f\"data.mask\", data=mask)\n", + " outp_source.create_compressed_key(f\"data.mask\", data=mask_stored)\n", " step_timer.done_step(\"Storing data\")" ] }, -- GitLab