Skip to content

Commit

Permalink
try
Browse files Browse the repository at this point in the history
  • Loading branch information
lanougue committed Jun 15, 2021
1 parent 19aff5e commit ca652c9
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions xrft/xrft.py
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,7 @@ def dft(
dims=up_dim,
coords={up_dim: newcoords[up_dim]},
) # taking advantage of xarray broadcasting and ordered coordinates
daft[up_dim].attrs.update({"direct_lag": lag.obj})

if true_amplitude:
daft = daft * np.prod(delta_x)
Expand Down Expand Up @@ -539,8 +540,9 @@ def idft(
dim = [d for d in dim if d != real_dim] + [
real_dim
] # real dim has to be moved or added at the end !

if lag is not None:
if lag is None:
lag = [daft[d].attrs.get("direct_lag", 0.0) for d in dim]
else:
if isinstance(lag, float) or isinstance(lag, int):
lag = [lag]
if len(dim) != len(lag):
Expand All @@ -549,8 +551,8 @@ def idft(
msg = "Setting lag with true_phase=False does not guarantee accurate idft."
warnings.warn(msg, Warning)

for d, l in zip(dim, lag):
daft = daft * np.exp(1j * 2.0 * np.pi * daft[d] * l)
for d, l in zip(dim, lag):
daft = daft * np.exp(1j * 2.0 * np.pi * daft[d] * l)

if chunks_to_segments:
daft = _stack_chunks(daft, dim)
Expand Down

0 comments on commit ca652c9

Please sign in to comment.