Skip to content

Commit 92c69ff

Browse files
authored
Refactor code to have a single Ellipsoid class (#616)
Refactor the ellipsoid code to have a single `Ellipsoid` class that can represent any type of ellipsoid. Ditch the specific classes for each ellipsoid type and the `create_ellipsoid` function. Update the forward modelling code for gravity and magnetics. Make use of an extra rotation matrix that aligns the x, y, z local coordinate system to the ellipsoid's semiaxes in decreasing order, so `a >= b >= c`. Modify the analytic solutions for oblate ellipsoids in such way that they are defined by `a == b > c` (instead of `a < b == c` as Takahashi et al. and Clark et al. do). Make rotation angles and `center` as optional arguments for the `Ellipsoid` class. Fix numerical instabilities of triaxial ellipsoids when they approximate prolate or oblate ellipsoids (when two semiaxes lengths are close enough to each other). Update the tests and add a few more for the new bits of code. **Relevant issues/PRs:** Part of #594
1 parent 676414d commit 92c69ff

File tree

12 files changed

+1325
-1721
lines changed

12 files changed

+1325
-1721
lines changed

doc/api/index.rst

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -86,16 +86,12 @@ Magnetic fields:
8686
ellipsoid_magnetic
8787
prism_magnetic
8888

89-
Ellipsoids:
89+
Geometric bodies:
9090

9191
.. autosummary::
9292
:toctree: generated/
9393

94-
create_ellipsoid
95-
OblateEllipsoid
96-
ProlateEllipsoid
97-
Sphere
98-
TriaxialEllipsoid
94+
Ellipsoid
9995

10096
Layers and meshes:
10197

@@ -174,4 +170,3 @@ Type hints
174170
:toctree: generated/
175171

176172
typing.Coordinates
177-
typing.Ellipsoid

harmonica/__init__.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,7 @@
1616
from ._equivalent_sources.spherical import EquivalentSourcesSph
1717
from ._euler_deconvolution import EulerDeconvolution
1818
from ._forward.dipole import dipole_magnetic
19-
from ._forward.ellipsoids import (
20-
OblateEllipsoid,
21-
ProlateEllipsoid,
22-
Sphere,
23-
TriaxialEllipsoid,
24-
create_ellipsoid,
25-
ellipsoid_gravity,
26-
ellipsoid_magnetic,
27-
)
19+
from ._forward.ellipsoids import Ellipsoid, ellipsoid_gravity, ellipsoid_magnetic
2820
from ._forward.point import point_gravity
2921
from ._forward.prism_gravity import prism_gravity
3022
from ._forward.prism_layer import DatasetAccessorPrismLayer, prism_layer

harmonica/_forward/ellipsoids/__init__.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,6 @@
88
Forward modelling of ellipsoids.
99
"""
1010

11-
from .ellipsoids import (
12-
OblateEllipsoid,
13-
ProlateEllipsoid,
14-
Sphere,
15-
TriaxialEllipsoid,
16-
create_ellipsoid,
17-
)
11+
from .ellipsoids import Ellipsoid
1812
from .gravity import ellipsoid_gravity
1913
from .magnetic import ellipsoid_magnetic

0 commit comments

Comments
 (0)