diff --git a/cal_tools/cal_tools/agipdlib.py b/cal_tools/cal_tools/agipdlib.py index 01d79c8983062ca3fcca6ff68029e09e8b4d8747..898aff6dfe213aa72963b04501eb71e32e3f3059 100644 --- a/cal_tools/cal_tools/agipdlib.py +++ b/cal_tools/cal_tools/agipdlib.py @@ -972,7 +972,7 @@ class AgipdCorrections: # if we have enough pixels in medium or low gain and # correction via hist matching is requested to this now gcrit = np.count_nonzero(gain[i, ...] > 0) > 1000 - if gcrit and self.baseline_corr_using_hmatch: + if gcrit and self.baseline_corr_using_hmatch and hasattr(self, "rel_gain"): dd2 = self.correct_baseline_via_hist(im[i, ...], rel_cor[i, ...], gain[i, ...]) diff --git a/notebooks/AGIPD/AGIPD_Correct_and_Verify.ipynb b/notebooks/AGIPD/AGIPD_Correct_and_Verify.ipynb index 324ec316c198653cec782701fd61649304690eac..9069ee16f71ca1fe347d6506040b93ec71b513ef 100644 --- a/notebooks/AGIPD/AGIPD_Correct_and_Verify.ipynb +++ b/notebooks/AGIPD/AGIPD_Correct_and_Verify.ipynb @@ -41,10 +41,8 @@ "photon_energy = 9.2 # photon energy in keV\n", "index_v = 2 # version of RAW index type\n", "nodb = False # if set only file-based constants will be used\n", - "blc_noise = False # if set, baseline correction via noise peak location is attempted\n", "blc_noise_threshold = 5000 # above this mean signal intensity now baseline correction via noise is attempted\n", "blc_hist = False # if set, base line correction via histogram matching is attempted \n", - "match_asics = False # if set, inner ASIC borders are matched to the same signal level\n", "corr_asic_diag = False # if set, diagonal drop offs on ASICs are correted \n", "melt_snow = \"\" # if set to \"none\" snowy pixels are identified and resolved to NaN, if set to \"interpolate\", the value is interpolated from neighbouring pixels\n", "cal_db_timeout = 30000 # in milli seconds\n", @@ -56,13 +54,17 @@ "force_hg_if_below = 1000 # set to a value other than 0 to force a pixel into high gain if it's high gain offset subtracted value is below this threshold\n", "force_mg_if_below = 1000 # set to a value other than 0 to force a pixel into medium gain if it's medium gain offset subtracted value is below this threshold\n", "mask_noisy_adc = 0.25 # set to a value other than 0 and below 1 to mask entire ADC if fraction of noisy pixels is above\n", - "adjust_mg_baseline = False # adjust medium gain baseline to match highest high gain value\n", "acq_rate = 0. # the detector acquisition rate, use 0 to try to auto-determine\n", + "\n", + "# Correction Booleans\n", + "only_offset = False # Apply only Offset correction.\n", + "pc_corr = False # Apply only Pulse Capictor correction.\n", + "ff_corr = False # Apply only Flat Field correction.\n", + "blc_noise = False # if set, baseline correction via noise peak location is attempted\n", + "match_asics = False # if set, inner ASIC borders are matched to the same signal level\n", + "adjust_mg_baseline = False # adjust medium gain baseline to match highest high gain value\n", "dont_zero_nans = False # do not zero NaN values in corrected data\n", "dont_zero_orange = False # do not zero very negative and very large values\n", - "only_offset = False # Apply only Offset correction.\n", - "only_slopespc = False # Apply only Pulse Capictor correction.\n", - "only_slopesff = False # Apply only Flat Field correction.\n", "\n", "def balance_sequences(in_folder, run, sequences, sequences_per_node):\n", " import glob\n", @@ -104,12 +106,12 @@ "if not only_offset:\n", " \n", " # Apply PC correction only if requested\n", - " if slopespc:\n", - " corr_bools[\"SlopesPC\"] = only_slopespc\n", + " if pc_corr:\n", + " corr_bools[\"slopesPC\"] = pc_corr\n", " \n", " # Apply FF correction only if requested\n", - " if slopesff:\n", - " corr_bools[\"SlopesFF\"] = only_slopesff\n", + " if ff_corr:\n", + " corr_bools[\"slopesFF\"] = ff_corr\n", " \n", " corr_bools[\"adjust_mg_baseline\"] = adjust_mg_baseline\n", " corr_bools[\"do_rel_gain\"] = relative_gain\n", @@ -486,9 +488,11 @@ "\n", " blc_noise_threshold, blc_hist, melt_snow = special_opts\n", " if not corr_bools[\"only_offset\"]:\n", - " agipd_corr.baseline_corr_noise_threshold = blc_noise_threshold\n", - " agipd_corr.baseline_corr_using_hmatch = blc_hist\n", - " agipd_corr.melt_snow = melt_snow\n", + " blc_hist = False\n", + " melt_snow = False\n", + " agipd_corr.baseline_corr_noise_threshold = blc_noise_threshold\n", + " agipd_corr.baseline_corr_using_hmatch = blc_hist\n", + " agipd_corr.melt_snow = melt_snow\n", " try:\n", " agipd_corr.get_valid_image_idx()\n", " except IOError:\n",