This repository was archived by the owner on Dec 22, 2021. It is now read-only.
Implement kernel functions for tesseroid forward modeling - #118
Merged
Conversation
Using a single function and looping over module functions.
Didn't have time to check. Probably broken.
This will allow future magnetic functions to get the magnetization from the tesseroids without having to modify the discretization code. Also made some aesthetic changes to the Cython code.
Profiling code need update for new function names
Docs say it is more efficient. Benchmark says it doesn't make much of a difference. Still, better use it just in case.
In gravmag.tesseroid: Moved distance calculating into too_close. Sorting input 'points' array instead of allocating a buffer and splitting that. too_close now returns the index that splits 'points' into don't need division and need division. Using sincos to calculate sin and cos at the same time. Raise a ValueError if trying to calculate directly on top of the tesseroid.
In the benchmark, just run a quick check if they are equal.
Improved tests for tesseroid and added check if the input arrays have the same shape.
Docs wont build because of importing _tesseroid extension module. Need to make it a silent import error for now (bad solution).
Member
Author
|
@birocoles could you please take a look at the new code here? It's in tesseroid.py and the Cython module _tesseroid.pyx. The We should start doing this kind of review more often. Doing it only at the end of a project is not very good because things get complicated. |
Wasn't even suitable for testing anymore.
Conflicts: doc/changelog.rst
Getting Float 0 division errors. Not sure where.
Moved the queue inside Cython kernel function. This resulted in a faster implementation than the Tesseroids recursive one for gzz. Need to refactor code into smaller functions and reusable part. That's why I didn't commit the C files as well to avoid clutter.
Moved some things around and got rid of some Python variable conversions to get a decent speedup. Got it faster than C. Need to implement a queue in Cython to be able to release the GIL and use prange.
Results in ~2x speedup with respect to latest build of Tesseroids. Could release the GIL for the data loop, making use of prange possible.
Separated the data loop and redistretization into a cdef function and pass a pointer to the kernel.
Few changes to benchmark as well
Got consistent speedups with respect to Tesseroids implementation. The biggest gains are in gzz
Passing queue size as an argument to the Cython functions.
Refactor tesseroid kernels
Conflicts: doc/changelog.rst
Number of new elements is nlon*nlat*nr not +
As is being done in Tesseroids. The Vicenty formula was not necessary and took longer to calculate.
Conflicts: doc/changelog.rst fatiando/gravmag/_tesseroid.c
The distance is measured to the center of the tesseroid. Test trying to raise an overflow error is failing.
The test that was breaking was checking for overflow with default queue size at h=1. This didn't overflow anymore with the new distance calculation. Adapted to use queue size = 20 and calculate at h=0. Now overflows.
Check is all tesseroid results are within 0.1% of the shell values. Had to adjust gz ratio to 1.6 for tests to pass.
leouieda
added a commit
that referenced
this pull request
Mar 11, 2015
Implement kernel functions for tesseroid forward modeling
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Separate the tesseroid functions into kernels. Clean up the Cython code (very messy and not very fast) and make more/better tests.
Fixes #114
Tasks:
gravmag.tesseroid.Checklist: