diff options
author | Nadia Dencheva <nadia.astropy@gmail.com> | 2016-08-14 17:14:55 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-08-14 17:14:55 -0400 |
commit | 36b6b7837e8e6c87c372af25c3636a0b6020ca30 (patch) | |
tree | cc105741d82f0255a8f941a1cf7e79f01845829a | |
parent | 854883354a933451a6120d96154a25c55dc14826 (diff) | |
parent | 7d3caf090ee2d975f5d314de3a9d4c89a1c0e9e5 (diff) | |
download | stwcs_hcf-36b6b7837e8e6c87c372af25c3636a0b6020ca30.tar.gz |
Merge pull request #16 from nden/catch-info-messages
Catch info messages
-rw-r--r-- | stwcs/updatewcs/__init__.py | 4 | ||||
-rw-r--r-- | stwcs/wcsutil/altwcs.py | 11 | ||||
-rw-r--r-- | stwcs/wcsutil/headerlet.py | 7 | ||||
-rw-r--r-- | stwcs/wcsutil/hstwcs.py | 8 |
4 files changed, 27 insertions, 3 deletions
diff --git a/stwcs/updatewcs/__init__.py b/stwcs/updatewcs/__init__.py index a59f106..fe1eea2 100644 --- a/stwcs/updatewcs/__init__.py +++ b/stwcs/updatewcs/__init__.py @@ -9,6 +9,8 @@ from .. import __version__ from astropy import wcs as pywcs import astropy +from astropy import log +default_log_level = log.getEffectiveLevel() from . import utils, corrections from . import npol, det2im @@ -210,7 +212,9 @@ def copyWCS(w, ehdr): WCS of the 'SCI' extension to the headers of 'ERR', 'DQ', 'SDQ', 'TIME' or 'SAMP' extensions. """ + log.setLevel('WARNING') hwcs = w.to_header() + log.setLevel(default_log_level) if w.wcs.has_cd(): wcsutil.pc2cd(hwcs) diff --git a/stwcs/wcsutil/altwcs.py b/stwcs/wcsutil/altwcs.py index 050a15e..2d1565d 100644 --- a/stwcs/wcsutil/altwcs.py +++ b/stwcs/wcsutil/altwcs.py @@ -6,6 +6,9 @@ from astropy import wcs as pywcs 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'] @@ -120,7 +123,7 @@ def archiveWCS(fname, ext, wcskey=" ", wcsname=" ", reusekey=False): else: wkey = wcskey wname = wcsname - + log.setLevel('WARNING') for e in ext: hdr = _getheader(f, e) w = pywcs.WCS(hdr, f) @@ -147,6 +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(default_log_level) closefobj(fname, f) @@ -429,8 +433,9 @@ def _restore(fobj, ukey, fromextnum, # 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 @@ -513,7 +518,9 @@ 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/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(): |