fatiando / boule

Reference ellipsoids for geodesy and geophysics
https://www.fatiando.org/boule
BSD 3-Clause "New" or "Revised" License
37 stars 16 forks source link

Add area and area_equivalent_radius to all three ellipsoid classes #178

Closed MarkWieczorek closed 3 months ago

MarkWieczorek commented 3 months ago

This PR adds the property area and area_equivalent_radius to the three ellipsoid classes. The "area_equivalent_radius" is what WGS84 calls $R_2$.

The equations for the area of bi-axial and tri-axial ellipsoids are taken from https://en.wikipedia.org/wiki/Ellipsoid#Surface_area. The equation for a bi-axial ellispoid is relatively simple, and only requires to use np.arctanh. The equation for a triaxial ellipsoid, however, requires computing two elliptic integrals. To do this, I have used the elliptic integral functions from scipy: scipy.special.elliprd and scipy.special.elliprf. This required adding scipy to the environment.yml and requirements-test.txt files.

I have verified that the area equivalent radius for WGS84 in boule is what is given in the literature. I have verified that the triaxial ellipsoid routine gives the correct value when a=b for WGS84.

If you don't like having scipy as a dependency, we could perhaps have this an an optional dependency, and check if it is available before running TriaxialEllipsoid.area (this is the only routine that requires it).

Relevant issues/PRs:

MarkWieczorek commented 3 months ago

Please note that the python 3.7 tests are failing only because the scipy elliptic integral functions I used were introduced in version 1.8.0, and that version of scipy requires python 3.8+.

See https://docs.scipy.org/doc/scipy/reference/generated/scipy.special.elliprd.html#scipy.special.elliprd and https://docs.scipy.org/doc/scipy/release/1.8.0-notes.html.

MarkWieczorek commented 3 months ago

Note: I have updated with github tests to use Python 3.8 and 3.12.

leouieda commented 3 months ago

I opened #188 to drop 3.7 support than we can merge that into here once it's on main. Thanks!

leouieda commented 3 months ago

Merged! Many thanks for this!