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

Suppress NaN warnings with context manager. #453

Merged
merged 1 commit into from
Feb 7, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/hats/inspection/visualize_catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,12 +236,12 @@ def get_fov_moc_from_wcs(wcs: WCS) -> MOC | None:
y_px = np.append(y_px, y[1:, 0][::-1])

# Disable the output of warnings when encoutering NaNs.
warnings.filterwarnings("ignore")
# Inverse projection from pixel coordinate space to the world coordinate space
viewport = pixel_to_skycoord(x_px, y_px, wcs)
# If one coordinate is a NaN we exit the function and do not go further
ra_deg, dec_deg = viewport.icrs.ra.deg, viewport.icrs.dec.deg
warnings.filterwarnings("default")
with warnings.catch_warnings():
warnings.simplefilter("ignore")
# Inverse projection from pixel coordinate space to the world coordinate space
viewport = pixel_to_skycoord(x_px, y_px, wcs)
# If one coordinate is a NaN we exit the function and do not go further
ra_deg, dec_deg = viewport.icrs.ra.deg, viewport.icrs.dec.deg

if np.isnan(ra_deg).any() or np.isnan(dec_deg).any():
return None
Expand Down