diff options
author | dencheva <dencheva@stsci.edu> | 2009-02-12 14:57:59 -0500 |
---|---|---|
committer | dencheva <dencheva@stsci.edu> | 2009-02-12 14:57:59 -0500 |
commit | 29e09d97fbac778ad0d216fef4b21fc189315bf4 (patch) | |
tree | a35d83a729925fdd8fe7fd29021864f395c5d414 | |
parent | 48391819c2284d83a2440b3ba7173a2e4c18354b (diff) | |
download | stwcs_hcf-29e09d97fbac778ad0d216fef4b21fc189315bf4.tar.gz |
Added support for nicmos, stis, wfc3
git-svn-id: http://svn.stsci.edu/svn/ssb/stsci_python/development/trunk/updatewcs@7549 fe389314-cf27-0410-b35b-8c050e845b92
-rw-r--r-- | hstwcs/__init__.py | 15 | ||||
-rw-r--r-- | hstwcs/apply_corrections.py | 8 | ||||
-rw-r--r-- | wcsutil/__init__.py | 17 | ||||
-rw-r--r-- | wcsutil/instruments.py | 132 | ||||
-rw-r--r-- | wcsutil/mappings.py | 9 |
5 files changed, 160 insertions, 21 deletions
diff --git a/hstwcs/__init__.py b/hstwcs/__init__.py index dfb2e4b..926d4c3 100644 --- a/hstwcs/__init__.py +++ b/hstwcs/__init__.py @@ -129,6 +129,14 @@ def getNrefchip(fobj): Nrefchip = 1 elif instrument == 'NICMOS': Nrefchip = fobj[0].header['CAMERA'] + elif instrument == 'WFC3': + detector = fobj[0].header['DETECTOR'] + if detector == 'UVIS': + Nrefchip =2 + else: + Nrefchip = 1 + else: + Nrefchip = 1 return Nrefchip, Nrefext def checkFiles(input): @@ -136,9 +144,9 @@ def checkFiles(input): Purpose ======= Checks that input files are in the correct format. - Converts geis and waiver fits files to multietension fits. + Converts geis and waiver fits files to multiextension fits. """ - from pytools.check_files import geis2mef, waiver2mef + from pytools.check_files import geis2mef, waiver2mef, checkFiles removed_files = [] newfiles = [] for file in input: @@ -176,5 +184,8 @@ def checkFiles(input): print 'The following files will be removed from the list of files to be processed :\n' for f in removed_files: print f + + newfiles = checkFiles(newfiles)[0] + return newfiles diff --git a/hstwcs/apply_corrections.py b/hstwcs/apply_corrections.py index 22dfbbc..b30c4c5 100644 --- a/hstwcs/apply_corrections.py +++ b/hstwcs/apply_corrections.py @@ -12,7 +12,10 @@ __docformat__ = 'restructuredtext' # These are the default corrections applied also in the pipeline. allowed_corrections={'WFPC2': ['MakeWCS','CompSIP', 'VACorr', 'DGEOCorr'], - 'ACS': ['TDDCorr', 'MakeWCS', 'CompSIP','VACorr', 'DGEOCorr'] + 'ACS': ['TDDCorr', 'MakeWCS', 'CompSIP','VACorr', 'DGEOCorr'], + 'STIS': ['MakeWCS', 'CompSIP','VACorr'], + 'NICMOS': ['MakeWCS', 'CompSIP','VACorr'], + 'WFC3': ['MakeWCS', 'CompSIP','VACorr'], } def setCorrections(fname, vacorr=True, tddcorr=True, dgeocorr=True): @@ -115,9 +118,10 @@ def applyDgeoCorr(fname, udgeocorr): # in first extension header applyDGEOCorr = True except KeyError: - print 'DGEOFILE keyword not found in primary header' applyDGEOCorr = False + return applyDGEOCorr + if isOldStyleDGEO(fname, fdgeo0): applyDGEOCorr = False return (applyDGEOCorr and udgeocorr) diff --git a/wcsutil/__init__.py b/wcsutil/__init__.py index ee22c19..adde32a 100644 --- a/wcsutil/__init__.py +++ b/wcsutil/__init__.py @@ -103,11 +103,19 @@ class HSTWCS(WCS): self.offtab = primhdr.get('OFFTAB', None) self.idctab = primhdr.get('IDCTAB', None) self.date_obs = primhdr.get('DATE-OBS', None) - self.pav3 = primhdr.get('PA_V3', None) self.ra_targ = primhdr.get('RA_TARG', None) self.dec_targ = primhdr.get('DEC_TARG', None) - self.filename = primhdr.get('FILENAME', "") - self.detector = primhdr.get('DETECTOR', None) + #self.detector = primhdr.get('DETECTOR', None) + + try: + self.pav3 = primhdr['PA_V3'] + + except KeyError: + print 'Kw PA_V3 not found in primary header.' + print 'This is typical for some old files. Please retrieve the files fromthe archive again.' + print 'Quitting ...' + raise + def readIDCCoeffs(self, header): @@ -174,8 +182,7 @@ class HSTWCS(WCS): cd22 = -cd11 cdmat = N.array([[cd11, cd12],[cd21,cd22]]) self.wcs.cd = cdmat * self.pscale/3600 - - + def readModel(self, update=False, header=None): """ diff --git a/wcsutil/instruments.py b/wcsutil/instruments.py index d0ace1c..4491079 100644 --- a/wcsutil/instruments.py +++ b/wcsutil/instruments.py @@ -19,6 +19,7 @@ class InstrWCS(object): There should be a set_kw method for all kw listed in mappings.ins_spec_kw """ + self.set_detector() self.set_filter1() self.set_filter2() self.set_vafactor() @@ -29,7 +30,7 @@ class InstrWCS(object): self.set_binned() self.set_chip() self.set_parity() - self.set_detector() + def set_filter1(self): try: @@ -97,19 +98,23 @@ class ACSWCS(InstrWCS): self.exthdr = hdr InstrWCS.__init__(self,hdr0, hdr) self.set_ins_spec_kw() + + def set_detector(self): + try: + self.detector = self.primhdr['DETECTOR'] + except KeyError: + print 'ERROR: Detector kw not found.\n' + raise def set_parity(self): parity = {'WFC':[[1.0,0.0],[0.0,-1.0]], 'HRC':[[-1.0,0.0],[0.0,1.0]], 'SBC':[[-1.0,0.0],[0.0,1.0]]} - try: - detector = self.primhdr.get('detector', None) - except: - detector = None - if detector not in parity.keys(): + + if self.detector not in parity.keys(): parity = InstrWCS.set_parity(self) else: - self.parity = parity[detector] + self.parity = parity[self.detector] class WFPC2WCS(InstrWCS): @@ -129,7 +134,7 @@ class WFPC2WCS(InstrWCS): def set_filter2(self): self.filter2 = self.primhdr.get('FILTNAM2', None) if self.filter2 == " " or self.filter2 == None: - self.filter2 = 'CLEAR1' + self.filter2 = 'CLEAR2' def set_binned(self): @@ -146,4 +151,113 @@ class WFPC2WCS(InstrWCS): self.parity = [[-1.0,0.],[0.,1.0]] def set_detector(self): - self.detector = self.exthdr.get('DETECTOR', None) + try: + self.detector = self.exthdr['DETECTOR'] + except KeyError: + print 'ERROR: Detector kw not found.\n' + raise + + +class WFC3WCS(InstrWCS): + """ + Create a WFC3 detector specific class + """ + + def __init__(self, hdr0, hdr): + self.primhdr = hdr0 + self.exthdr = hdr + InstrWCS.__init__(self,hdr0, hdr) + self.set_ins_spec_kw() + + def set_detector(self): + try: + self.detector = self.primhdr['DETECTOR'] + except KeyError: + print 'ERROR: Detector kw not found.\n' + raise + + def set_filter1(self): + self.filter1 = self.primhdr.get('FILTER', None) + if self.filter1 == " " or self.filter1 == None: + self.filter1 = 'CLEAR' + + def set_filter2(self): + #Nicmos idc tables do not allow 2 filters. + self.filter2 = 'CLEAR' + + def set_parity(self): + parity = {'UVIS':[[-1.0,0.0],[0.0,1.0]], + 'IR':[[-1.0,0.0],[0.0,1.0]]} + + if self.detector not in parity.keys(): + parity = InstrWCS.set_parity(self) + else: + self.parity = parity[self.detector] + +class NICMOSWCS(InstrWCS): + """ + Create a NICMOS specific class + """ + + def __init__(self, hdr0, hdr): + self.primhdr = hdr0 + self.exthdr = hdr + InstrWCS.__init__(self,hdr0, hdr) + self.set_ins_spec_kw() + + def set_parity(self): + self.parity = [[-1.0,0.],[0.,1.0]] + + def set_filter1(self): + self.filter1 = self.primhdr.get('FILTER', None) + if self.filter1 == " " or self.filter1 == None: + self.filter1 = 'CLEAR' + + def set_filter2(self): + #Nicmos idc tables do not allow 2 filters. + self.filter2 = 'CLEAR' + """ + self.filter2 = self.primhdr.get('FILTER2', None) + if self.filter2 == " " or self.filter2 == None: + self.filter2 = 'CLEAR2' + """ + def set_chip(self): + self.chip = self.detector + + def set_detector(self): + try: + self.detector = self.primhdr['CAMERA'] + except KeyError: + print 'ERROR: Detector kw not found.\n' + raise + +class STISWCS(InstrWCS): + """ + Create a NICMOS specific class + """ + + def __init__(self, hdr0, hdr): + self.primhdr = hdr0 + self.exthdr = hdr + InstrWCS.__init__(self,hdr0, hdr) + self.set_ins_spec_kw() + + def set_parity(self): + self.parity = [[-1.0,0.],[0.,1.0]] + + def set_filter1(self): + self.filter1 = self.exthdr.get('OPT_ELEM', None) + if self.filter1 == " " or self.filter1 == None: + self.filter1 = 'CLEAR1' + + def set_filter2(self): + self.filter2 = self.exthdr.get('FILTER', None) + if self.filter2 == " " or self.filter2 == None: + self.filter2 = 'CLEAR2' + + def set_detector(self): + try: + self.detector = self.primhdr['DETECTOR'] + except KeyError: + print 'ERROR: Detector kw not found.\n' + raise
\ No newline at end of file diff --git a/wcsutil/mappings.py b/wcsutil/mappings.py index d5d5e29..48f687f 100644 --- a/wcsutil/mappings.py +++ b/wcsutil/mappings.py @@ -4,15 +4,18 @@ # The instrument class handles instrument specific keywords inst_mappings={'WFPC2': 'WFPC2WCS', - 'ACS': 'ACSWCS' + 'ACS': 'ACSWCS', + 'NICMOS': 'NICMOSWCS', + 'STIS': 'STISWCS', + 'WFC3': 'WFC3WCS' } # A list of instrument specific keywords # Every instrument class must have methods which define each of these # as class attributes. -ins_spec_kw = ['ltv1', 'ltv2', 'parity', 'binned','vafactor', 'chip', - 'naxis1', 'naxis2', 'filter1', 'filter2', 'detector'] +ins_spec_kw = [ 'detector', 'ltv1', 'ltv2', 'parity', 'binned','vafactor', 'chip', + 'naxis1', 'naxis2', 'filter1', 'filter2'] # A list of keywords defined in the primary header. # The HSTWCS class sets this as attributes |