Skip to content

Add a function to compute heliocentric angle (related to mu for limb darkening)#7979

Merged
Cadair merged 13 commits into
sunpy:mainfrom
nabobalis:mu_angle
Nov 24, 2025
Merged

Add a function to compute heliocentric angle (related to mu for limb darkening)#7979
Cadair merged 13 commits into
sunpy:mainfrom
nabobalis:mu_angle

Conversation

@nabobalis
Copy link
Copy Markdown
Member

@nabobalis nabobalis commented Jan 7, 2025

I asked Albert this question about 10 years ago and never wrote it up.

So here is this really rough first go.

TODO:

  • Changelog
  • Check math is ok
  • Create a function?

@nabobalis nabobalis added No Backport A PR that isn't to be backported to any release branch. (To be used as a flag to other maintainers) Documentation Affects the documentation. labels Jan 7, 2025
Comment thread docs/how_to/mu_angle.rst Outdated
Comment thread docs/how_to/mu_angle.rst Outdated
@nabobalis nabobalis marked this pull request as ready for review February 1, 2025 22:17
Comment thread docs/how_to/mu_angle.rst Outdated
Comment thread docs/how_to/mu_angle.rst Outdated
@nabobalis nabobalis added the Needs Review Needs review(s) before merge. label Feb 8, 2025
@wtbarnes

This comment was marked as resolved.

@github-actions github-actions Bot added the Stale The bot will close this PR after 6 months (if enabled on this repo). label Sep 7, 2025
@nabobalis nabobalis removed the Stale The bot will close this PR after 6 months (if enabled on this repo). label Sep 11, 2025
@sunpy sunpy deleted a comment from github-actions Bot Sep 11, 2025
Comment thread sunpy/coordinates/tests/test_utils.py Outdated
Comment on lines +403 to +411
# Requires an observer
bad_skycoord = SkyCoord(0*u.arcsec, 0*u.arcsec, frame='heliographic_stonyhurst')
with pytest.raises(ConvertError, match="observer=None."):
get_mu_angle(bad_skycoord)

# Requires an obstime
bad_skycoord = SkyCoord(0*u.arcsec, 0*u.arcsec, frame='heliographic_stonyhurst', observer="earth")
with pytest.raises(ConvertError, match="frame needs a specified obstime"):
get_mu_angle(bad_skycoord)
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like this is testing not the function. I added it for completeness but it feels pointless.

# Off disk with spherical screen for kicks
with SphericalScreen(hpc_coord_center.observer, radius=constants.radius):
mu_angle = get_mu_angle(hpc_coord_off_disk)
assert_quantity_allclose(mu_angle, 0.267803967191623*u.deg)
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This I assume is gibberish but I wanted to see what it would output.

@nabobalis nabobalis requested a review from ayshih September 12, 2025 15:35
ayshih
ayshih previously requested changes Sep 16, 2025
Copy link
Copy Markdown
Member

@ayshih ayshih left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The use of terms in this PR are confusing, at least as I understand the typical terminology:

  • There is an angle (say, $\theta$), sometimes called the "heliocentric angle", which is the angle between the observer LOS vector and the surface normal (or for a point not on the surface, the vector from Sun center to the point)
  • It's often useful, particularly for limb darkening, to transform this quantity by the cosine, which we then call "mu" -> $\mu = cos(\theta)$

The text in the how-to guide and the function docstring mostly conform with the above, but there are multiple instances where "heliocentric angle" and "mu" are conflated. And, I don't know if there's a standard understanding of the term "mu angle", but some literature suggests that "mu angle" refers to the cosine, and is not actually an angle in degrees.

For example, the function is called get_mu_angle() and states that it returns mu (which a user may not think is the same thing as "mu angle"), but the description indicates it is actually returning the heliocentric angle, even though earlier in the docstring says that $\mu$ is the cosine of the heliocentric angle.

