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
base: main
Are you sure you want to change the base?
Conversation
…inates contain NaN values. Added tests to test_mapbase.py.
# If bottom_left or top_right is a helioprojective coordinate with NaN values, | ||
# cannot create meaningful submap |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# 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() |
There was a problem hiding this comment.
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." |
There was a problem hiding this comment.
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."): |
There was a problem hiding this comment.
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?
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!