From 336e9994e87e0c21807f1cbd3f06d2ab1029e055 Mon Sep 17 00:00:00 2001 From: Roy Smart Date: Wed, 6 Nov 2024 00:07:49 -0700 Subject: [PATCH] Modified `opitka.sensors.AbstractImagingSensor.readout()` to more gracefully deal with negative photons. --- optika/sensors/_sensors.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/optika/sensors/_sensors.py b/optika/sensors/_sensors.py index 9388d2e..df980f0 100644 --- a/optika/sensors/_sensors.py +++ b/optika/sensors/_sensors.py @@ -116,9 +116,11 @@ def readout( where = where & rays.unvignetted + sgn = np.sign(rays.intensity) + rays = dataclasses.replace( rays, - intensity=rays.intensity * timedelta, + intensity=np.abs(rays.intensity) * timedelta, ) normal = self.sag.normal(rays.position) @@ -128,6 +130,11 @@ def readout( normal=normal, ) + rays = dataclasses.replace( + rays, + intensity=sgn * rays.intensity, + ) + rays = self.material.charge_diffusion( rays=rays, normal=normal, @@ -151,7 +158,7 @@ def readout( wavelength=np.mean(rays.wavelength, axis=axis), position=hist.inputs, ), - outputs=hist.outputs, + outputs=np.maximum(hist.outputs, 0), )