I think this PR needs to avoid implying that "mu" is an angle, and outright avoid the term "mu angle": either call the function get_mu() and return the cosine of the heliocentric angle, or call the function get_heliocentric_angle() and explain that the user can get $\mu$ by taking the cosine of the return.

Also, why are we citing the Stack Exchange discussion? It's not a scientific reference, and there are issues with its terminology, even more so than above.

@nabobalis
Copy link
Copy Markdown
Member Author

See If I made it any better. I don't really understand any of this, so I am just winging it, if you cant tell.

@nabobalis nabobalis added this to the 7.1.0 milestone Nov 5, 2025
@nabobalis nabobalis dismissed ayshih’s stale review November 6, 2025 00:34

LONGEST SHUTDOWN BABY

@nabobalis nabobalis removed their assignment Nov 6, 2025
@Cadair Cadair changed the title How to guide to get a mu angle Add a function to compute mu angle, and how to guide Nov 6, 2025
@Cadair Cadair self-requested a review November 6, 2025 17:01
@wtbarnes
Copy link
Copy Markdown
Member

wtbarnes commented Nov 6, 2025

Sorry but I still don't see the point of a how-to guide, especially since it now just repeats what is the docstring of the function.

@nabobalis
Copy link
Copy Markdown
Member Author

I REMOVED IT SO REVIEW THE REST OF THE PR

@nabobalis nabobalis removed the request for review from Cadair November 6, 2025 17:39
@nabobalis nabobalis assigned Cadair and wtbarnes and unassigned nabobalis Nov 6, 2025
Copy link
Copy Markdown
Member

@Cadair Cadair left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apart from a few little tweaks this looks fine to me, though I haven't checked your maths, that I leave to @ayshih .

Comment thread sunpy/coordinates/utils.py Outdated

def get_heliocentric_angle(coordinate_on_solar_disk):
r"""
The heliocentric angle is the angle between direction from a point on the surface of the body toward the observer, with respect to the local vertical of that body.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should "body" not be "sun" here? This only works on the sun right?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NO idea.

Comment thread sunpy/coordinates/utils.py Outdated
Comment thread sunpy/coordinates/utils.py Outdated
@Cadair Cadair requested review from ayshih and wtbarnes November 19, 2025 14:50
@Cadair
Copy link
Copy Markdown
Member

Cadair commented Nov 19, 2025

I'd like Albert as lord of coord to look at this before we merge it.

Comment thread sunpy/coordinates/utils.py Outdated
Comment thread sunpy/coordinates/utils.py Outdated
Comment thread sunpy/coordinates/utils.py Outdated
Comment thread sunpy/coordinates/tests/test_utils.py
Comment thread changelog/7979.feature.rst Outdated
Comment thread sunpy/coordinates/utils.py Outdated
Comment thread sunpy/coordinates/utils.py Outdated
Comment thread sunpy/coordinates/utils.py Outdated
@ayshih ayshih changed the title Add a function to compute mu angle Add a function to compute heliocentric angle (related to mu for limb darkening) Nov 19, 2025
@Cadair Cadair requested a review from ayshih November 24, 2025 12:51
@Cadair Cadair removed the Needs Review Needs review(s) before merge. label Nov 24, 2025
Comment thread sunpy/coordinates/utils.py Outdated
Copy link
Copy Markdown
Member

@Cadair Cadair left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The formatting on the mu equation did not work:

image

Comment thread sunpy/coordinates/utils.py Outdated
@ayshih
Copy link
Copy Markdown
Member

ayshih commented Nov 24, 2025

I had too many backslashes, now fixed

@Cadair Cadair merged commit 36151d3 into sunpy:main Nov 24, 2025
31 of 32 checks passed
@nabobalis nabobalis deleted the mu_angle branch November 24, 2025 18:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Documentation Affects the documentation. No Backport A PR that isn't to be backported to any release branch. (To be used as a flag to other maintainers)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants