Skip to content

Commit

Permalink
Suppress NaN warnings with context manager.
Browse files Browse the repository at this point in the history
  • Loading branch information
delucchi-cmu committed Feb 7, 2025
1 parent feedc15 commit a9b5fd3
Showing 1 changed file with 6 additions and 6 deletions.
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

0 comments on commit a9b5fd3

Please sign in to comment.