diff options
author | dencheva <dencheva@stsci.edu> | 2008-12-03 09:19:48 -0500 |
---|---|---|
committer | dencheva <dencheva@stsci.edu> | 2008-12-03 09:19:48 -0500 |
commit | 4e8d8be8719226a0ae7467d8010a57ee0c52ba50 (patch) | |
tree | fbea4eef6657111341fdeaa507d4bfd68747362a | |
parent | bc142ccc1365b9d2b782bb49660215e3268b0d0b (diff) | |
download | stwcs_hcf-4e8d8be8719226a0ae7467d8010a57ee0c52ba50.tar.gz |
Added first order coefficients as attributes to HSTWCS object. Added the ability to create a default HSTWCS object for a given instrument.
git-svn-id: http://svn.stsci.edu/svn/ssb/stsci_python/development/trunk/hstwcs@7319 fe389314-cf27-0410-b35b-8c050e845b92
-rw-r--r-- | wcsutil/__init__.py | 37 | ||||
-rw-r--r-- | wcsutil/instruments.py | 63 |
2 files changed, 73 insertions, 27 deletions
diff --git a/wcsutil/__init__.py b/wcsutil/__init__.py index 5a2d640..1ab9fea 100644 --- a/wcsutil/__init__.py +++ b/wcsutil/__init__.py @@ -22,7 +22,7 @@ class HSTWCS(WCS): instrument specific attributes needed by the correction classes. """ - def __init__(self, hdr0, ehdr, fobj=None): + def __init__(self, hdr0=None, ehdr=None, fobj=None, instrument=None): """ :Parameters: `hdr0`: Pyfits Header @@ -33,13 +33,24 @@ class HSTWCS(WCS): pyfits file object """ WCS.__init__(self, ehdr, fobj=fobj) - self.setHDR0kw(hdr0) - self.detector = self.setDetector(hdr0) self.inst_kw = ins_spec_kw - self.setInstrSpecKw(hdr0, ehdr) - self.pscale = self.setPscale() - self.orientat = self.setOrient() + if hdr0 == None and ehdr == None and instrument != None: + #default HSTWCS objectbased on instrument only + self.instrument = instrument + self.setInstrSpecKw() + + elif instrument == None: + assert isinstance (hdr0, pyfits.Header) + assert isinstance (ehdr, pyfits.Header) + + self.setHDR0kw(hdr0) + self.detector = self.setDetector(hdr0) + + self.setInstrSpecKw(hdr0, ehdr) + self.pscale = self.setPscale() + self.orientat = self.setOrient() + self.readIDCCoeffs(ehdr) def setHDR0kw(self, primhdr): @@ -60,7 +71,15 @@ class HSTWCS(WCS): else: return None - def setInstrSpecKw(self, prim_hdr, ext_hdr): + def readIDCCoeffs(self, header): + """ + Reads in first order IDCTAB coefficients if present in the header + """ + coeffs = ['ocx10', 'ocx11', 'ocy10', 'ocy11', 'idcscale'] + for c in coeffs: + self.__setattr__(c, header.get(c, None)) + + def setInstrSpecKw(self, prim_hdr=None, ext_hdr=None): # Based on the instrument kw creates an instalnce of an instrument WCS class # and sets attributes from instrument specific kw if self.instrument in inst_mappings.keys(): @@ -119,8 +138,8 @@ class HSTWCS(WCS): ext_hdr.update('OCY11', self.idcmodel.cy[1,1]) ext_hdr.update('IDCSCALE', self.idcmodel.refpix['PSCALE']) ext_hdr.update('IDCTHETA', self.idcmodel.refpix['THETA']) - #ext_hdr.update('IDCXREF', self.idcmodel.refpix['XREF']) - #ext_hdr.update('IDCYREF', self.idcmodel.refpix['YREF']) + ext_hdr.update('IDCXREF', self.idcmodel.refpix['XREF']) + ext_hdr.update('IDCYREF', self.idcmodel.refpix['YREF']) ext_hdr.update('IDCV2REF', self.idcmodel.refpix['V2REF']) ext_hdr.update('IDCV3REF', self.idcmodel.refpix['V3REF']) #ext_hdr.update('IDCXSIZE', self.idcmodel.refpix['XSIZE']) diff --git a/wcsutil/instruments.py b/wcsutil/instruments.py index a80ec31..e2c2b0b 100644 --- a/wcsutil/instruments.py +++ b/wcsutil/instruments.py @@ -9,7 +9,7 @@ class InstrWCS(object): It prvides a default implementation (modeled by ACS) for all set_kw methods. """ - def __init__(self, hdr0, hdr): + def __init__(self, hdr0=None, hdr=None): self.exthdr = hdr self.primhdr = hdr0 @@ -31,31 +31,52 @@ class InstrWCS(object): self.set_parity() def set_filter1(self): - self.filter1 = self.primhdr.get('FILTER1', None) - + try: + self.filter1 = self.primhdr.get('FILTER1', None) + except: + self.filter1 = None def set_filter2(self): - self.filter2 = self.primhdr.get('FILTER2', None) - + try: + self.filter2 = self.primhdr.get('FILTER2', None) + except: + self.filter2 = None def set_vafactor(self): - self.vafactor = self.exthdr.get('vafactor', 1) - + try: + self.vafactor = self.exthdr.get('vafactor', 1) + except: + self.vafactor = 1. def set_naxis1(self): - self.naxis1 = self.exthdr.get('naxis1', None) - + try: + self.naxis1 = self.exthdr.get('naxis1', None) + except: + self.naxis1 = None def set_naxis2(self): - self.naxis2 = self.exthdr.get('naxis2', None) - + try: + self.naxis2 = self.exthdr.get('naxis2', None) + except: + self.naxis2 = None def set_ltv1(self): - self.ltv1 = self.exthdr.get('ltv1', 0.0) + try: + self.ltv1 = self.exthdr.get('ltv1', 0.0) + except: + self.ltv1 = 0.0 def set_ltv2(self): - self.ltv2 = self.exthdr.get('ltv2', 0.0) + try: + self.ltv2 = self.exthdr.get('ltv2', 0.0) + except: + self.ltv2 = 0.0 def set_binned(self): - self.binned = self.exthdr.get('BINAXIS1', 1) - + try: + self.binned = self.exthdr.get('BINAXIS1', 1) + except: + self.binned = 1 def set_chip(self): - self.chip = self.exthdr.get('CCDCHIP', 1) + try: + self.chip = self.exthdr.get('CCDCHIP', 1) + except: + self.chip = 1 def set_parity(self): self.parity = [[1.0,0.0],[0.0,-1.0]] @@ -75,8 +96,14 @@ class ACSWCS(InstrWCS): 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]]} - detector = self.primhdr.get('detector', None) - self.parity = parity[detector] + try: + detector = self.primhdr.get('detector', None) + except: + detector = None + if detector not in parity.keys(): + parity = InstrWCS.set_parity(self) + else: + self.parity = parity[detector] class WFPC2WCS(InstrWCS): |