diff options
Diffstat (limited to 'stwcs/wcsutil')
-rw-r--r-- | stwcs/wcsutil/altwcs.py | 14 | ||||
-rw-r--r-- | stwcs/wcsutil/hstwcs.py | 6 |
2 files changed, 13 insertions, 7 deletions
diff --git a/stwcs/wcsutil/altwcs.py b/stwcs/wcsutil/altwcs.py index 043d535..b166b61 100644 --- a/stwcs/wcsutil/altwcs.py +++ b/stwcs/wcsutil/altwcs.py @@ -1,6 +1,7 @@ from __future__ import absolute_import, division, print_function import string +import warnings import numpy as np from astropy import wcs as pywcs from astropy.io import fits @@ -9,6 +10,13 @@ from stsci.tools import fileutil as fu from astropy import log default_log_level = log.getEffectiveLevel() +warnings.filterwarnings("ignore", message="^Some non-standard WCS keywords were excluded:", module="astropy.wcs.wcs") + + +__all__ = ["archiveWCS", "available_wcskeys", "convertAltWCS", "deleteWCS", "next_wcskey", + "pc2cd", "readAltWCS", "restoreWCS", "wcskeys", "wcsnames"] + + altwcskw = ['WCSAXES', 'CRVAL', 'CRPIX', 'PC', 'CDELT', 'CD', 'CTYPE', 'CUNIT', 'PV', 'PS'] altwcskw_extra = ['LATPOLE', 'LONPOLE', 'RESTWAV', 'RESTFRQ'] @@ -151,6 +159,7 @@ def archiveWCS(fname, ext, wcskey=" ", wcsname=" ", reusekey=False): key = k[: 7] + wkey f[e].header[key] = hwcs[k] log.setLevel(default_log_level) + warnings.resetwarnings() closefobj(fname, f) @@ -432,10 +441,9 @@ def _restore(fobj, ukey, fromextnum, hdr = _getheader(fobj, fromextension) # keep a copy of the ctype because of the "-SIP" suffix. ctype = hdr['ctype*'] + w = pywcs.WCS(hdr, fobj, key=ukey) - log.setLevel('WARNING') hwcs = w.to_header() - log.setLevel(default_log_level) if hwcs is None: return @@ -518,9 +526,7 @@ def readAltWCS(fobj, ext, wcskey=' ', verbose=False): print('readAltWCS: Could not read WCS with key %s' % wcskey) print(' Skipping %s[%s]' % (fobj.filename(), str(ext))) return None - log.setLevel('WARNING') hwcs = nwcs.to_header() - log.setLevel(default_log_level) if nwcs.wcs.has_cd(): hwcs = pc2cd(hwcs, key=wcskey) diff --git a/stwcs/wcsutil/hstwcs.py b/stwcs/wcsutil/hstwcs.py index d9146d2..86dec5e 100644 --- a/stwcs/wcsutil/hstwcs.py +++ b/stwcs/wcsutil/hstwcs.py @@ -1,6 +1,7 @@ from __future__ import absolute_import, division, print_function import os +import warnings from astropy.wcs import WCS from astropy.io import fits from ..distortion import models, coeff_converter @@ -17,6 +18,7 @@ default_log_level = log.getEffectiveLevel() __all__ = ['HSTWCS'] +warnings.filterwarnings("ignore", message="^Some non-standard WCS keywords were excluded:", module="astropy.wcs.wcs") def extract_rootname(kwvalue, suffix=""): """ Returns the rootname from a full reference filename @@ -385,10 +387,8 @@ class HSTWCS(WCS): sip2hdr : bool If True - include SIP coefficients """ - if not relax and not sip2hdr: - log.setLevel('WARNING') + warnings.filterwarnings("ignore", message="^Some non-standard WCS keywords were excluded:", module="astropy.wcs") h = self.to_header(key=wcskey, relax=relax) - log.setLevel(default_log_level) if not wcskey: wcskey = self.wcs.alt |