From 43010144f1f869e17a62a98de3d8fc51b6630c4c Mon Sep 17 00:00:00 2001 From: Nadia Dencheva Date: Sun, 14 Aug 2016 11:16:16 -0400 Subject: altwcs logging --- stwcs/wcsutil/altwcs.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'stwcs/wcsutil/altwcs.py') diff --git a/stwcs/wcsutil/altwcs.py b/stwcs/wcsutil/altwcs.py index 050a15e..cba400f 100644 --- a/stwcs/wcsutil/altwcs.py +++ b/stwcs/wcsutil/altwcs.py @@ -3,6 +3,7 @@ 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 @@ -120,7 +121,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 +148,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') closefobj(fname, f) @@ -429,8 +431,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('DEBUG') if hwcs is None: return @@ -513,7 +516,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('DEBUG') if nwcs.wcs.has_cd(): hwcs = pc2cd(hwcs, key=wcskey) -- cgit From 2b246650dae33a3a11220adf5f044b419a5ed1ea Mon Sep 17 00:00:00 2001 From: Nadia Dencheva Date: Sun, 14 Aug 2016 11:46:28 -0400 Subject: Catch log.info messages from astropy.wcs and don't print them. --- stwcs/wcsutil/altwcs.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'stwcs/wcsutil/altwcs.py') 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) -- cgit