diff options
-rw-r--r-- | stwcs/wcsutil/altwcs.py | 10 | ||||
-rw-r--r-- | stwcs/wcsutil/headerlet.py | 7 | ||||
-rw-r--r-- | stwcs/wcsutil/hstwcs.py | 8 |
3 files changed, 20 insertions, 5 deletions
diff --git a/stwcs/wcsutil/altwcs.py b/stwcs/wcsutil/altwcs.py index cba400f..2d1565d 100644 --- a/stwcs/wcsutil/altwcs.py +++ b/stwcs/wcsutil/altwcs.py @@ -3,10 +3,12 @@ from __future__ import absolute_import, division, print_function import string import numpy as np from astropy import wcs as pywcs -from astropy import log from astropy.io import fits from stsci.tools import fileutil as fu +from astropy import log +default_log_level = log.getEffectiveLevel() + altwcskw = ['WCSAXES', 'CRVAL', 'CRPIX', 'PC', 'CDELT', 'CD', 'CTYPE', 'CUNIT', 'PV', 'PS'] altwcskw_extra = ['LATPOLE', 'LONPOLE', 'RESTWAV', 'RESTFRQ'] @@ -148,7 +150,7 @@ def archiveWCS(fname, ext, wcskey=" ", wcsname=" ", reusekey=False): for k in hwcs.keys(): key = k[: 7] + wkey f[e].header[key] = hwcs[k] - log.setLevel('DEBUG') + log.setLevel(default_log_level) closefobj(fname, f) @@ -433,7 +435,7 @@ def _restore(fobj, ukey, fromextnum, w = pywcs.WCS(hdr, fobj, key=ukey) log.setLevel('WARNING') hwcs = w.to_header() - log.setLevel('DEBUG') + log.setLevel(default_log_level) if hwcs is None: return @@ -518,7 +520,7 @@ def readAltWCS(fobj, ext, wcskey=' ', verbose=False): return None log.setLevel('WARNING') hwcs = nwcs.to_header() - log.setLevel('DEBUG') + log.setLevel(default_log_level) if nwcs.wcs.has_cd(): hwcs = pc2cd(hwcs, key=wcskey) diff --git a/stwcs/wcsutil/headerlet.py b/stwcs/wcsutil/headerlet.py index 03861df..1d7351a 100644 --- a/stwcs/wcsutil/headerlet.py +++ b/stwcs/wcsutil/headerlet.py @@ -34,6 +34,9 @@ from . import wcscorr from .hstwcs import HSTWCS from .mappings import basic_wcs +from astropy import log +default_log_level = log.getEffectiveLevel() + # Logging support functions @@ -2144,6 +2147,8 @@ class Headerlet(fits.HDUList): fobj.close() raise ValueError(mess) numsip = countExtn(self, 'SIPWCS') + + log.setLevel('WARNING') for idx in range(1, numsip + 1): siphdr = self[('SIPWCS', idx)].header tg_ext = (siphdr['TG_ENAME'], siphdr['TG_EVER']) @@ -2164,6 +2169,8 @@ class Headerlet(fits.HDUList): # fhdr.insert(wind, pyfits.Card(kw + wkey, # self[0].header[kw])) fhdr.append(fits.Card(kw + wkey, self[0].header[kw])) + + log.setLevel(default_log_level) # Update the WCSCORR table with new rows from the headerlet's WCSs wcscorr.update_wcscorr(fobj, self, 'SIPWCS') diff --git a/stwcs/wcsutil/hstwcs.py b/stwcs/wcsutil/hstwcs.py index aeaa43f..d9146d2 100644 --- a/stwcs/wcsutil/hstwcs.py +++ b/stwcs/wcsutil/hstwcs.py @@ -12,6 +12,9 @@ from . import getinput from . import instruments from .mappings import inst_mappings, ins_spec_kw +from astropy import log +default_log_level = log.getEffectiveLevel() + __all__ = ['HSTWCS'] @@ -382,8 +385,11 @@ class HSTWCS(WCS): sip2hdr : bool If True - include SIP coefficients """ - + if not relax and not sip2hdr: + log.setLevel('WARNING') h = self.to_header(key=wcskey, relax=relax) + log.setLevel(default_log_level) + if not wcskey: wcskey = self.wcs.alt if self.wcs.has_cd(): |