Skip to content

Commit febb44d

Browse files
authored
Merge pull request #21 from roxyboy/coords
More robust coordinate setting for the wavelet
2 parents a358a68 + a18fab1 commit febb44d

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

xwavelet/tests/test_wavelet.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -120,12 +120,12 @@ def test_isotropic_ps_slope(chunk, N=128, dL=1.0, amp=1e0, slope=-3.0, xo=50):
120120
dL,
121121
amp,
122122
slope,
123-
other_dim_sizes=[20],
123+
other_dim_sizes=[30],
124124
dim_order=True,
125125
)
126126

127127
if chunk:
128-
theta = theta.chunk({"d0": 30, "y": 64, "x": 64})
128+
theta = theta.chunk({"d0": 5, "y": 64, "x": 64})
129129

130130
s = xr.DataArray(
131131
np.linspace(0.1, 1.0, 20),

xwavelet/wavelet.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,11 @@ def _morlet(xo, ntheta, a, s, y, x, dim):
7979
th = xr.DataArray(th, dims=["angle"], coords={"angle": th})
8080

8181
# rotated positions
82-
yp = np.sin(th) * s**-1 * y
83-
xp = np.cos(th) * s**-1 * x
82+
yp = np.sin(th) * s**-1 * (y - y.mean())
83+
xp = np.cos(th) * s**-1 * (x - x.mean())
8484

8585
arg1 = 2j * np.pi * ko * (yp - xp)
86-
arg2 = -(x**2 + y**2) / 2 / s**2 / xo**2
86+
arg2 = -((x - x.mean()) ** 2 + (y - y.mean()) ** 2) / 2 / s**2 / xo**2
8787
m = a * np.exp(arg1) * np.exp(arg2)
8888

8989
return m, th

0 commit comments

Comments
 (0)