Skip to content

Commit

Permalink
Suppress WCS warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
dahlend committed Jun 17, 2024
1 parent 2aa4585 commit 969b916
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Significant rewrite of the SPICE kernel file management, this rewrite is required
so that future work can enable writing SPICE kernel files.

### Fixed

- Astropy WCS warnings are now suppressed.

### Removed

- Removed support for SPK Files of type 3, these should be a trivial change from type 2
Expand Down
5 changes: 4 additions & 1 deletion docs/tutorials/kona.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ First we do some setup, including importing many needed packages.
import matplotlib.pyplot as plt
import numpy as np
import datetime
import warnings
import astropy
from astropy.io import fits
Expand Down Expand Up @@ -55,7 +56,9 @@ calculated from the corners of the frame.
# Build the corner position of the FOV in RA/DEC, and build those into vectors
# The WCS will raise a warning because the FITs files produced by WISE use an
# old format.
frame_wcs = WCS(frame.header, relax=True)
with warnings.catch_warnings():
warnings.filterwarnings("ignore")
frame_wcs = WCS(frame.header)
corners = []
dx, dy = frame_wcs.pixel_shape
for x, y in zip([0, 0, dx, dx], [0, dy, dy, 0]):
Expand Down
7 changes: 6 additions & 1 deletion src/neospy/irsa.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import time
import logging
import numpy as np
import warnings
import pandas as pd # type: ignore
import matplotlib.pyplot as plt # type: ignore
from xml.etree import ElementTree
Expand Down Expand Up @@ -194,7 +195,11 @@ def plot_fits_image(fit, vmin=-3, vmax=7, cmap="bone_r"):
Color map to use for the plot.
"""
data = np.nan_to_num(fit.data)
wcs = WCS(fit.header, relax=True)

with warnings.catch_warnings():
warnings.filterwarnings("ignore")
wcs = WCS(fit.header)

if not plt.get_fignums():
plt.figure(dpi=120, figsize=(6, 6), facecolor="w")
ax = plt.subplot(projection=wcs)
Expand Down
5 changes: 4 additions & 1 deletion src/neospy/wise.py
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,10 @@ def plot_frames(
except OSError:
continue
data = np.nan_to_num(fit.data)
wcs = WCS(fit.header, relax=True)
with warnings.catch_warnings():
warnings.filterwarnings("ignore")
wcs = WCS(fit.header)

ax = plt.subplot(2, 2, band, projection=wcs)

data_no_bkg = data - np.median(data)
Expand Down

0 comments on commit 969b916

Please sign in to comment.