summaryrefslogtreecommitdiff
path: root/lib/stwcs/wcsutil/hstwcs.py
diff options
context:
space:
mode:
authordencheva <dencheva@stsci.edu>2012-10-01 16:41:07 -0400
committerdencheva <dencheva@stsci.edu>2012-10-01 16:41:07 -0400
commit9a2e2abe1ca50840d9d95a3eae61f7161ee47651 (patch)
treed52f22ba215ec333512c015fd7d9227626d513ef /lib/stwcs/wcsutil/hstwcs.py
parente1f23c40bcf6b249171cb2e80c3c85d17effa0a1 (diff)
downloadstwcs_hcf-9a2e2abe1ca50840d9d95a3eae61f7161ee47651.tar.gz
Refactored headerlet code works with pywcs.WCS objects now. Also works iwth non-HST files
git-svn-id: http://svn.stsci.edu/svn/ssb/stsci_python/stsci_python/trunk/stwcs@19777 fe389314-cf27-0410-b35b-8c050e845b92
Diffstat (limited to 'lib/stwcs/wcsutil/hstwcs.py')
-rw-r--r--lib/stwcs/wcsutil/hstwcs.py30
1 files changed, 17 insertions, 13 deletions
diff --git a/lib/stwcs/wcsutil/hstwcs.py b/lib/stwcs/wcsutil/hstwcs.py
index 371de0f..cc9c28b 100644
--- a/lib/stwcs/wcsutil/hstwcs.py
+++ b/lib/stwcs/wcsutil/hstwcs.py
@@ -169,9 +169,10 @@ class HSTWCS(WCS):
cd21 = self.wcs.cd[1][0]
self.pscale = np.sqrt(np.power(cd11,2)+np.power(cd21,2)) * 3600.
except AttributeError:
- print "This file has a PC matrix. You may want to convert it \n \
- to a CD matrix, if reasonable, by running pc2.cd() method.\n \
- The plate scale can be set then by calling setPscale() method.\n"
+ if self.wcs.has_cd():
+ print "This file has a PC matrix. You may want to convert it \n \
+ to a CD matrix, if reasonable, by running pc2.cd() method.\n \
+ The plate scale can be set then by calling setPscale() method.\n"
self.pscale = None
def setOrient(self):
@@ -183,9 +184,10 @@ class HSTWCS(WCS):
cd22 = self.wcs.cd[1][1]
self.orientat = np.rad2deg(np.arctan2(cd12,cd22))
except AttributeError:
- print "This file has a PC matrix. You may want to convert it \n \
- to a CD matrix, if reasonable, by running pc2.cd() method.\n \
- The orientation can be set then by calling setOrient() method.\n"
+ if self.wcs.has_cd():
+ print "This file has a PC matrix. You may want to convert it \n \
+ to a CD matrix, if reasonable, by running pc2.cd() method.\n \
+ The orientation can be set then by calling setOrient() method.\n"
self.pscale = None
def updatePscale(self, scale):
@@ -307,7 +309,7 @@ class HSTWCS(WCS):
self.ltv1 = 0.
self.ltv2 = 0.
- def wcs2header(self, sip2hdr=False, idc2hdr=True):
+ def wcs2header(self, sip2hdr=False, idc2hdr=True, wcskey=None, relax=False):
"""
Create a pyfits.Header object from WCS keywords.
@@ -319,25 +321,28 @@ class HSTWCS(WCS):
sip2hdr: boolean
If True - include SIP coefficients
"""
- h = self.to_header()
+
+ h = self.to_header(wkey=wcskey, relax=relax)
+ if not wcskey:
+ wcskey = self.wcs.alt
if self.wcs.has_cd():
- h = altwcs.pc2cd(h, key=self.wcskey)
+ h = altwcs.pc2cd(h, alt=self.wcs.alt, key=wcskey)
if 'wcsname' not in h:
if self.idctab is not None:
wname = build_default_wcsname(self.idctab)
else:
wname = 'DEFAULT'
- h.update('wcsname',value=wname)
+ h.update('wcsname'+wcskey, value=wname)
if idc2hdr:
for card in self._idc2hdr():
- h.update(card.key,value=card.value,comment=card.comment)
+ h.update(card.key+wcskey, value=card.value, comment=card.comment)
try:
del h['RESTFRQ']
del h['RESTWAV']
except KeyError: pass
-
+
if sip2hdr and self.sip:
for card in self._sip2hdr('a'):
h.update(card.key,value=card.value,comment=card.comment)
@@ -361,7 +366,6 @@ class HSTWCS(WCS):
h.update(card.key,value=card.value,comment=card.comment)
return h
-
def _sip2hdr(self, k):
"""
Get a set of SIP coefficients in the form of an array