-
Notifications
You must be signed in to change notification settings - Fork 72
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
Compute horizontal derivatives of grids using finite differences #378
Conversation
Use a central finite-difference method by default to compute the horizontal derivatives of a regular grid. Uses the Xarray's DataArray.differentiate method.
Refactor private function to make it clearer how it works.
The second order upward derivative in FFT has a lot of error in comparison with the one obtained by summing the two horizontal derivatives done with finite differences.
…a into horizontal-finite-diff
@LL-Geo, I'm planning to merge this PR during this week. If you have the chance to take a look at it, that would be nice. Otherwise, don't worry, we can always change this code afterwards. Since horizontal derivatives using finite differences in the grid are more accurate than their FFT counterpart, I think it might be better to offer the finite differences option as the default one. This was also the default behavior in the old |
With if and elif statements, pytest wasn't able to determine if we were fully testing these functions, since invalid method were being caught by the private check function.
Remove the private functions that just checked a valid method and repeat the error raising inside each horizontal derivative function. This simplifies code to a simple "if, elif, else" block.
@LL-Geo, I'm merging this so I can start the release of Harmonica. Don't worry about the review. If you find something we should change, feel free to open an issue or a pr! Thanks again for all the work with the fft filters! |
Just had a quick look! That looks great! 👍 |
Make functions
derivative_easting
andderivative_northing
to compute the horizontal derivatives using central finite-differences through thexarray.DataArray.differentiate
method by default. Add amethod
argument to let users choose if they want to use the FFT implementation or the finite differences one. This implementation mimics the one we had in the oldfatiando
.