diff options
author | dencheva <dencheva@stsci.edu> | 2010-01-25 17:13:05 -0500 |
---|---|---|
committer | dencheva <dencheva@stsci.edu> | 2010-01-25 17:13:05 -0500 |
commit | 1c380263a895a6ce91ef24ee9c2c0445df7bbebb (patch) | |
tree | 75a3f18b0fd58d6ac5adfb1d3af7520967f3a67d /wcsutil/__init__.py | |
parent | add5bab6ddb69e48bc6f95e2f0b38e60c4fb9fed (diff) | |
download | stwcs_hcf-1c380263a895a6ce91ef24ee9c2c0445df7bbebb.tar.gz |
- If idc table is not found and idc model cannot be restored from SIP, idcmodel is always set to None.
- Two cases are considered when output_wcs is created and idcmodel for the reference image is None:
-- if idcmodel can be found, a RuntimeError will be raised and the user prompted to run 'updatewcs' or pass 'undistort=False' kw.
-- if idcmodel cannot be found, the original WCS for the reference object will be returned and used as an output WCS.
git-svn-id: http://svn.stsci.edu/svn/ssb/stsci_python/stsci_python/trunk/stwcs@8640 fe389314-cf27-0410-b35b-8c050e845b92
Diffstat (limited to 'wcsutil/__init__.py')
-rw-r--r-- | wcsutil/__init__.py | 33 |
1 files changed, 20 insertions, 13 deletions
diff --git a/wcsutil/__init__.py b/wcsutil/__init__.py index dcce32f..791f3aa 100644 --- a/wcsutil/__init__.py +++ b/wcsutil/__init__.py @@ -181,25 +181,33 @@ class HSTWCS(WCS): def readModel(self, update=False, header=None): + """ + Reads distortion model from IDCTAB. + If IDCTAB is not found ('N/A', "", or not found on disk), then + if SIP coefficients and first order IDCTAb coefficients are present + in the header, restore the idcmodel from the header. + If not - assign None to self.idcmodel. + """ - if self.idctab == None: + if self.idctab == None or self.idctab == ' ': #Keyword idctab is not present in header - check for sip coefficients if header.has_key('IDCSCALE'): - self.readModelFromHeader(header) + self._readModelFromHeader(header) else: - print 'Distortion model is not available\n' - return + 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'): - self.readModelFromHeader(header) + self._readModelFromHeader(header) else: - print 'Distortion model is not available\n' - return + print 'Distortion model is not available: IDCTAB file %s not found\n' % self.idctab + self.idcmodel = None else: - self.readModelFromIDCTAB(header=header, update=update) + self._readModelFromIDCTAB(header=header, update=update) - def readModelFromHeader(self, header): + def _readModelFromHeader(self, header): # Recreate idc model from SIP coefficients and header kw + print 'Restoring IDC model from SIP coefficients\n' model = models.GeometryModel() cx, cy = coeff_converter.sip2idc(self) model.cx = cx @@ -219,7 +227,7 @@ class HSTWCS(WCS): self.idcmodel = model - def readModelFromIDCTAB(self, header=None, update=False): + def _readModelFromIDCTAB(self, header=None, update=False): """ Purpose ======= @@ -245,9 +253,8 @@ class HSTWCS(WCS): if update: if header==None: print 'Update header with IDC model kw requested but header was not provided\n.' - return else: - self.updatehdr(header) + self._updatehdr(header) def restore(self, header=None): @@ -281,7 +288,7 @@ class HSTWCS(WCS): self.setPscale() self.setOrient() - def updatehdr(self, ext_hdr, newkeywords=None): + def _updatehdr(self, ext_hdr): #kw2add : OCX10, OCX11, OCY10, OCY11 # record the model in the header for use by pydrizzle ext_hdr.update('OCX10', self.idcmodel.cx[1,0]) |