diff --git a/src/calng/Gotthard2Correction.py b/src/calng/Gotthard2Correction.py index d03eeb83a52f003045414503d365cbcac6424b6f..126e0dee2b3bc15f3c3756d1642a850e601a42ea 100644 --- a/src/calng/Gotthard2Correction.py +++ b/src/calng/Gotthard2Correction.py @@ -2,6 +2,7 @@ import enum import numpy as np from karabo.bound import ( + FLOAT_ELEMENT, IMAGEDATA_ELEMENT, KARABO_CLASSINFO, NODE_ELEMENT, @@ -232,6 +233,14 @@ class Gotthard2Correction(BaseCorrection): .key("preview.outputStreak") .dataSchema(streak_preview_schema) .commit(), + + FLOAT_ELEMENT(expected) + .key("preview.replaceNanWith") + .displayedName("Replace streak NaNs by by") + .assignmentOptional() + .defaultValue(-1000) + .reconfigurable() + .commit(), ) Gotthard2CalcatFriend.add_schema(expected, Gotthard2Correction._managed_keys) @@ -334,12 +343,16 @@ class Gotthard2Correction(BaseCorrection): 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( - buffer_array, + streak_preview, Dims(*buffer_array.shape), Encoding.GRAY, bitsPerPixel=32,