Skip to content

Commit

Permalink
fix(delay): subtract sample mean instead of weighted mean
Browse files Browse the repository at this point in the history
  • Loading branch information
ljgray committed Jun 17, 2024
1 parent e389b2b commit 9151eb0
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions draco/analysis/delay.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down Expand Up @@ -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])

Expand Down

0 comments on commit 9151eb0

Please sign in to comment.