Skip to content

Commit

Permalink
fix correlate doc build (#402)
Browse files Browse the repository at this point in the history
  • Loading branch information
d-chambers authored Jun 13, 2024
1 parent 9bbae76 commit b6edf30
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
9 changes: 4 additions & 5 deletions dascore/proc/correlate.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,7 @@ def correlate_shift(patch, dim, undo_weighting=True):
data = np.fft.fftshift(patch.data, axes=axis)
if undo_weighting:
data = data / to_float(coord.step)
# so it appears (from testing) there is one lest sample on the positive
# side.
step = to_float(coord.step)
step = coord.step
new_start = -np.ceil((len(coord) - 1) / 2) * step
new_end = np.ceil((len(coord) - 1) / 2) * step
new_coord = dc.get_coord(start=new_start, stop=new_end, step=step)
Expand Down Expand Up @@ -182,8 +180,9 @@ def correlate(
-----
1 - The cross-correlation is performed in the frequency domain.
2 - The output dimension is opposite of the one specified in kwargs, has
the units of float, and the string "lag_" prepended. For example, "lag_time".
2 - The output dimension is opposite of the one specified in kwargs and
shares a name with the original coord except the string "lag_" is
prepended. For example, "lag_time".
"""
if lag is not None:
msg = "Correlate lag is deprecated. Simply use on the output patch."
Expand Down
4 changes: 3 additions & 1 deletion docs/recipes/correlate.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,7 @@ patch = dc.get_example_patch(
corr = patch.correlate(distance=3, samples=True)
corr.viz.waterfall();
# Note we squeeze the last dimension to get 2D patch
corr.squeeze().viz.waterfall();
```
2 changes: 1 addition & 1 deletion tests/test_proc/test_correlate.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def test_auto_correlation(self, random_dft_patch):
# ensure the max value happens at zero lag time.
time_ax = auto_patch.dims.index("lag_time")
argmax = np.argmax(random_dft_patch.data, axis=time_ax)
assert np.allclose(coord_array[argmax], 0)
assert np.all(coord_array[argmax] == dc.to_timedelta64(0))


class TestCorrelateInternal:
Expand Down

0 comments on commit b6edf30

Please sign in to comment.