summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--stwcs/updatewcs/__init__.py13
-rw-r--r--stwcs/updatewcs/apply_corrections.py2
-rw-r--r--stwcs/wcsutil/altwcs.py14
-rw-r--r--stwcs/wcsutil/hstwcs.py6
4 files changed, 24 insertions, 11 deletions
diff --git a/stwcs/updatewcs/__init__.py b/stwcs/updatewcs/__init__.py
index 46faa72..fe326c3 100644
--- a/stwcs/updatewcs/__init__.py
+++ b/stwcs/updatewcs/__init__.py
@@ -1,6 +1,8 @@
from __future__ import absolute_import, division, print_function
import atexit
+import warnings
+
from astropy.io import fits
from .. import wcsutil
#from ..wcsutil.hwstwcs import HSTWCS
@@ -25,6 +27,7 @@ atexit.register(logging.shutdown)
# Note: The order of corrections is important
+warnings.filterwarnings("ignore", message="^Some non-standard WCS keywords were excluded:", module="astropy.wcs")
def updatewcs(input, vacorr=True, tddcorr=True, npolcorr=True, d2imcorr=True,
checkfiles=True, verbose=False):
@@ -119,7 +122,10 @@ def makecorr(fname, allowed_corr):
f.readall()
# Determine the reference chip and create the reference HSTWCS object
nrefchip, nrefext = getNrefchip(f)
+
+ log.setLevel("WARNING")
wcsutil.restoreWCS(f, nrefext, wcskey='O')
+ log.setLevel(default_log_level)
rwcs = wcsutil.HSTWCS(fobj=f, ext=nrefext)
rwcs.readModel(update=True, header=f[nrefext].header)
@@ -134,14 +140,18 @@ def makecorr(fname, allowed_corr):
if 'extname' in extn.header:
extname = extn.header['extname'].lower()
if extname == 'sci':
+ log.setLevel("WARNING")
wcsutil.restoreWCS(f, ext=i, wcskey='O')
+ log.setLevel(default_log_level)
sciextver = extn.header['extver']
ref_wcs = rwcs.deepcopy()
hdr = extn.header
ext_wcs = wcsutil.HSTWCS(fobj=f, ext=i)
# check if it exists first!!!
# 'O ' can be safely archived again because it has been restored first.
+ # perhaps archive only if it doesn't exist???
wcsutil.archiveWCS(f, ext=i, wcskey="O", wcsname="OPUS", reusekey=True)
+
ext_wcs.readModel(update=True, header=hdr)
for c in allowed_corr:
if c != 'NPOLCorr' and c != 'DET2IMCorr':
@@ -213,10 +223,7 @@ 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)
for k in hwcs.keys():
diff --git a/stwcs/updatewcs/apply_corrections.py b/stwcs/updatewcs/apply_corrections.py
index 247dba0..26a9cd0 100644
--- a/stwcs/updatewcs/apply_corrections.py
+++ b/stwcs/updatewcs/apply_corrections.py
@@ -249,7 +249,7 @@ def apply_d2im_correction(fname, d2imcorr):
return False
fd2im0 = fileutil.osfn(fd2im0)
if not fileutil.findFile(fd2im0):
- message = "D2IMFILE {0} not found.".format(fname)
+ message = "D2IMFILE {0} not found.".format(fd2im0)
logger.critical(message)
raise IOError(message)
try:
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