hotfix: fix incorrect integration scheme, move to time integration as Bukartas 2021 doccomp.

This commit is contained in:
Pim Nelissen
2026-05-06 00:37:26 +02:00
parent 2a15ae12f6
commit bc538ff5dd
2 changed files with 23 additions and 5 deletions

View File

@ -108,6 +108,7 @@ def calculate_counts_along_path(
landscape: "Landscape", landscape: "Landscape",
detector: "Detector", detector: "Detector",
velocity: float, velocity: float,
t_acq: float,
points_per_segment: int = 10, points_per_segment: int = 10,
bkg_cps_input: int | None = None, bkg_cps_input: int | None = None,
seed: int | None = None seed: int | None = None
@ -166,10 +167,26 @@ def calculate_counts_along_path(
) )
cps_with_bg = cps + bkg cps_with_bg = cps + bkg
# reshape so each segment is on a row
cps_per_seg = cps_with_bg.reshape(num_segments, points_per_segment)
du = s[1] - s[0] # Integrate along time dimension. see e.g. Bukartas (2021 doccomp.)
int_counts = np.trapezoid(cps_per_seg, dx=du, axis=1) / velocity t = s / abs(velocity)
return original_distances[1:], s, cps_with_bg, int_counts, np.mean(bkg) # acquisition bins
t_bins = np.arange(0, t[-1] + t_acq, t_acq)
int_counts = np.zeros(len(t_bins) - 1)
acq_points = np.zeros(len(t_bins) - 1)
for i in range(len(t_bins) - 1):
mask = (t >= t_bins[i]) & (t < t_bins[i + 1])
int_counts[i] = np.trapezoid(cps_with_bg[mask], t[mask])
acq_points[i] = np.mean(s[mask])
return (
acq_points[:-1],
s[:-1],
cps_with_bg[:-1],
int_counts[:-1],
np.mean(bkg)
)

View File

@ -49,6 +49,7 @@ class SimulationEngine:
self.detector, self.detector,
velocity=self.runtime_spec.speed, velocity=self.runtime_spec.speed,
bkg_cps_input=self.sim_spec.bkg_cps, bkg_cps_input=self.sim_spec.bkg_cps,
t_acq=self.runtime_spec.acquisition_time,
seed=self.sim_spec.seed seed=self.sim_spec.seed
) )
) )