summaryrefslogtreecommitdiff
path: root/distortion/coeff_converter.py
diff options
context:
space:
mode:
authordencheva <dencheva@stsci.edu>2010-01-25 17:13:05 -0500
committerdencheva <dencheva@stsci.edu>2010-01-25 17:13:05 -0500
commit1c380263a895a6ce91ef24ee9c2c0445df7bbebb (patch)
tree75a3f18b0fd58d6ac5adfb1d3af7520967f3a67d /distortion/coeff_converter.py
parentadd5bab6ddb69e48bc6f95e2f0b38e60c4fb9fed (diff)
downloadstwcs_hcf-1c380263a895a6ce91ef24ee9c2c0445df7bbebb.tar.gz
- If idc table is not found and idc model cannot be restored from SIP, idcmodel is always set to None.
- Two cases are considered when output_wcs is created and idcmodel for the reference image is None: -- if idcmodel can be found, a RuntimeError will be raised and the user prompted to run 'updatewcs' or pass 'undistort=False' kw. -- if idcmodel cannot be found, the original WCS for the reference object will be returned and used as an output WCS. git-svn-id: http://svn.stsci.edu/svn/ssb/stsci_python/stsci_python/trunk/stwcs@8640 fe389314-cf27-0410-b35b-8c050e845b92
Diffstat (limited to 'distortion/coeff_converter.py')
-rw-r--r--distortion/coeff_converter.py32
1 files changed, 17 insertions, 15 deletions
diff --git a/distortion/coeff_converter.py b/distortion/coeff_converter.py
index 807bc3f..f2eb4ad 100644
--- a/distortion/coeff_converter.py
+++ b/distortion/coeff_converter.py
@@ -16,12 +16,11 @@ def sip2idc(wcs):
ocx11 = wcs.get('OCX11', None)
ocy10 = wcs.get('OCY10', None)
ocy11 = wcs.get('OCY11', None)
- order = hdr.get('A_ORDER', None)
- sipa, sipb = _read_sip_kw(header)
- if sipa == None or sipb == None:
- print 'SIP coefficients are not available.\n'
+ order = wcs.get('A_ORDER', None)
+ sipa, sipb = _read_sip_kw(wcs)
+ if None in [ocx10, ocx11, ocy10, ocy11, sipa, sipb]:
print 'Cannot convert SIP to IDC coefficients.\n'
- return
+ return None, None
elif isinstance(wcs,pywcs.WCS):
try:
ocx10 = wcs.ocx10
@@ -31,27 +30,28 @@ def sip2idc(wcs):
except AttributeError:
print 'First order IDCTAB coefficients are not available.\n'
print 'Cannot convert SIP to IDC coefficients.\n'
- return
+ return None, None
try:
sipa = wcs.sip.a
sipb = wcs.sip.b
except AttributeError:
- print 'SIP coefficients are not available.\n'
+ print 'SIP coefficients are not available.'
print 'Cannot convert SIP to IDC coefficients.\n'
- return
+ return None, None
+ try:
+ order = wcs.sip.a_order
+ except AttributeError:
+ print 'SIP model order unknown, exiting ...\n'
+ return None, None
+
else:
print 'Input to sip2idc must be a PyFITS header or a wcsutil.HSTWCS object\n'
return
- try:
- order = wcs.sip.a_order
- except AttributeError:
- print 'SIP model order unknown, exiting ...\n'
- return
-
+
if None in [ocx10, ocx11, ocy10, ocy11]:
print 'First order IDC coefficients not found, exiting ...\n'
- return
+ return
idc_coeff = np.array([[ocx11, ocx10], [ocy11, ocy10]])
cx = np.zeros((order+1,order+1), dtype=np.double)
cy = np.zeros((order+1,order+1), dtype=np.double)
@@ -102,6 +102,8 @@ def _read_sip_kw(header):
b = None
return a , b
+
+
"""
def idc2sip(wcsobj, idctab = None):
if isinstance(wcs,pywcs.WCS):