Skip to content

Commit

Permalink
Merge pull request #7465 from ahmedhosssam/moon_coordinates
Browse files Browse the repository at this point in the history
A more appropriate way to define moon_radius constants
  • Loading branch information
nabobalis committed Mar 21, 2024
2 parents 6afadab + c6e2a74 commit 51c3a28
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions sunpy/coordinates/sun.py
Original file line number Diff line number Diff line change
Expand Up @@ -759,16 +759,16 @@ def eclipse_amount(observer, *, moon_radius: Literal['IAU', 'minimum'] = 'IAU'):
--------
.. minigallery:: sunpy.coordinates.sun.eclipse_amount
"""
# TODO: Find somewhere more appropriate to define these constants
# The radius of the Moon to use (in units of Earth radii)
# See https://eclipse.gsfc.nasa.gov/SEmono/reference/radius.html
if moon_radius == 'IAU':
k = 0.2725076
elif moon_radius == 'minimum':
k = 0.272281
else:
raise ValueError("The supported values for `moon_radius` are 'IAU' and 'minimum'.")
R_moon = k * R_earth
radius_options = {
'IAU': 0.2725076,
'minimum': 0.272281
}
try:
R_moon = radius_options[moon_radius] * R_earth
except KeyError:
raise ValueError("The supported values for `moon_radius` are: " + ", ".join(radius_options.keys()))

# Get the light-travel-time adjusted location of the Moon
moon = get_body_heliographic_stonyhurst('moon', observer.obstime, observer=observer, quiet=True)
Expand Down

0 comments on commit 51c3a28

Please sign in to comment.