Skip to content
Snippets Groups Projects

Per pulse pedestal subtraction

Open Danilo Enoque Ferreira de Lima requested to merge fix/per_pulse_pedestal_subtraction into main
1 file
+ 16
4
Compare changes
  • Side-by-side
  • Inline
+ 16
4
@@ -508,10 +508,22 @@ class SelectRelevantLowResolution(TransformerMixin, BaseEstimator):
if self.delta_tof is not None:
first = max(0, self.tof_start - self.delta_tof)
last = min(X[self.channels[0]].shape[1], self.tof_start + self.delta_tof)
y = {channel: [item[:, (first + delta):(last + delta)] - self.pedestal[channel]
for delta in pulse_spacing[channel]]
for channel, item in X.items()
if channel in self.channels}
# subtract pedestal per channel, per pulse
for ch in channels:
# mean of test data, over ensemble
mean_trace[ch] = X[ch].mean(0)
# for each pulse, get a pedestal and subtract it from the trace
for p in pulse_spacing[ch]:
# slice a pulse
s = slice(first + p - self.delta_tof - 1, first + p + self.delta_tof + 1)
# get first 10 points in pulse and take its average
pulse_pedestal = mean_trace[ch][s][:10].mean()
# subtract the pedestal from the trace
X[ch][:, s] = X[ch][:, s] - pulse_pedestal
# y = {channel: [item[:, (first + delta):(last + delta)] - self.pedestal[channel]
# for delta in pulse_spacing[channel]]
# for channel, item in X.items()
# if channel in self.channels}
# convert to Numpy if it is a Dask array
y = {ch: [item.compute().astype(np.float32) if isinstance(item, da.Array) else item.astype(np.float32) for item in v]
for ch, v in y.items()}
Loading