diff options
author | hack <hack@stsci.edu> | 2013-04-30 16:55:57 -0400 |
---|---|---|
committer | hack <hack@stsci.edu> | 2013-04-30 16:55:57 -0400 |
commit | 05d1dce7d577d746482a7cb33d83703ab0b6e769 (patch) | |
tree | a57ddf5997004e18a88ff632a6c3de2b42959c4c | |
parent | 7d529dbb88ec1e47611373638b72ca8d648246a3 (diff) | |
download | stwcs_hcf-05d1dce7d577d746482a7cb33d83703ab0b6e769.tar.gz |
This update removes all references to .has_key() method, including those for list and dict comprehension, but primarily to work with PyFITS 3.2.dev checked in on 29-Apr-2013. [Trac Ticket #1007]
git-svn-id: http://svn.stsci.edu/svn/ssb/stsci_python/stwcs/trunk@24552 fe389314-cf27-0410-b35b-8c050e845b92
-rw-r--r-- | lib/stwcs/distortion/coeff_converter.py | 6 | ||||
-rw-r--r-- | lib/stwcs/distortion/models.py | 4 | ||||
-rw-r--r-- | lib/stwcs/distortion/mutil.py | 10 | ||||
-rw-r--r-- | lib/stwcs/gui/archive_headerlet.py | 4 | ||||
-rw-r--r-- | lib/stwcs/gui/extract_headerlet.py | 2 | ||||
-rw-r--r-- | lib/stwcs/gui/headerlet_summary.py | 2 | ||||
-rw-r--r-- | lib/stwcs/gui/updatewcs.py | 2 | ||||
-rw-r--r-- | lib/stwcs/gui/write_headerlet.py | 4 | ||||
-rw-r--r-- | lib/stwcs/updatewcs/__init__.py | 6 | ||||
-rw-r--r-- | lib/stwcs/wcsutil/altwcs.py | 4 | ||||
-rw-r--r-- | lib/stwcs/wcsutil/hstwcs.py | 4 |
11 files changed, 24 insertions, 24 deletions
diff --git a/lib/stwcs/distortion/coeff_converter.py b/lib/stwcs/distortion/coeff_converter.py index bbad867..a0ff1a4 100644 --- a/lib/stwcs/distortion/coeff_converter.py +++ b/lib/stwcs/distortion/coeff_converter.py @@ -76,8 +76,8 @@ def _read_sip_kw(header): If no SIP header keywords are found, None is returned. """ - if header.has_key("A_ORDER"): - if not header.has_key("B_ORDER"): + if "A_ORDER" in header: + if "B_ORDER" not in header: raise ValueError( "A_ORDER provided without corresponding B_ORDER " "keyword for SIP distortion") @@ -93,7 +93,7 @@ def _read_sip_kw(header): for i in range(m+1): for j in range(m-i+1): b[i, j] = header.get("B_%d_%d" % (i, j), 0.0) - elif header.has_key("B_ORDER"): + elif "B_ORDER" in header: raise ValueError( "B_ORDER provided without corresponding A_ORDER " "keyword for SIP distortion") diff --git a/lib/stwcs/distortion/models.py b/lib/stwcs/distortion/models.py index db48a9f..3e7d2b4 100644 --- a/lib/stwcs/distortion/models.py +++ b/lib/stwcs/distortion/models.py @@ -273,7 +273,7 @@ class IDCModel(GeometryModel): chip=chip,direction=direction,filter1=filter1,filter2=filter2, date=date, offtab=offtab) - if self.refpix.has_key('empty_model') and self.refpix['empty_model']: + if 'empty_model' in self.refpix and self.refpix['empty_model']: pass else: self.refpix['PSCALE'] = self.refpix['PSCALE'] * binned @@ -296,7 +296,7 @@ class WCSModel(GeometryModel): GeometryModel.__init__(self) - if header.has_key('rootname'): + if 'rootname' in header: self.name = header['rootname'] else: self.name = rootname diff --git a/lib/stwcs/distortion/mutil.py b/lib/stwcs/distortion/mutil.py index fc97606..02fc4c2 100644 --- a/lib/stwcs/distortion/mutil.py +++ b/lib/stwcs/distortion/mutil.py @@ -67,10 +67,10 @@ def readIDCtab (tabname, chip=1, date=None, direction='forward', #First thing we need, is to read in the coefficients from the IDC # table and populate the Fx and Fy matrices. - if ftab['PRIMARY'].header.has_key('DETECTOR'): + if 'DETECTOR' in ftab['PRIMARY'].header: detector = ftab['PRIMARY'].header['DETECTOR'] else: - if ftab['PRIMARY'].header.has_key('CAMERA'): + if 'CAMERA' in ftab['PRIMARY'].header: detector = str(ftab['PRIMARY'].header['CAMERA']) else: detector = 1 @@ -263,7 +263,7 @@ def read_tdd_coeffs(phdr): skew_coeffs['TDD_A'] = None skew_coeffs['TDD_B'] = None - if phdr.has_key("TDDORDER"): + if "TDDORDER" in phdr: n = int(phdr["TDDORDER"]) else: print 'TDDORDER kw not present, using default TDD correction' @@ -438,7 +438,7 @@ def readWCSCoeffs(header): for i in xrange(_xorder+1): for j in xrange(i+1): xcname = cxstr+str(j)+'_'+str(i-j) - if header.has_key(xcname): + if xcname in header: fx[i,j] = header[xcname] # Extract Y coeffs separately as a different order may @@ -446,7 +446,7 @@ def readWCSCoeffs(header): for i in xrange(_yorder+1): for j in xrange(i+1): ycname = cystr+str(j)+'_'+str(i-j) - if header.has_key(ycname): + if ycname in header: fy[i,j] = header[ycname] # Now set the linear terms diff --git a/lib/stwcs/gui/archive_headerlet.py b/lib/stwcs/gui/archive_headerlet.py index 707d521..735baa4 100644 --- a/lib/stwcs/gui/archive_headerlet.py +++ b/lib/stwcs/gui/archive_headerlet.py @@ -49,7 +49,7 @@ def run(configObj=None): # such as those above cdict = configObj.dict() # remove any rules defined for the TEAL interface - if cdict.has_key("_RULES_"): del cdict['_RULES_'] + if "_RULES_" in cdict: del cdict['_RULES_'] del cdict['_task_name_'] del cdict['filename'] del cdict['hdrname'] @@ -66,4 +66,4 @@ def run(configObj=None): # author=None, descrip=None, history=None, # hdrlet=None, clobber=False) headerlet.archive_as_headerlet(configObj['filename'], configObj['hdrname'], - **cdict)
\ No newline at end of file + **cdict) diff --git a/lib/stwcs/gui/extract_headerlet.py b/lib/stwcs/gui/extract_headerlet.py index 8751ff3..c807920 100644 --- a/lib/stwcs/gui/extract_headerlet.py +++ b/lib/stwcs/gui/extract_headerlet.py @@ -45,7 +45,7 @@ def run(configObj=None): # such as those above cdict = configObj.dict() # remove any rules defined for the TEAL interface - if cdict.has_key("_RULES_"): del cdict['_RULES_'] + if "_RULES_" in cdict: del cdict['_RULES_'] del cdict['_task_name_'] del cdict['filename'] del cdict['output'] diff --git a/lib/stwcs/gui/headerlet_summary.py b/lib/stwcs/gui/headerlet_summary.py index 28c26c2..1b2245e 100644 --- a/lib/stwcs/gui/headerlet_summary.py +++ b/lib/stwcs/gui/headerlet_summary.py @@ -36,7 +36,7 @@ def run(configObj=None): # such as those above cdict = configObj.dict() # remove any rules defined for the TEAL interface - if cdict.has_key("_RULES_"): del cdict['_RULES_'] + if "_RULES_" in cdict: del cdict['_RULES_'] del cdict['_task_name_'] del cdict['filename'] if headerlet.is_par_blank(cdict['columns']): diff --git a/lib/stwcs/gui/updatewcs.py b/lib/stwcs/gui/updatewcs.py index 912bf16..e818d96 100644 --- a/lib/stwcs/gui/updatewcs.py +++ b/lib/stwcs/gui/updatewcs.py @@ -46,7 +46,7 @@ def run(configObj=None): # such as those above cdict = configObj.dict() # remove any rules defined for the TEAL interface - if cdict.has_key("_RULES_"): del cdict['_RULES_'] + if "_RULES_" in cdict: del cdict['_RULES_'] del cdict['_task_name_'] del cdict['input'] del cdict['extname'] diff --git a/lib/stwcs/gui/write_headerlet.py b/lib/stwcs/gui/write_headerlet.py index 442650d..b9b17ad 100644 --- a/lib/stwcs/gui/write_headerlet.py +++ b/lib/stwcs/gui/write_headerlet.py @@ -60,7 +60,7 @@ def run(configObj=None): # such as those above cdict = configObj.dict() # remove any rules defined for the TEAL interface - if cdict.has_key("_RULES_"): del cdict['_RULES_'] + if "_RULES_" in cdict: del cdict['_RULES_'] del cdict['_task_name_'] del cdict['filename'] del cdict['hdrname'] @@ -77,4 +77,4 @@ def run(configObj=None): # author=None, descrip=None, history=None, # attach=True, clobber=False) headerlet.write_headerlet(flist, configObj['hdrname'], - **cdict)
\ No newline at end of file + **cdict) diff --git a/lib/stwcs/updatewcs/__init__.py b/lib/stwcs/updatewcs/__init__.py index 37ab6e3..43f572b 100644 --- a/lib/stwcs/updatewcs/__init__.py +++ b/lib/stwcs/updatewcs/__init__.py @@ -126,7 +126,7 @@ def makecorr(fname, allowed_corr): for i in range(len(f))[1:]: extn = f[i] - if extn.header.has_key('extname'): + if 'extname' in extn.header: extname = extn.header['extname'].lower() if extname == 'sci': wcsutil.restoreWCS(f, ext=i, wcskey='O') @@ -167,12 +167,12 @@ def makecorr(fname, allowed_corr): for kw in kw2update: f[1].header.update(kw, kw2update[kw]) # Finally record the version of the software which updated the WCS - if f[0].header.has_key('HISTORY'): + if 'HISTORY' in f[0].header: f[0].header.update(key='UPWCSVER', value=stwcs.__version__, comment="Version of STWCS used to updated the WCS", before='HISTORY') f[0].header.update(key='PYWCSVER', value=pywcs.__version__, comment="Version of PYWCS used to updated the WCS", before='HISTORY') - elif f[0].header.has_key('ASN_MTYP'): + elif 'ASN_MTYP' in f[0].header: f[0].header.update(key='UPWCSVER', value=stwcs.__version__, comment="Version of STWCS used to updated the WCS", after='ASN_MTYP') f[0].header.update(key='PYWCSVER', value=pywcs.__version__, diff --git a/lib/stwcs/wcsutil/altwcs.py b/lib/stwcs/wcsutil/altwcs.py index e4ca488..ad17a11 100644 --- a/lib/stwcs/wcsutil/altwcs.py +++ b/lib/stwcs/wcsutil/altwcs.py @@ -424,10 +424,10 @@ def _restore(fobj, ukey, fromextnum, fobj[toextension].header.update(key=key, value = hwcs[k]) else: continue - if key == 'O' and fobj[toextension].header.has_key('TDDALPHA'): + if key == 'O' and 'TDDALPHA' in fobj[toextension].header: fobj[toextension].header['TDDALPHA'] = 0.0 fobj[toeztension].header['TDDBETA'] = 0.0 - if fobj[toextension].header.has_key('ORIENTAT'): + if 'ORIENTAT' in fobj[toextension].header: norient = np.rad2deg(np.arctan2(hwcs['CD1_2'+'%s' %ukey], hwcs['CD2_2'+'%s' %ukey])) fobj[toextension].header.update(key='ORIENTAT', value=norient) diff --git a/lib/stwcs/wcsutil/hstwcs.py b/lib/stwcs/wcsutil/hstwcs.py index c5bdd71..f52c27a 100644 --- a/lib/stwcs/wcsutil/hstwcs.py +++ b/lib/stwcs/wcsutil/hstwcs.py @@ -218,13 +218,13 @@ class HSTWCS(WCS): """ if self.idctab in [None, '', ' ','N/A']: #Keyword idctab is not present in header - check for sip coefficients - if header is not None and header.has_key('IDCSCALE'): + if header is not None and 'IDCSCALE' in header: 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 is not None and header.has_key('IDCSCALE'): + if header is not None and 'IDCSCALE' in header: self._readModelFromHeader(header) else: print 'Distortion model is not available: IDCTAB file %s not found\n' % self.idctab |