trouble with real=True in dft
See original GitHub issueI am having some trouble using the real fft. I have a time series of temperature data:
da = surf_temp_1selection.copy()
months = np.arange(da.time.size)+1
da.time.values = months
da = da.chunk({'time':None})
da = da.mean(dim={'xt_ocean', 'yt_ocean'})
da
<xarray.DataArray 'surface_temp' (time: 2520)>
dask.array<mean_agg-aggregate, shape=(2520,), dtype=float32, chunksize=(2520,), chunktype=numpy.ndarray>
Coordinates:
* time (time) int64 1 2 3 4 5 6 7 8 ... 2514 2515 2516 2517 2518 2519 2520
When I use dft
without the real=True
flag all seems good:
dahat = xrft.dft(da, dim=['time'], window=True)
dahat
<xarray.DataArray 'rechunk-merge-43b3f58ebe71665aef5d349f10b36e8c' (freq_time: 2520)>
dask.array<rechunk-merge, shape=(2520,), dtype=complex128, chunksize=(2520,), chunktype=numpy.ndarray>
Coordinates:
* freq_time (freq_time) float64 -0.5 -0.4996 ... 0.4992 0.4996
freq_time_spacing float64 0.0003968
But when I give real=True
I get:
dahat = xrft.dft(da, dim=['time'], window=True, real=True)
dahat
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-89-2e819cfb9956> in <module>
6
7 print(da)
----> 8 dahat = xrft.dft(da, dim=['time'], window=True, real=True)
9 print(" ");print(" ");print(" ");
10 print(dahat)
/g/data3/hh5/public/apps/miniconda3/envs/analysis3-19.10/lib/python3.6/site-packages/xrft/xrft.py in dft(da, spacing_tol, dim, real, shift, detrend, window, chunks_to_segments)
250
251 rawdims = da.dims
--> 252 da, trans = _transpose(da, real)
253 if dim is None:
254 dim = list(da.dims)
/g/data3/hh5/public/apps/miniconda3/envs/analysis3-19.10/lib/python3.6/site-packages/xrft/xrft.py in _transpose(da, real, trans)
194 transdim = list(da.dims)
195 if real not in transdim:
--> 196 raise ValueError("The dimension along real FT is taken must "
197 "be one of the existing dimensions.")
198 elif real != transdim[-1]:
ValueError: The dimension along real FT is taken must be one of the existing dimensions.
Am I doing something wrong?
Issue Analytics
- State:
- Created 4 years ago
- Comments:9 (8 by maintainers)
Top Results From Across the Web
Problem on Properties of Discrete Fourier Transform (DFT)
Subject - Discrete Time Signal ProcessingVideo Name - Problem on Properties of Discrete Fourier Transform ( DFT )Chapter - Discrete Fourier ...
Read more >Improving Rule Evaluation Using Multitask Learning - Mark Reid
Abstract. This paper introduces Deft, a new multitask learning ap- proach for rule learning algorithms. Like other multitask learning sys-.
Read more >ase/wannier.py at master · qsnake/ase - GitHub
from ase.dft.kpoints import get_monkhorst_pack_size_and_offset ... def write_cube(self, index, fname, repeat=None, real=True):.
Read more >Flatorize - Guillaume Lathoud
Example: Discrete Fourier Transform (DFT) #. We now implement a DFT using the Cooley-Tukey algorithm for both real & complex inputs (option). The...
Read more >Density functional theory error discovered - C&EN
Bootsma, now a senior scientist at Pfizer, discovered the problem when Bootsma was testing an automated computer program that uses DFT to ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
real
takes the dimension to take the real FFT over so in your case,dahat = xrft.dft(da, window=True, real='time')
should do the trick.Hmm, then I’m not sure why real DFT generated errors in Python 3.7 and not in 3.6. In any case, the tests for real DFT in Python 3.7 all pass in PR #88.