diff options
author | hack <hack@stsci.edu> | 2011-04-05 09:42:56 -0400 |
---|---|---|
committer | hack <hack@stsci.edu> | 2011-04-05 09:42:56 -0400 |
commit | 462577895390869011e5aeb22e6afdd55b95c008 (patch) | |
tree | 4fc6c59dbd6cfbe59fe3a11636ea6a959f936353 /wcsutil/hstwcs.py | |
parent | 9753d368de5771d33cf8dd2ae16e735402ec4298 (diff) | |
download | stwcs_hcf-462577895390869011e5aeb22e6afdd55b95c008.tar.gz |
The HSTWCS method 'wcs2header' was modified to append the SIP and IDC distortion model keywords to the header using the '.update()' method instead of extending the header with a CardList. This corrected a problem with the CardList not fully updating the original header making the appended cards unaccessible using the dictionary lookup syntax.
The logic for using the 'readModel()' method of HSTWCS was also improved to not try and read the IDCModel when no 'idctab' had been specified in the header.
Finally, a small bug was fixed in the 'wcscorr' module for recognizing what rows are available for being updated so that the update will actually occur.
git-svn-id: http://svn.stsci.edu/svn/ssb/stsci_python/stsci_python/trunk/stwcs@12392 fe389314-cf27-0410-b35b-8c050e845b92
Diffstat (limited to 'wcsutil/hstwcs.py')
-rw-r--r-- | wcsutil/hstwcs.py | 29 |
1 files changed, 14 insertions, 15 deletions
diff --git a/wcsutil/hstwcs.py b/wcsutil/hstwcs.py index 907f215..b4e9123 100644 --- a/wcsutil/hstwcs.py +++ b/wcsutil/hstwcs.py @@ -172,16 +172,15 @@ class HSTWCS(WCS): CX10, CX11, CY10, CY11, IDCSCALE, IDCTHETA, IDCXREF, IDCYREF, IDCV2REF, IDCV3REF """ - - if self.idctab == None or self.idctab == ' ': + if self.idctab in [None, '', ' ','N/A']: #Keyword idctab is not present in header - check for sip coefficients - if header.has_key('IDCSCALE'): + if header is not None and header.has_key('IDCSCALE'): self._readModelFromHeader(header) else: print "Distortion model is not available: IDCTAB=None\n" self.idcmodel = None elif not os.path.exists(fileutil.osfn(self.idctab)): - if header.has_key('IDCSCALE'): + if header is not None and header.has_key('IDCSCALE'): self._readModelFromHeader(header) else: print 'Distortion model is not available: IDCTAB file %s not found\n' % self.idctab @@ -262,19 +261,19 @@ class HSTWCS(WCS): h = altwcs.pc2cd(h, key=self.wcskey) if idc2hdr: - h.ascard.extend(self._idc2hdr()) - + for card in self._idc2hdr(): + h.update(card.key,value=card.value,comment=card.comment) try: del h.ascard['RESTFRQ'] del h.ascard['RESTWAV'] except KeyError: pass if sip2hdr and self.sip: - cards = self._sip2hdr('a') - h.ascard.extend(cards) - cards = self._sip2hdr('b') - h.ascard.extend(cards) - + for card in self._sip2hdr('a'): + h.update(card.key,value=card.value,comment=card.comment) + for card in self._sip2hdr('b'): + h.update(card.key,value=card.value,comment=card.comment) + try: ap = self.sip.ap except AssertionError: @@ -285,11 +284,11 @@ class HSTWCS(WCS): bp = None if ap: - cards = self._sip2hdr('ap') - h.ascard.extend(cards) + for card in self._sip2hdr('ap'): + h.update(card.key,value=card.value,comment=card.comment) if bp: - cards = self._sip2hdr('bp') - h.ascard.extend(cards) + for card in self._sip2hdr('bp'): + h.update(card.key,value=card.value,comment=card.comment) return h |