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

Compute horizontal derivatives of grids using finite differences #378

Merged
merged 19 commits into from
Mar 1, 2023

Conversation

santisoler
Copy link
Member

@santisoler santisoler commented Feb 12, 2023

Make functions derivative_easting and derivative_northing to compute the horizontal derivatives using central finite-differences through the xarray.DataArray.differentiate method by default. Add a method 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 old fatiando.

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.
@santisoler
Copy link
Member Author

@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 fatiando horizontal derivatives functions.

@santisoler santisoler added this to the v0.6.0 milestone Feb 28, 2023
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.
@santisoler
Copy link
Member Author

@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!

@santisoler santisoler merged commit 335e543 into main Mar 1, 2023
@santisoler santisoler deleted the horizontal-finite-diff branch March 1, 2023 17:53
@LL-Geo
Copy link
Member

LL-Geo commented Mar 3, 2023

Just had a quick look! That looks great! 👍

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

Successfully merging this pull request may close these issues.

2 participants