diff options
author | Nadia Dencheva <nadia.dencheva@gmail.com> | 2016-08-10 11:53:10 -0400 |
---|---|---|
committer | Nadia Dencheva <nadia.dencheva@gmail.com> | 2016-08-10 11:53:10 -0400 |
commit | af56b9ad582ac0fe25ef7e941fbec4309906f7f5 (patch) | |
tree | 972d9d8748653e0efe32afedf0b97b638e3874a8 /stwcs/wcsutil/wcsdiff.py | |
parent | 0268dd1037bfacf06af22ff614c5d8479bd83e99 (diff) | |
download | stwcs_hcf-af56b9ad582ac0fe25ef7e941fbec4309906f7f5.tar.gz |
the rest of pep8 changes
Diffstat (limited to 'stwcs/wcsutil/wcsdiff.py')
-rw-r--r-- | stwcs/wcsutil/wcsdiff.py | 53 |
1 files changed, 29 insertions, 24 deletions
diff --git a/stwcs/wcsutil/wcsdiff.py b/stwcs/wcsutil/wcsdiff.py index cfc2d66..9f00f1a 100644 --- a/stwcs/wcsutil/wcsdiff.py +++ b/stwcs/wcsutil/wcsdiff.py @@ -1,10 +1,12 @@ -from __future__ import print_function +from __future__ import absolute_import, print_function + from astropy import wcs as pywcs from collections import OrderedDict from astropy.io import fits from .headerlet import parse_filename import numpy as np + def is_wcs_identical(scifile, file2, sciextlist, fextlist, scikey=" ", file2key=" ", verbose=False): """ @@ -48,28 +50,29 @@ def is_wcs_identical(scifile, file2, sciextlist, fextlist, scikey=" ", sciobj, sciname, close_scifile = parse_filename(scifile) diff['file_names'] = [scifile, file2] if get_rootname(scifile) != get_rootname(file2): - #logger.info('Rootnames do not match.') - diff['rootname'] = ("%s: %s", "%s: %s") % (sciname, get_rootname(scifile), file2, get_rootname(file2)) + # logger.info('Rootnames do not match.') + diff['rootname'] = ("%s: %s", "%s: %s") % (sciname, get_rootname(scifile), file2, + get_rootname(file2)) result = False for i, j in zip(sciextlist, fextlist): w1 = pywcs.WCS(sciobj[i].header, sciobj, key=scikey) w2 = pywcs.WCS(fobj[j].header, fobj, key=file2key) diff['extension'] = [get_extname_extnum(sciobj[i]), get_extname_extnum(fobj[j])] if not np.allclose(w1.wcs.crval, w2.wcs.crval, rtol=10**(-7)): - #logger.info('CRVALs do not match') + # logger.info('CRVALs do not match') diff['CRVAL'] = w1.wcs.crval, w2.wcs.crval result = False if not np.allclose(w1.wcs.crpix, w2.wcs.crpix, rtol=10**(-7)): - #logger.info('CRPIX do not match') - diff ['CRPIX'] = w1.wcs.crpix, w2.wcs.crpix + # logger.info('CRPIX do not match') + diff['CRPIX'] = w1.wcs.crpix, w2.wcs.crpix result = False if not np.allclose(w1.wcs.cd, w2.wcs.cd, rtol=10**(-7)): - #logger.info('CDs do not match') - diff ['CD'] = w1.wcs.cd, w2.wcs.cd + # logger.info('CDs do not match') + diff['CD'] = w1.wcs.cd, w2.wcs.cd result = False if not (np.array(w1.wcs.ctype) == np.array(w2.wcs.ctype)).all(): - #logger.info('CTYPEs do not match') - diff ['CTYPE'] = w1.wcs.ctype, w2.wcs.ctype + # logger.info('CTYPEs do not match') + diff['CTYPE'] = w1.wcs.ctype, w2.wcs.ctype result = False if w1.sip or w2.sip: if (w2.sip and not w1.sip) or (w1.sip and not w2.sip): @@ -79,41 +82,41 @@ def is_wcs_identical(scifile, file2, sciextlist, fextlist, scikey=" ", diff['SIP_A'] = 'SIP_A differ' result = False if not np.allclose(w1.sip.b, w2.sip.b, rtol=10**(-7)): - #logger.info('SIP coefficients do not match') - diff ['SIP_B'] = (w1.sip.b, w2.sip.b) + # logger.info('SIP coefficients do not match') + diff['SIP_B'] = (w1.sip.b, w2.sip.b) result = False if w1.cpdis1 or w2.cpdis1: if w1.cpdis1 and not w2.cpdis1 or w2.cpdis1 and not w1.cpdis1: diff['CPDIS1'] = "CPDIS1 missing" - result=False + result = False if w1.cpdis2 and not w2.cpdis2 or w2.cpdis2 and not w1.cpdis2: diff['CPDIS2'] = "CPDIS2 missing" result = False if not np.allclose(w1.cpdis1.data, w2.cpdis1.data, rtol=10**(-7)): - #logger.info('NPOL distortions do not match') - diff ['CPDIS1_data'] = (w1.cpdis1.data, w2.cpdis1.data) + # logger.info('NPOL distortions do not match') + diff['CPDIS1_data'] = (w1.cpdis1.data, w2.cpdis1.data) result = False if not np.allclose(w1.cpdis2.data, w2.cpdis2.data, rtol=10**(-7)): - #logger.info('NPOL distortions do not match') - diff ['CPDIS2_data'] = (w1.cpdis2.data, w2.cpdis2.data) + # logger.info('NPOL distortions do not match') + diff['CPDIS2_data'] = (w1.cpdis2.data, w2.cpdis2.data) result = False if w1.det2im1 or w2.det2im1: if w1.det2im1 and not w2.det2im1 or \ - w2.det2im1 and not w1.det2im1: + w2.det2im1 and not w1.det2im1: diff['DET2IM'] = "Det2im1 missing" result = False if not np.allclose(w1.det2im1.data, w2.det2im1.data, rtol=10**(-7)): - #logger.info('Det2Im corrections do not match') - diff ['D2IM1_data'] = (w1.det2im1.data, w2.det2im1.data) - result = False + # logger.info('Det2Im corrections do not match') + diff['D2IM1_data'] = (w1.det2im1.data, w2.det2im1.data) + result = False if w1.det2im2 or w2.det2im2: if w1.det2im2 and not w2.det2im2 or \ w2.det2im2 and not w1.det2im2: diff['DET2IM2'] = "Det2im2 missing" result = False if not np.allclose(w1.det2im2.data, w2.det2im2.data, rtol=10**(-7)): - #logger.info('Det2Im corrections do not match') - diff ['D2IM2_data'] = (w1.det2im2.data, w2.det2im2.data) + # logger.info('Det2Im corrections do not match') + diff['D2IM2_data'] = (w1.det2im2.data, w2.det2im2.data) result = False if not result and verbose: for key in diff: @@ -124,6 +127,7 @@ def is_wcs_identical(scifile, file2, sciextlist, fextlist, scikey=" ", sciobj.close() return result, diff + def get_rootname(fname): """ Returns the value of ROOTNAME or DESTIM @@ -139,12 +143,13 @@ def get_rootname(fname): rootname = fname return rootname + def get_extname_extnum(ext): """ Return (EXTNAME, EXTNUM) of a FITS extension """ extname = "" - extnum=1 + extnum = 1 extname = ext.header.get('EXTNAME', extname) extnum = ext.header.get('EXTVER', extnum) return (extname, extnum) |