summaryrefslogtreecommitdiff
path: root/wcsutil/__init__.py
diff options
context:
space:
mode:
authordencheva <dencheva@stsci.edu>2008-12-03 09:19:48 -0500
committerdencheva <dencheva@stsci.edu>2008-12-03 09:19:48 -0500
commit4e8d8be8719226a0ae7467d8010a57ee0c52ba50 (patch)
treefbea4eef6657111341fdeaa507d4bfd68747362a /wcsutil/__init__.py
parentbc142ccc1365b9d2b782bb49660215e3268b0d0b (diff)
downloadstwcs_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
Diffstat (limited to 'wcsutil/__init__.py')
-rw-r--r--wcsutil/__init__.py37
1 files changed, 28 insertions, 9 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'])