diff options
-rw-r--r-- | wcsutil/__init__.py | 10 | ||||
-rw-r--r-- | wcsutil/instruments.py | 16 |
2 files changed, 17 insertions, 9 deletions
diff --git a/wcsutil/__init__.py b/wcsutil/__init__.py index 40a3649..c43f86e 100644 --- a/wcsutil/__init__.py +++ b/wcsutil/__init__.py @@ -117,7 +117,15 @@ class HSTWCS(WCS): inst_kl = instruments.__dict__[inst_kl] insobj = inst_kl(prim_hdr, ext_hdr) for key in self.inst_kw: - self.__setattr__(key, insobj.__getattribute__(key)) + try: + self.__setattr__(key, insobj.__getattribute__(key)) + except AttributeError: + # Some of the instrument's attributes are recorded in the primary header and + # were already set, (e.g. 'DETECTOR'), the code below is a check for that case. + if not self.__getattribute__(key): + print '%s object has no attribute %s' % (insobj.__class__.__name__, key) + else: + raise else: raise KeyError, "Unsupported instrument - %s" %self.instrument diff --git a/wcsutil/instruments.py b/wcsutil/instruments.py index 092597c..d0ace1c 100644 --- a/wcsutil/instruments.py +++ b/wcsutil/instruments.py @@ -29,7 +29,7 @@ class InstrWCS(object): self.set_binned() self.set_chip() self.set_parity() - self.set_extver() + self.set_detector() def set_filter1(self): try: @@ -79,14 +79,13 @@ class InstrWCS(object): except: self.chip = 1 - def set_extver(self): - try: - self.extver = self.exthdr.get('EXTVER', 1) - except: - self.extver = 1 - def set_parity(self): self.parity = [[1.0,0.0],[0.0,-1.0]] + + def set_detector(self): + # each instrument has a different kw for detector and it can be + # in a different header, so this is to be handled by the instrument classes + pass class ACSWCS(InstrWCS): """ @@ -146,4 +145,5 @@ class WFPC2WCS(InstrWCS): def set_parity(self): self.parity = [[-1.0,0.],[0.,1.0]] - + def set_detector(self): + self.detector = self.exthdr.get('DETECTOR', None) |