Skip to content

Commit

Permalink
Merge pull request #7530 from ayshih/small_tilt
Browse files Browse the repository at this point in the history
Fixed an inaccuracy in the HME<->HEE transformation
  • Loading branch information
Cadair committed Mar 26, 2024
2 parents b49cfa8 + 699d1df commit 7262a93
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
1 change: 1 addition & 0 deletions changelog/7530.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixed an inaccuracy in the implementation of `~sunpy.coordinates.HeliocentricEarthEcliptic` and `~sunpy.coordinates.GeocentricSolarEcliptic` such that the Earth was not exactly in the XY plane, but rather had an error of up ~10 meters.
3 changes: 2 additions & 1 deletion sunpy/coordinates/_transformations.py
Original file line number Diff line number Diff line change
Expand Up @@ -589,7 +589,8 @@ def _rotation_matrix_reprs_to_reprs(start_representation, end_representation):
A = start_representation.to_cartesian()
B = end_representation.to_cartesian()
rotation_axis = A.cross(B)
rotation_angle = -np.arccos(A.dot(B) / (A.norm() * B.norm())) # negation is required
# Calculate the angle using both cross and dot products to minimize numerical-precision issues
rotation_angle = -np.arctan2(rotation_axis.norm(), A.dot(B)) # negation is required

if rotation_angle.isscalar:
# This line works around some input/output quirks of Astropy's rotation_matrix()
Expand Down
7 changes: 7 additions & 0 deletions sunpy/coordinates/tests/test_transformations.py
Original file line number Diff line number Diff line change
Expand Up @@ -695,6 +695,13 @@ def test_hme_hee_sunspice():
assert_quantity_allclose(new.distance, old.distance)


def test_hee_earth():
# The Earth in HEE should have negligible Z component
times = parse_time('2013-08-10 12:00') + np.arange(10) * u.s
earth_hee = get_earth(times).heliocentricearthecliptic
assert_quantity_allclose(0*u.m, earth_hee.cartesian.z, atol=1e-4*u.m)


def test_hee_hee():
# Test HEE loopback transformation
obstime = Time('2001-01-01')
Expand Down

0 comments on commit 7262a93

Please sign in to comment.