-
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
Dft reverse axis #149
Dft reverse axis #149
Conversation
update for coming fft and ifft modifications
Update from original
Moving spacing as coords attribute + some update (xgcm#126)
update master
@roxyboy, merge ? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
xrft/xrft.py
Outdated
lag = coord[(len(coord.data)) // 2] | ||
reverse_coord = ( | ||
[] if (coord[-1] > coord[0]) else [-1] | ||
) # taking care of reverse coordinate (CAUTION : [] diff None) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand this comment, specifically (CAUTION : [] diff None)
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for this not being explicit. This is to emphasize that:
np.flip(a, axis=None) has a different behaviour than np.flip(a, axis=[]).
If axis=None, all axis are flipped.
If axis=[], no axis are flipped
I though it deserved to me mentioned in a comment
xrft/xrft.py
Outdated
reverse_coord = ( | ||
[] if (coord[-1] > coord[0]) else [-1] | ||
) # taking care of reverse coordinate (CAUTION : [] diff None) | ||
lag = np.flip(coord.data, axis=reverse_coord)[(len(coord.data)) // 2] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the sake of the other devs, I would prefer to make this all a bit more explicit, i.e.
if coord[-1] > coord[0]:
coord_data = coord.data
else:
coord_data = np.flip(coord.data, axis=-1)
lag = coord_data / (len(coord.data) // 2)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok but the last line should then be:
lag = coord_data[(len(coord.data)) // 2]
Thanks! So is the plan to defer the documentation updates to a future PR? If so, I will merge. |
I give a thumbs up to a separate PR for docs :) |
Handle decreasing coordinates in dft with true_phase = True.
Add a test to check