From 9e0293c0d5f3000b109e04e2919894e7055697fe Mon Sep 17 00:00:00 2001 From: Alessandro Montanari Date: Tue, 28 Apr 2026 12:08:31 +0200 Subject: [PATCH] refactor(src/nectarchain/dqm/bokeh_app): - app_hooks.py: adapt z-range of camera displays to handle outliers --- src/nectarchain/dqm/bokeh_app/app_hooks.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/nectarchain/dqm/bokeh_app/app_hooks.py b/src/nectarchain/dqm/bokeh_app/app_hooks.py index fcab6c7c..7f5a7ae7 100644 --- a/src/nectarchain/dqm/bokeh_app/app_hooks.py +++ b/src/nectarchain/dqm/bokeh_app/app_hooks.py @@ -392,12 +392,20 @@ def make_camera_display(source, parent_key, child_key): mask_high_gain, mask_low_gain = get_bad_pixels_position( source=source, image_shape=image.shape ) - min_colorbar = np.min( - image[~mask_low_gain if "LOW-GAIN" in parent_key else ~mask_high_gain] + # plotting by default range with 99.5% of all events, so that + # outliers do not prevent us from seing the bulk of the data + min_colorbar = np.nanquantile( + image[~mask_low_gain if "LOW-GAIN" in parent_key else ~mask_high_gain], + 0.005, ) - max_colorbar = np.max( - image[~mask_low_gain if "LOW-GAIN" in parent_key else ~mask_high_gain] + max_colorbar = np.nanquantile( + image[~mask_low_gain if "LOW-GAIN" in parent_key else ~mask_high_gain], + 0.995, ) + if max_colorbar == min_colorbar: + # avoid problems with bokeh display + max_colorbar *= 1.05 + min_colorbar *= 0.95 image[mask_low_gain if "LOW-GAIN" in parent_key else mask_high_gain] = 0.0 display = CameraDisplay(geometry=geom)