Skip to content

Forward modelling of ellipsoidal bodies for gravity and magnetic fields - #568

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

Draft
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

KellySavanna
Copy link

@KellySavanna KellySavanna commented Jun 17, 2025

This repo produces the magnetic and gravitational forward models of ellipsoidal bodies, much like the current Harmonica forward modelling packages. This was achieved with use of magnetic and gravitational ellipsoid derivations outlined in:

  • Clark, D. A., Saul, S. J., & Emerson, D. W. (1986). Magnetic and gravity anomalies of a triaxial ellipsoid. Exploration Geophysics, 17(4), 189–200. https://doi.org/10.1071/EG986189
  • Takahashi, D., & Oliveira Jr., V. C. (2017). Ellipsoids (v1.0): 3-D magnetic modelling of ellipsoidal bodies. Geoscientific Model Development, 10(9), 3591–3608. https://doi.org/10.5194/gmd-10-3591-2017.

There are three main .py files included: ellipsoid_magnetics.py for producing the total magnetic field due to ellipsoidal bodies, ellipsoid_gravity.py for the equivalent gravity fields, and create_ellipsoids.py to create the input ellipsoid for these functions. Tests for the code are included in /tests.

The user can specify the type of ellipsoid (triaxial: a > b > c, prolate: a > b = c, oblate a < b = c where a is the semi-major axis), the rotation components of the ellipsoid in intrinsic Euler angles (yaw, pitch and roll), and the centre of the ellipsoid in their given coordinate system. It also allows for multiple ellipsoidal bodies to be modelled, and produce and produce an array of the total anomaly as three components (be, bn, bu) or (ge, gn, gu) as (easting, northing, upward) magnetic and gravity components, respectfully. Users can also specify which component of the field to return (easting or northing or upward), and relevant input parameters such as susceptibility (isotropic or anisotropic), density and regional field $H_0$.

This code would be a useful addition to Harmonica, particularly in forward modelling for applications such as ore bodies.

! Work in progress !

Current issues in progress:

  • test_magnetics_ellipsoids.py has function test_mag_ext_int_boundary. The test is to check continuity across a the internal-external boundary, which currently fails unless the tolerance is greater than 1e2. The max rel difference is given as about 4%, which remains true for several tested magnitudes of tested radius. This is currently being looked into as to whether it is a instability/rounding/precision error or a bug in the code.
  • There are some areas which have potential for optimisation, e.g. currently the ellipsoid_magnetics function uses for-loops to avoid having to mask with an N x 3 x 3 matrix.
  • Currently the functions produce total field, but perhaps a user specified option to choose total field or just the anomaly would be beneficial to the interface?

Open to suggestions! Thank you 🙏

@KellySavanna KellySavanna changed the title Forward modelling of ellipsoidal bodies fir gravity and magnetic fields - Forward modelling of ellipsoidal bodies for gravity and magnetic fields - Jun 17, 2025
@KellySavanna KellySavanna marked this pull request as draft June 17, 2025 22:13
@KellySavanna KellySavanna marked this pull request as ready for review June 17, 2025 22:51
@leouieda
Copy link
Member

@KellySavanna thank you for the contribution and welcome to Fatiando! Great to have you here ❤️

I have enabled GitHub Actions for your pull request. Please take a look at the logs by clicking on each failed job to see what went wrong. Don't worry, this is very normal and we all get failing jobs almost every time.

I'll have a closer look at the code later but for now I can say that we don't need an option to return the total-field anomaly. The anomaly can already be calculated from the B field using https://www.fatiando.org/harmonica/latest/api/generated/harmonica.total_field_anomaly.html#harmonica.total_field_anomaly

Let me know if you need help with anything in particular!

@KellySavanna
Copy link
Author

Thank you! Hopefully most of these issues have now been solved.

@KellySavanna KellySavanna marked this pull request as draft June 19, 2025 15:58
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