diff --git a/notebooks/AGIPD/Characterize_AGIPD_Gain_Darks_NBC.ipynb b/notebooks/AGIPD/Characterize_AGIPD_Gain_Darks_NBC.ipynb index 58aaf3e526a2241897dc50d5a115bc3288551c8e..9dc02f12d81f3453a601beaa1fe3ca37819efc3a 100644 --- a/notebooks/AGIPD/Characterize_AGIPD_Gain_Darks_NBC.ipynb +++ b/notebooks/AGIPD/Characterize_AGIPD_Gain_Darks_NBC.ipynb @@ -135,7 +135,7 @@ "gains = np.arange(3)\n", "\n", "max_cells = mem_cells\n", - " \n", + "\n", "offset_runs = OrderedDict()\n", "offset_runs[\"high\"] = run_high\n", "offset_runs[\"med\"] = run_med\n", @@ -203,7 +203,7 @@ " gsettings.append(get_gain_setting(control_fname, h5path_ctrl))\n", " if not all(g == gsettings[0] for g in gsettings):\n", " raise ValueError(f\"Different gain settings for the 3 input runs {gsettings}\")\n", - " gain_setting = gsettings[0] \n", + " gain_setting = gsettings[0]\n", " except Exception as e:\n", " print(f'Error while reading gain setting from: \\n{control_fname}')\n", " print(f'Error: {e}')\n", @@ -228,7 +228,7 @@ "h5path = h5path.format(karabo_id, receiver_id)\n", "h5path_idx = h5path_idx.format(karabo_id, receiver_id)\n", "\n", - "if bias_voltage == 0: \n", + "if bias_voltage == 0:\n", " # Read the bias voltage from files, if recorded.\n", " # If not available, make use of the historical voltage the detector is running at\n", " bias_voltage = get_bias_voltage(control_names[0], karabo_id_control)\n", @@ -620,15 +620,15 @@ " acquisition_rate=acq_rate,\n", " gain_setting=gain_setting)\n", " if db_output:\n", - " md = send_to_db(db_module, karabo_id, dconst, condition, file_loc, \n", + " md = send_to_db(db_module, karabo_id, dconst, condition, file_loc,\n", " report, cal_db_interface, creation_time=creation_time,\n", " timeout=cal_db_timeout)\n", "\n", " if local_output:\n", - " md = save_const_to_h5(db_module, karabo_id, dconst, condition, dconst.data, \n", + " md = save_const_to_h5(db_module, karabo_id, dconst, condition, dconst.data,\n", " file_loc, report, creation_time, out_folder)\n", " print(f\"Calibration constant {const} is stored locally.\\n\")\n", - " \n", + "\n", " print(\"Constants parameter conditions are:\\n\")\n", " print(f\"• memory_cells: {max_cells}\\n• bias_voltage: {bias_voltage}\\n\"\n", " f\"• acquisition_rate: {acq_rate}\\n• gain_setting: {gain_setting}\\n\"\n", @@ -723,18 +723,18 @@ " BadPixels.OFFSET_OUT_OF_THRESHOLD.value: (BadPixels.OFFSET_OUT_OF_THRESHOLD.name, '#00FF0080'),\n", " BadPixels.GAIN_THRESHOLDING_ERROR.value: (BadPixels.GAIN_THRESHOLDING_ERROR.name, '#FF40FF40'),\n", " BadPixels.OFFSET_OUT_OF_THRESHOLD.value | BadPixels.NOISE_OUT_OF_THRESHOLD.value: ('OFFSET_OUT_OF_THRESHOLD + NOISE_OUT_OF_THRESHOLD', '#DD00DD80'),\n", - " BadPixels.OFFSET_OUT_OF_THRESHOLD.value | BadPixels.NOISE_OUT_OF_THRESHOLD.value | \n", + " BadPixels.OFFSET_OUT_OF_THRESHOLD.value | BadPixels.NOISE_OUT_OF_THRESHOLD.value |\n", " BadPixels.GAIN_THRESHOLDING_ERROR.value: ('MIXED', '#BFDF009F')}\n", "\n", "if high_res_badpix_3d:\n", " display(Markdown(\"\"\"\n", - " \n", + "\n", " ## Global Bad Pixel Behaviour ##\n", "\n", - " The following plots show the results of bad pixel evaluation for all evaluated memory cells. \n", - " Cells are stacked in the Z-dimension, while pixels values in x/y are rebinned with a factor of 2. \n", - " This excludes single bad pixels present only in disconnected pixels. \n", - " Hence, any bad pixels spanning at least 4 pixels in the x/y-plane, or across at least two memory cells are indicated. \n", + " The following plots show the results of bad pixel evaluation for all evaluated memory cells.\n", + " Cells are stacked in the Z-dimension, while pixels values in x/y are rebinned with a factor of 2.\n", + " This excludes single bad pixels present only in disconnected pixels.\n", + " Hence, any bad pixels spanning at least 4 pixels in the x/y-plane, or across at least two memory cells are indicated.\n", " Colors encode the bad pixel type, or mixed type.\n", "\n", " \"\"\"))\n", @@ -847,10 +847,10 @@ " for bit in bits:\n", " l_data_old.append(np.count_nonzero(old_const['BadPixelsDark'][:, :, :, gain] & bit.value))\n", "\n", - " l_data_name = ['All bad pixels', 'NOISE_OUT_OF_THRESHOLD', \n", + " l_data_name = ['All bad pixels', 'NOISE_OUT_OF_THRESHOLD',\n", " 'OFFSET_OUT_OF_THRESHOLD', 'OFFSET_NOISE_EVAL_ERROR', 'GAIN_THRESHOLDING_ERROR']\n", "\n", - " l_threshold = ['', f'{thresholds_noise_sigma}' f'{thresholds_noise_hard[gain]}', \n", + " l_threshold = ['', f'{thresholds_noise_sigma}' f'{thresholds_noise_hard[gain]}',\n", " f'{thresholds_offset_sigma}' f'{thresholds_offset_hard[gain]}',\n", " '', f'{thresholds_gain_sigma}']\n", "\n", @@ -873,9 +873,9 @@ "\n", "'''))\n", "if len(table)>0:\n", - " md = display(Latex(tabulate.tabulate(table, tablefmt='latex', \n", - " headers=[\"Pixel type\", \"Threshold\", \n", - " \"New constant\", \"Old constant\"]))) " + " md = display(Latex(tabulate.tabulate(table, tablefmt='latex',\n", + " headers=[\"Pixel type\", \"Threshold\",\n", + " \"New constant\", \"Old constant\"])))" ] }, { @@ -884,9 +884,9 @@ "metadata": {}, "outputs": [], "source": [ - "header = ['Parameter', \n", - " \"New constant\", \"Old constant \", \n", - " \"New constant\", \"Old constant \", \n", + "header = ['Parameter',\n", + " \"New constant\", \"Old constant \",\n", + " \"New constant\", \"Old constant \",\n", " \"New constant\", \"Old constant \",\n", " \"New constant\", \"Old constant \"]\n", "\n", @@ -896,15 +896,15 @@ " ['Offset', 'Noise', 'ThresholdsDark']\n", "\n", "for const in constants:\n", - " \n", + "\n", " if const == 'ThresholdsDark':\n", " table = [['','HG-MG threshold', 'HG-MG threshold', 'MG-LG threshold', 'MG-LG threshold']]\n", - " else: \n", + " else:\n", " table = [['','High gain', 'High gain', 'Medium gain', 'Medium gain', 'Low gain', 'Low gain']]\n", "\n", " for qm in res.keys():\n", " data = np.copy(res[qm][const])\n", - " \n", + "\n", " if const == 'ThresholdsDark':\n", " data[...,0][res[qm]['BadPixelsDark'][...,0]>0] = np.nan\n", " data[...,1][res[qm]['BadPixelsDark'][...,1]>0] = np.nan\n", @@ -937,7 +937,7 @@ " table.append(line)\n", "\n", " display(Markdown('### {} [ADU], good pixels only ###'.format(const)))\n", - " md = display(Latex(tabulate.tabulate(table, tablefmt='latex', headers=header))) " + " md = display(Latex(tabulate.tabulate(table, tablefmt='latex', headers=header)))" ] } ],