Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dft fails with real option after xarray update #78

Closed
tomchor opened this issue Aug 1, 2019 · 4 comments
Closed

dft fails with real option after xarray update #78

tomchor opened this issue Aug 1, 2019 · 4 comments

Comments

@tomchor
Copy link

tomchor commented Aug 1, 2019

I have recently updated xarray to the latest version and noticed that I can't perform a dft if one of the dimensions is set to have a real transform.

Example:

In [12]: xrft.dft(du.u, dim="x", shift=False)                                         
Out[12]: 
<xarray.DataArray 'fftn-e982410c8538317e81efde78e78ed80c' (itime: 30, freq_x: 160, y: 160, z: 144)>
dask.array<shape=(30, 160, 160, 144), dtype=complex128, chunksize=(2, 160, 160, 144)>
Coordinates:
  * itime           (itime) int64 167750 168000 168250 ... 174500 174750 175000
  * freq_x          (freq_x) float64 0.0 0.0025 0.005 ... -0.0075 -0.005 -0.0025
  * y               (y) float64 1.25 3.75 6.25 8.75 ... 391.2 393.8 396.2 398.8
  * z               (z) float64 -89.69 -89.06 -88.44 ... -1.562 -0.9375 -0.3125
    freq_x_spacing  float64 0.0025

Now if I use the the real option:

In [15]: xrft.dft(du.u, dim="x", shift=False, real="x")                               
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-15-f1b65d8824b4> in <module>
----> 1 xrft.dft(du.u, dim="x", shift=False, real="x")

~/miniconda3/envs/py36/lib/python3.6/site-packages/xrft/xrft.py in dft(da, spacing_tol, dim, real, shift, detrend, window, chunks_to_segments)
    350     if trans:
    351         enddims = [prefix + d for d in rawdims if d in dim]
--> 352         return daft.transpose(*enddims)
    353     else:
    354         return daft

~/miniconda3/envs/py36/lib/python3.6/site-packages/xarray/core/dataarray.py in transpose(self, transpose_coords, *dims)
   1642                 raise ValueError('arguments to transpose (%s) must be '
   1643                                  'permuted array dimensions (%s)'
-> 1644                                  % (dims, tuple(self.dims)))
   1645 
   1646         variable = self.variable.transpose(*dims)

ValueError: arguments to transpose (('freq_x',)) must be permuted array dimensions (('itime', 'y', 'z', 'freq_x'))

Thanks

@TomNicholas
Copy link
Member

It looks like this now breaks because an extra check on the 'dims' argument to da.transpose() was imposed in xarray PR #2556. To fix this then we would just need to supply all the dims in the correct order to daft.transpose(), rather than just the "enddims".

@roxyboy
Copy link
Member

roxyboy commented Nov 19, 2019

So... basically we should update the _transpose function in xrft @TomNicholas ?

@TomNicholas
Copy link
Member

Sorry for the slow response.

Your PR #88 does exactly this:

we would just need to supply all the dims in the correct order

so I think you should merge it :)

@roxyboy
Copy link
Member

roxyboy commented Jan 7, 2020

Ok, I'm gonna merge this @rabernat

@roxyboy roxyboy closed this as completed Feb 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants