Skip to content

Commit

Permalink
Add inverse
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark Wieczorek committed Apr 10, 2024
1 parent 6409055 commit 13d6a6f
Showing 1 changed file with 47 additions and 3 deletions.
50 changes: 47 additions & 3 deletions boule/_ellipsoid.py
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,8 @@ def geodetic_to_ellipsoidal_harmonic(self, longitude, latitude, height):
)
u = self.semiminor_axis

Check warning on line 541 in boule/_ellipsoid.py

View check run for this annotation

Codecov / codecov/patch

boule/_ellipsoid.py#L541

Added line #L541 was not covered by tests

return longitude, beta, u

Check warning on line 543 in boule/_ellipsoid.py

View check run for this annotation

Codecov / codecov/patch

boule/_ellipsoid.py#L543

Added line #L543 was not covered by tests

else:
# The variable names follow Li and Goetze (2001). The prime terms
# (*_p) refer to quantities on an ellipsoid passing through the
Expand Down Expand Up @@ -568,11 +570,53 @@ def geodetic_to_ellipsoidal_harmonic(self, longitude, latitude, height):
cosbeta_p2 = 0.5 + big_r / 2 - np.sqrt(0.25 + big_r**2 / 4 - big_d / 2)

Check warning on line 570 in boule/_ellipsoid.py

View check run for this annotation

Codecov / codecov/patch

boule/_ellipsoid.py#L570

Added line #L570 was not covered by tests

# Semiminor axis of ellipsoid passing through the computation point
u = np.sqrt(r_p2 + z_p2 - self.linear_eccentricity**2 * cosbeta_p2)
b_p = np.sqrt(r_p2 + z_p2 - self.linear_eccentricity**2 * cosbeta_p2)

Check warning on line 573 in boule/_ellipsoid.py

View check run for this annotation

Codecov / codecov/patch

boule/_ellipsoid.py#L573

Added line #L573 was not covered by tests

beta_p = np.degrees(np.arccos(np.sqrt(cosbeta_p2)))

Check warning on line 575 in boule/_ellipsoid.py

View check run for this annotation

Codecov / codecov/patch

boule/_ellipsoid.py#L575

Added line #L575 was not covered by tests

return longitude, beta_p, b_p

Check warning on line 577 in boule/_ellipsoid.py

View check run for this annotation

Codecov / codecov/patch

boule/_ellipsoid.py#L577

Added line #L577 was not covered by tests

def ellipsoidal_harmonic_to_geodetic(self, longitude, reduced_latitude, u):
"""
Convert from ellipsoidal-harmonic coordinates to geodetic coordinates.
The geodetic datum is defined by this ellipsoid.
Parameters
----------
longitude : array
Longitude coordinates on ellipsoidal-harmonic coordinate system in
degrees.
latitude : array
Reduced (parametric) latitude coordinates on ellipsoidal-harmonic
coordinate system in degrees.
u : array
The coordinate u, which is the semiminor axes of the ellipsoid that
passes through the input coordinates.
beta = np.degrees(np.arccos(np.sqrt(cosbeta_p2)))
Returns
-------
longitude : array
Longitude coordinates on geodetic coordinate system in degrees. The
longitude coordinates are not modified during this conversion.
latitude : array
Latitude coordinates on geodetic coordinate system in degrees.
height : array
Ellipsoidal heights in meters.
"""
# semimajor axis of the ellipsoid that passes through the input
# coordinates
a_p = np.sqrt(u**2 + self.linear_eccentricity**2)

Check warning on line 609 in boule/_ellipsoid.py

View check run for this annotation

Codecov / codecov/patch

boule/_ellipsoid.py#L609

Added line #L609 was not covered by tests
# latitude = np.arctan(a_p / u * np.tan(np.radians(reduced_latitude)))
latitude = np.arctan(a_p / u * np.tan(np.radians(reduced_latitude)))

Check warning on line 611 in boule/_ellipsoid.py

View check run for this annotation

Codecov / codecov/patch

boule/_ellipsoid.py#L611

Added line #L611 was not covered by tests

# Compute height as the difference of the prime_vertical_radius of the
# input ellipsoid and reference ellipsoid
height = self.prime_vertical_radius(np.sin(latitude)) * (

Check warning on line 615 in boule/_ellipsoid.py

View check run for this annotation

Codecov / codecov/patch

boule/_ellipsoid.py#L615

Added line #L615 was not covered by tests
a_p / self.semimajor_axis - 1
)

return longitude, beta, u
return longitude, np.degrees(latitude), height

Check warning on line 619 in boule/_ellipsoid.py

View check run for this annotation

Codecov / codecov/patch

boule/_ellipsoid.py#L619

Added line #L619 was not covered by tests

def normal_gravity(self, latitude, height, si_units=False):
r"""
Expand Down

0 comments on commit 13d6a6f

Please sign in to comment.