From 9151eb0e22c065e7d4a2d14bf0dca752cb1d429d Mon Sep 17 00:00:00 2001 From: Liam Gray Date: Sat, 15 Jun 2024 10:11:36 -0700 Subject: [PATCH] fix(delay): subtract sample mean instead of weighted mean --- draco/analysis/delay.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/draco/analysis/delay.py b/draco/analysis/delay.py index 7a9b8b7a..6873264e 100644 --- a/draco/analysis/delay.py +++ b/draco/analysis/delay.py @@ -610,10 +610,9 @@ def _cut_data( # Remove the mean from the data before estimating the spectrum if self.remove_mean: - dmean = (data * weight).mean(axis=0) * tools.invert_no_zero( - weight.mean(axis=0) - ) - data = data - dmean[np.newaxis, :] + # Do not apply this in place to make sure we don't modify + # the input data + data = data - data.mean(axis=0, keepdims=True) # If there are no non-zero data entries skip if (data == 0.0).all(): @@ -819,11 +818,10 @@ def _evaluate(self, data_view, weight_view, out_cont, delays, channel_ind): # If max-likelihood didn't converge in allowed number of iters, reflect this in the mask. if not success: - out_cont.datasets["spectrum_mask"][ - bi - ] = 1 # Indexing into a MemDatasetDistributed object with the + # Indexing into a MemDatasetDistributed object with the # global index bi actually ends up (under the hood) # indexing the underlying MPIArray with the local index. + out_cont.datasets["spectrum_mask"][bi] = 1 out_cont.spectrum[bi] = np.fft.fftshift(spec[-1])