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

Add function to create a tesseroid layer #316

Merged
merged 51 commits into from
Sep 28, 2022

Conversation

aguspesce
Copy link
Member

@aguspesce aguspesce commented May 30, 2022

Add function that creates a tesseroid layer, similar to the prism layer. Create
an Xarray DataAccesor that makes available some methods to deal with the prism
layer, included one to compute the gravitational field generated by the whole
layer in a set of computation points. Add checks to avoid generating layers
with tesseroids that overlap around the earth. Add tests and a new gallery
example.

Fixes #83

aguspesce and others added 2 commits July 7, 2022 15:32
Build the computation grid on a different set of points. Use meshgrid to
build 2d versions of the original longitude and latitude arrays (don't
regenerate it with vd.grid_coordinates).
@aguspesce
Copy link
Member Author

Hello @leouieda and @santisoler
I have a little problem with this PR, so I need your wisdom!

I coded the function to calculate a teseroid layer and its gravity. I also created an example using Esaio's topography.
When I ran the example, it calculates the teseroid layer, and I think it's done well.
But when it calculates the gravity, it returns this error:

 $ python -i examples/forward/tesseroid_layer.py
ZeroDivisionError: division by zero

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/agustina/Github/harmonica/examples/forward/tesseroid_layer.py", line 41, in <module>
    gravity = tesseroids.tesseroid_layer.gravity(grid_coords, field="g_z")
  File "/home/agustina/Github/harmonica/harmonica/forward/tesseroid_layer.py", line 269, in gravity
    return tesseroid_gravity(
  File "/home/agustina/Github/harmonica/harmonica/forward/tesseroid.py", line 174, in tesseroid_gravity
    dispatcher(parallel, density)(
SystemError: CPUDispatcher(<function jit_tesseroid_gravity at 0x7f9a26841670>) returned a result with an error set

I know that I have a zero division, but I don't know where is the problem... It is my code that create wrong the layer or the tesseroid function to calculate the gravity.
Please... Ideas, suggestions, something?

@santisoler santisoler added this to the v0.6.0 milestone Aug 12, 2022
@santisoler
Copy link
Member

Sorry for not replying directly in this PR, @aguspesce. For the record, the zero division error was due to the fact that the forward modelling wasn't ignoring tesseroids with zero volume. You have already fixed it on #339.

How is the status on this PR? Is it ready for review?

@aguspesce
Copy link
Member Author

Hello @santisoler. I've working in the test. If you like, you can review the example and the teseroid_layer function

@aguspesce
Copy link
Member Author

Hello @santisoler. I think that this PR is ready for your review

Copy link
Member

@santisoler santisoler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for writing this @aguspesce! I left some minor suggestions. Check them out and don't hesitate to ask any question.

harmonica/tests/test_tesseroid_layer.py Outdated Show resolved Hide resolved
harmonica/forward/tesseroid_layer.py Outdated Show resolved Hide resolved
harmonica/forward/tesseroid_layer.py Outdated Show resolved Hide resolved
harmonica/forward/tesseroid_layer.py Outdated Show resolved Hide resolved
@aguspesce
Copy link
Member Author

@santisoler... when you have some time, take a look at the code

Copy link
Member

@santisoler santisoler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @aguspesce! A minor suggestions here. I'm committing them.

harmonica/forward/tesseroid_layer.py Outdated Show resolved Hide resolved
harmonica/forward/tesseroid_layer.py Outdated Show resolved Hide resolved
harmonica/tests/test_tesseroid_layer.py Outdated Show resolved Hide resolved
harmonica/tests/test_tesseroid_layer.py Outdated Show resolved Hide resolved
harmonica/tests/test_tesseroid_layer.py Outdated Show resolved Hide resolved
harmonica/tests/test_tesseroid_layer.py Outdated Show resolved Hide resolved
@santisoler santisoler changed the title Add function to create a tesseroid layer Add function to create a tesseroid layer Sep 28, 2022
@santisoler santisoler merged commit 0a38f04 into fatiando:main Sep 28, 2022
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.

Add function to create tesseroid layers
2 participants