Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds ValueError to mapbase.submap() when Helioprojection coordinate contains NaN values. #7543

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

grahamasam
Copy link

This pull request produces a value error when Helioprojection coordinates that have NaN distance values are input as bottom_left or top_right to the submap() function.

Relevant issue: #5598

Additional Info:
I'm unsure if this solution fully addresses the common user issue presented in #5598. A testcase that mimics one of these specific user issues could be useful to determine what other situations should result in the ValueError. Any suggestions would be greatly appreciated!

…inates contain NaN values. Added tests to test_mapbase.py.
Comment on lines +1998 to +1999
# If bottom_left or top_right is a helioprojective coordinate with NaN values,
# cannot create meaningful submap
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
# If bottom_left or top_right is a helioprojective coordinate with NaN values,
# cannot create meaningful submap

# If bottom_left or top_right is a helioprojective coordinate with NaN values,
# cannot create meaningful submap
if (isinstance(bottom_left, Helioprojective)):
values = bottom_left.distance.to_value()
Copy link
Contributor

Choose a reason for hiding this comment

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

Are the values needed for anything else? If not, we could use the new walrus operator?

if (isinstance(bottom_left, Helioprojective)):
values = bottom_left.distance.to_value()
if np.isnan(values).any():
raise ValueError("The Helioprojective coordinates input to `submap()` contain NaN values."
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this message is the same as below? If so, I think defining it once above would be better.

h = Helioprojective([1,7]*u.arcsec*319, 0*u.arcsec,
observer='earth', obstime='2020-04-08')
h_3d = h.make_3d()
with pytest.raises(ValueError, match="contain NaN values."):
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you make more of the message, maybe just the start of it instead?

@nabobalis nabobalis added this to the 6.0.0 milestone May 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants