From 7693770b8df1c4830adc2299b46e88a610a0717c Mon Sep 17 00:00:00 2001 From: Karim Ahmed <karim.ahmed@xfel.eu> Date: Wed, 30 Oct 2019 07:55:51 +0100 Subject: [PATCH] fix notebook plotting issues --- cal_tools/cal_tools/plotting.py | 12 +++++++++--- .../DSSC/Characterize_DSSC_Darks_NBC.ipynb | 17 ++++++++--------- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/cal_tools/cal_tools/plotting.py b/cal_tools/cal_tools/plotting.py index 440b4f688..60124779b 100644 --- a/cal_tools/cal_tools/plotting.py +++ b/cal_tools/cal_tools/plotting.py @@ -5,7 +5,7 @@ import numpy as np def show_overview(d, cell_to_preview, gain_to_preview, out_folder=None, infix=None): - + for module, data in d.items(): fig = plt.figure(figsize=(20,20)) grid = AxesGrid(fig, 111, @@ -120,9 +120,15 @@ def create_constant_overview(constant, name, cells, vmin, vmax, entries=3, fig = plt.figure(figsize=(10, 5)) ax = fig.add_subplot(111) table = [] - + for qm in constant.keys(): - d = constant[qm][...,g] + if len(constant[qm].shape) == 4: + d = constant[qm][..., g] + else: + # This case was introduced for DSSC dark + # it uses this function but have a constant + # of shape (x, y, z), unlike AGIPD. + d = constant[qm] #print("{} {}, gain {:0.2f}: mean: {:0.2f}, median: {:0.2f}, std: {:0.2f}".format(name, qm, g, # np.nanmean(d), # np.nanmedian(d), diff --git a/notebooks/DSSC/Characterize_DSSC_Darks_NBC.ipynb b/notebooks/DSSC/Characterize_DSSC_Darks_NBC.ipynb index eb7b7721c..fc2f5b66b 100644 --- a/notebooks/DSSC/Characterize_DSSC_Darks_NBC.ipynb +++ b/notebooks/DSSC/Characterize_DSSC_Darks_NBC.ipynb @@ -8,7 +8,7 @@ "\n", "Author: S. Hauf, Version: 0.1\n", "\n", - "The following code analyzes a set of dark images taken with the AGIPD detector to deduce detector offsets and noise. Data for the detector's three gain stages needs to be present, separated into separate runs.\n", + "The following code analyzes a set of dark images taken with the DSSC detector to deduce detector offsets and noise. Data for the detector is presented in one run and don't acquire multiple gain stages.\n", "\n", "The notebook explicitely does what pyDetLib provides in its offset calculation method for streaming data." ] @@ -26,10 +26,10 @@ "source": [ "cluster_profile = \"noDB\" # The ipcluster profile to use\n", "in_folder = \"/gpfs/exfel/exp/SCS/201931/p900095/raw\" # path to input data, required\n", - "out_folder = \"/gpfs/exfel/data/scratch/ahmedk/test/\" # path to output to, required\n", + "out_folder = \"/gpfs/exfel/data/scratch/ahmedk/test/DSSC\" # path to output to, required\n", "sequences = [0] # sequence files to evaluate.\n", "\n", - "run = 1417 # run number in which data was recorded, required\n", + "run = 1497 # run number in which data was recorded, required\n", "\n", "mem_cells = 0 # number of memory cells used, set to 0 to automatically infer\n", "local_output = False # output constants locally\n", @@ -144,7 +144,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "The following lines will create a queue of files which will the be executed module-parallel. Distiguishing between different gains." + "The following lines will create a queue of files which will the be executed module-parallel. Distinguishing between different gains." ] }, { @@ -164,7 +164,6 @@ "\n", "gmf = gain_map_files(in_folder, offset_runs, sequences, DET_FILE_INSET, QUADRANTS, MODULES_PER_QUAD)\n", "gain_mapped_files, total_sequences, total_file_size = gmf\n", - "\n", "print(\"Will process at total of {} sequences: {:0.2f} GB of data.\".format(total_sequences, total_file_size))" ] }, @@ -504,7 +503,7 @@ "\n", "gain = 0\n", "for mod, data in badpix_g.items():\n", - " plot_badpix_3d(data[...,gain], cols, title=mod, rebin_fac=rebin)" + " plot_badpix_3d(data, cols, title=mod, rebin_fac=rebin)" ] }, { @@ -525,7 +524,7 @@ "outputs": [], "source": [ "create_constant_overview(offset_g, \"Offset (ADU)\", max_cells, 4000, 8000,\n", - " out_folder=out_folder, infix=\"_\".join(offset_runs.values()))" + " out_folder=out_folder, infix=\"_\".join(offset_runs.values()), entries=1)" ] }, { @@ -537,7 +536,7 @@ "outputs": [], "source": [ "create_constant_overview(noise_g, \"Noise (ADU)\", max_cells, 0, 100,\n", - " out_folder=out_folder, infix=\"_\".join(offset_runs.values()))" + " out_folder=out_folder, infix=\"_\".join(offset_runs.values()), entries=1)" ] }, { @@ -549,7 +548,7 @@ "bad_pixel_aggregate_g = OrderedDict()\n", "for m, d in badpix_g.items():\n", " bad_pixel_aggregate_g[m] = d.astype(np.bool).astype(np.float)\n", - "create_constant_overview(bad_pixel_aggregate_g, \"Bad pixel fraction\", max_cells, 0, 0.10, 3,\n", + "create_constant_overview(bad_pixel_aggregate_g, \"Bad pixel fraction\", max_cells, 0, 0.10, entries=1,\n", " out_folder=out_folder, infix=\"_\".join(offset_runs.values()))" ] }, -- GitLab