Closed paigem closed 3 years ago
I think this is indeed a bug. I didn't have in mind the same dimension having two coordinates corresponding to it when writing the code. A PR would be appreciated :)
I'll probably make a new release as soon as this issue is resolved.
Ok sounds good! So just to clarify - what do you think the best course of action is here? Ask the user to delete the extra coordinates, or keep the "problem" coordinate (in my example above, keep 'time' as a dimension in addition to 'freq_time')? Or something else?
I doubt that after taking the FFT, any coordinate attached to the dimension upon which it was taken (i.e. time
in your example) will be useful to the user but... who knows. So, if you can find a work around to keep the extra metadata, I think that would be the most versatile PR.
Otherwise, I think raising an error with a proper message that "the dimension over which the FFT is taken should only have one coordinate" would be sufficient.
Will submit this PR tomorrow - was at a workshop all day and didn't have as much in-between time as I was hoping.
Closed via #163
I ran into an error when running xrft functions. The error seems to occur when the xarray DataArray has multiple coordinates that depend on the dimension that is passed to the
real_dim
flag. Below is (my attempt at) a minimal reproducible example that yields an error included just below.Value Error
``` --------------------------------------------------------------------------- ValueError Traceback (most recent call last)So I think the trouble here is that in taking the FT, the dimension 'time' is converted to 'freq_time', but then
xrft
andxarray
do not know how to handle coordinates that are attached to the 'time' dimension. The above error is easily avoided by removing the coordinate causing trouble (in the above case that would betime2
). Perhaps this is the best option? If so, then a more targeted error message might be helpful for users.I'd be happy to put in a PR for this, but want to get feedback on how to handle this first.