diff --git a/src/calng/Gotthard2Correction.py b/src/calng/Gotthard2Correction.py index 24429baeba5aba06701019d85af15ae626073ffe..64578f92dea1a90b2a5663efa94eb2a18d7f54a8 100644 --- a/src/calng/Gotthard2Correction.py +++ b/src/calng/Gotthard2Correction.py @@ -19,7 +19,11 @@ from karabo.bound import ( from . import base_calcat, utils from ._version import version as deviceVersion -from .base_correction import BaseCorrection, add_correction_step_schema +from .base_correction import ( + BaseCorrection, + add_correction_step_schema, + preview_schema, +) _pretend_pulse_table = np.arange(2720, dtype=np.uint8) @@ -235,11 +239,16 @@ class Gotthard2Correction(BaseCorrection): .dataSchema(streak_preview_schema) .commit(), + OUTPUT_CHANNEL(expected) + .key("preview.outputFrameSums") + .dataSchema(preview_schema) + .commit(), + FLOAT_ELEMENT(expected) .key("preview.replaceNanWith") - .displayedName("Replace streak NaNs by by") + .displayedName("Replace streak/sum NaNs by") .assignmentOptional() - .defaultValue(-1000) + .defaultValue(0) .reconfigurable() .commit(), ) @@ -340,31 +349,27 @@ class Gotthard2Correction(BaseCorrection): self._write_output(data_hash, metadata) if do_generate_preview: - self._write_preview_outputs( - ( - ("preview.outputRaw", preview_raw), - ("preview.outputCorrected", preview_corrected), - ), - metadata, - ) - # custom additional preview for this 1D detector streak_preview = buffer_array.copy() replacement = self.unsafe_get("preview.replaceNanWith") streak_preview[np.isnan(streak_preview)] = replacement streak_preview[np.isinf(streak_preview)] = replacement - self.writeChannel( - "preview.outputStreak", - Hash( - "image.data", - ImageData( - streak_preview, - Dims(*buffer_array.shape), - Encoding.GRAY, - bitsPerPixel=32, + frame_sums = np.sum(streak_preview, axis=0) + self._write_preview_outputs( + ( + ("preview.outputRaw", preview_raw), + ("preview.outputCorrected", preview_corrected), + ( + "preview.outputStreak", + ImageData( + streak_preview, + Dims(*streak_preview.shape), + Encoding.GRAY, + bitsPerPixel=32, + ), ), - "trainId", - train_id, + ("preview.outputFrameSums", frame_sums), ), + metadata, ) def _load_constant_to_runner(self, constant, constant_data):