-
-
Notifications
You must be signed in to change notification settings - Fork 573
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?
Changes from all commits
82d39f6
db50a75
aa7b642
81d89ca
a92c51f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Updated :meth:`sunpy.map.Map.submap` to check if it is about to work on locations with NaNs now errors and informs the user that they likely want to use :meth:`~sunpy.coordinates.Helioprojective.assume_spherical_screen` so that the off-disk 2D coordinate can be converted to a 3D coordinate. | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,7 +36,7 @@ | |
import sunpy.coordinates | ||
import sunpy.visualization.colormaps | ||
from sunpy import config, log | ||
from sunpy.coordinates import HeliographicCarrington, get_earth, sun | ||
from sunpy.coordinates import HeliographicCarrington, Helioprojective, get_earth, sun | ||
from sunpy.coordinates.utils import get_rectangle_coordinates | ||
from sunpy.image.resample import resample as sunpy_image_resample | ||
from sunpy.image.resample import reshape_image_to_4d_superpixel | ||
|
@@ -1994,6 +1994,18 @@ def _parse_submap_quantity_input(self, bottom_left, top_right, width, height): | |
@_parse_submap_input.register(SkyCoord) | ||
@_parse_submap_input.register(BaseCoordinateFrame) | ||
def _parse_submap_coord_input(self, bottom_left, top_right, width, height): | ||
msg = ( | ||
"The {quadrant} input contains NaN values. " | ||
"It is possible the coordinates are off-disk. " | ||
"Consider using Helioprojective.assume_spherical_screen" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we merge #7115, this should change to
Comment on lines
+1998
to
+2000
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This reads more like a warning than an exception. My issue with it is it doesn't really say why an exception is being raised. Why am I not being allowed to crop my map when one of my coordinates is off disk? |
||
) | ||
if isinstance(bottom_left, Helioprojective): | ||
if np.isnan(bottom_left.distance.to_value()).any(): | ||
raise ValueError(msg.format(quadrant="bottom_left")) | ||
if top_right is not None and isinstance(top_right, Helioprojective): | ||
if np.isnan(top_right.distance.to_value()).any(): | ||
raise ValueError(msg.format(quadrant="top_right")) | ||
|
||
# Use helper function to get top_right as a SkyCoord | ||
bottom_left, top_right = get_rectangle_coordinates(bottom_left, | ||
top_right=top_right, | ||
|
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.
Same as below. Should be updated to use
SphericalScreen
once that PR is merged.