diff options
author | dencheva <dencheva@stsci.edu> | 2010-09-23 16:46:28 -0400 |
---|---|---|
committer | dencheva <dencheva@stsci.edu> | 2010-09-23 16:46:28 -0400 |
commit | eeb95498b61fae9ae48a8d18abe668b1021ee26c (patch) | |
tree | 4066622383676cf36b2f5c84e3e9f03cc4a80240 /updatewcs/__init__.py | |
parent | 41c0f740305f584bb8d75c978450a08948a98f12 (diff) | |
download | stwcs_hcf-eeb95498b61fae9ae48a8d18abe668b1021ee26c.tar.gz |
Moved deleteing of WCS's when a new idctab is detected to updatewcs
git-svn-id: http://svn.stsci.edu/svn/ssb/stsci_python/stsci_python/trunk/stwcs@10384 fe389314-cf27-0410-b35b-8c050e845b92
Diffstat (limited to 'updatewcs/__init__.py')
-rw-r--r-- | updatewcs/__init__.py | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/updatewcs/__init__.py b/updatewcs/__init__.py index c973cb1..8992b69 100644 --- a/updatewcs/__init__.py +++ b/updatewcs/__init__.py @@ -78,6 +78,11 @@ def updatewcs(input, vacorr=True, tddcorr=True, dgeocorr=True, d2imcorr=True, acorr = apply_corrections.setCorrections(f, vacorr=vacorr, \ tddcorr=tddcorr,dgeocorr=dgeocorr, d2imcorr=d2imcorr) + if 'MakeWCS' in acorr and newIDCTAB(fname): + print "New IDCTAB file detected. This invalidates all WCS's." + print "Deleting all previous WCS's" + cleanWCS(fname) + #restore the original WCS keywords #wcsutil.restoreWCS(f, ext=[], wcskey='O', clobber=True) makecorr(f, acorr, wkey=wcskey, wname=wcsname, clobber=False) @@ -287,7 +292,28 @@ def checkFiles(input): return newfiles - +def newIDCTAB(fname): + #When this is called we know there's a kw IDCTAB in the header + idctab = fileutil.osfn(pyfits.getval(fname, 'IDCTAB')) + try: + #check for the presence of IDCTAB in the first extension + oldidctab = fileutil.osfn(pyfits.getval(fname, 'IDCTAB', ext=1)) + except KeyError: + return False + if idctab == oldidctab: + return False + else: + return True + +def cleanWCS(fname): + # A new IDCTAB means all previously computed WCS's are invalid + # We are deleting all of them except the original OPUS WCS.nvalidates all WCS's. + keys = altwcs.wcskeys(pyfits.getheader(fname, ext=1)) + f = pyfits.open(fname, mode='update') + fext = range(len(f)) + for key in keys: + altwcs.deleteWCS(fname, ext=fext,wcskey=key) + def getCorrections(instrument): """ Print corrections available for an instrument |