-
Notifications
You must be signed in to change notification settings - Fork 44
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
window_correction seems sensitive to formatting of dim
#142
Comments
Do you mean that if you generate a synthetic data with the same dimensions and coordinates as your |
Oh sorry I think that was left in from debugging!
No this is not what I mean. I just tried with the example from the docs in my setup and I didn't get the error. But the example has dimension name |
It looks like |
The issue is that there is a |
I think in Line 341 in 2bb85b3
So the |
Hmm weird... I'll try and get to the bottom of this this morning |
Thanks for reporting this @cspencerjones! We appreciate it. |
I think I've just run into this same problem when using xrft's I'm using xrft version 0.3.0 on Pangeo Cloud. #Create dummy data
import numpy as np
x = np.arange(-5,5,0.01)
a = np.sin(2*x) + x + 3
# Convert to xarray
import xarray as xr
ax = xr.DataArray(a,dims=['time'])
# No error with constant detrend
import xrft
xrft.detrend(ax,'time',detrend_type='constant')
# Error with linear detrend
xrft.detrend(ax,'time',detrend_type='linear') ValueError--------------------------------------------------------------------------- ValueError Traceback (most recent call last) /srv/conda/envs/notebook/lib/python3.8/site-packages/xarray/core/common.py in _get_axis_num(self, dim) 171 try: --> 172 return self.dims.index(dim) 173 except ValueError:ValueError: tuple.index(x): x not in tuple During handling of the above exception, another exception occurred: ValueError Traceback (most recent call last) /srv/conda/envs/notebook/lib/python3.8/site-packages/xrft/detrend.py in detrend(da, dim, detrend_type) /srv/conda/envs/notebook/lib/python3.8/site-packages/xrft/detrend.py in (.0) /srv/conda/envs/notebook/lib/python3.8/site-packages/xarray/core/common.py in get_axis_num(self, dim) /srv/conda/envs/notebook/lib/python3.8/site-packages/xarray/core/common.py in _get_axis_num(self, dim) ValueError: 't' not found in array dimensions ('time',) |
One possible workaround for this issue is to just put the dim inside a list, e.g. xrft.detrend(ax, ['time'], detrend_type='constant') Does this work? |
@rabernat yep I did that so I could run my current computation, but I still think it probably makes sense to update |
That would be great, thanks @dougiesquire! |
I haven't been able to reproduce this with synthetic data (sorry!)
But for my real data,
xrft.power_spectrum(u_unfiltered.isel(x0=1000,y0=1000).load(),dim='time', window='hann',window_correction=True)
gives the error:Whereas
xrft.power_spectrum(u_unfiltered.isel(x0=1000,y0=1000).load(),dim=['time'], window='hann',window_correction=True)
is totally fine.Any idea what is causing this? Is all testing performed on data with single character dimension names? Perhaps that is the problem?
The text was updated successfully, but these errors were encountered: