summaryrefslogtreecommitdiff
path: root/wcsutil
diff options
context:
space:
mode:
Diffstat (limited to 'wcsutil')
-rw-r--r--wcsutil/__init__.py17
-rw-r--r--wcsutil/instruments.py132
-rw-r--r--wcsutil/mappings.py9
3 files changed, 141 insertions, 17 deletions
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