diff options
author | hack <hack@stsci.edu> | 2011-10-25 17:25:35 -0400 |
---|---|---|
committer | hack <hack@stsci.edu> | 2011-10-25 17:25:35 -0400 |
commit | b5f4204747f7e4105049713b40d7bca0fae052e5 (patch) | |
tree | 8a2bd7713049a348ea3d955c646ccf1a7c4b7815 /lib/stwcs/updatewcs | |
parent | c68d6121a6847327df30ece3d90d8cfe0919367b (diff) | |
download | stwcs_hcf-b5f4204747f7e4105049713b40d7bca0fae052e5.tar.gz |
Merging changes from 'stwcs_hdrlet' branch (r18787 - r13909) into trunk. This version of STWCS (0.9.1) provides support for headerlets based on 'Headerlet Design' wiki document, and includes TEAL interfaces for all public headerlet functions. It also moves the TEAL interface for 'updatewcs' from 'astrodither' to this package. The TEAL interaces have been included as a new 'gui' sub-package in order to keep them separate from the remainder of the package's functionality.
git-svn-id: http://svn.stsci.edu/svn/ssb/stsci_python/stsci_python/trunk/stwcs@13910 fe389314-cf27-0410-b35b-8c050e845b92
Diffstat (limited to 'lib/stwcs/updatewcs')
-rw-r--r-- | lib/stwcs/updatewcs/__init__.py | 2 | ||||
-rw-r--r-- | lib/stwcs/updatewcs/makewcs.py | 13 | ||||
-rw-r--r-- | lib/stwcs/updatewcs/utils.py | 53 |
3 files changed, 55 insertions, 13 deletions
diff --git a/lib/stwcs/updatewcs/__init__.py b/lib/stwcs/updatewcs/__init__.py index 9ab8ade..179612d 100644 --- a/lib/stwcs/updatewcs/__init__.py +++ b/lib/stwcs/updatewcs/__init__.py @@ -100,6 +100,7 @@ def updatewcs(input, vacorr=True, tddcorr=True, npolcorr=True, d2imcorr=True, cleanWCS(f) makecorr(f, acorr) + return files def makecorr(fname, allowed_corr): @@ -359,4 +360,3 @@ def getCorrections(instrument): print "The following corrections will be performed for instrument %s\n" % instrument for c in acorr: print c,': ' , apply_corrections.cnames[c] - diff --git a/lib/stwcs/updatewcs/makewcs.py b/lib/stwcs/updatewcs/makewcs.py index e422a4a..c2e709d 100644 --- a/lib/stwcs/updatewcs/makewcs.py +++ b/lib/stwcs/updatewcs/makewcs.py @@ -1,6 +1,5 @@ from __future__ import division # confidence high -from stwcs import DEGTORAD, RADTODEG import numpy as np from math import sin, sqrt, pow, cos, asin, atan2,pi import utils @@ -149,7 +148,7 @@ class MakeWCS(object): ref_wcs.idcmodel.shift(offsetx,offsety) rfx, rfy = ref_wcs.idcmodel.cx, ref_wcs.idcmodel.cy - + ref_wcs.setPscale() offshift = offsh dec = ref_wcs.wcs.crval[1] @@ -244,10 +243,10 @@ def troll(roll, dec, v2, v3): Generic Conversion at STScI. """ # Convert all angles to radians - _roll = DEGTORAD(roll) - _dec = DEGTORAD(dec) - _v2 = DEGTORAD(v2 / 3600.) - _v3 = DEGTORAD(v3 / 3600.) + _roll = np.deg2rad(roll) + _dec = np.deg2rad(dec) + _v2 = np.deg2rad(v2 / 3600.) + _v3 = np.deg2rad(v3 / 3600.) # compute components sin_rho = sqrt((pow(sin(_v2),2)+pow(sin(_v3),2)) - (pow(sin(_v2),2)*pow(sin(_v3),2))) @@ -260,7 +259,7 @@ def troll(roll, dec, v2, v3): B = atan2( sin(A)*cos(_dec), (sin(_dec)*sin_rho - cos(_dec)*cos(rho)*cos(A))) # compute final value - troll = RADTODEG(pi - (gamma+B)) + troll = np.rad2deg(pi - (gamma+B)) return troll diff --git a/lib/stwcs/updatewcs/utils.py b/lib/stwcs/updatewcs/utils.py index b7fe7c4..b761efc 100644 --- a/lib/stwcs/updatewcs/utils.py +++ b/lib/stwcs/updatewcs/utils.py @@ -57,7 +57,7 @@ def extract_rootname(kwvalue): else: rootname = fname - return rootname + return rootname.strip() def construct_distname(fobj,wcsobj): """ @@ -73,15 +73,24 @@ def construct_distname(fobj,wcsobj): if idcname is None and wcsobj.sip is not None: idcname = 'UNKNOWN' - npolname = extract_rootname(fobj[0].header.get('NPOLFILE', "NONE")) + npolname = build_npolname(fobj) if npolname is None and wcsobj.cpdis1 is not None: npolname = 'UNKNOWN' - d2imname = extract_rootname(fobj[0].header.get('D2IMFILE', "NONE")) + d2imname = build_d2imname(fobj) if d2imname is None and wcsobj.det2im is not None: d2imname = 'UNKNOWN' - sipname = '%s_%s'%(fobj[0].header.get('rootname',""),idcname) + sipname = build_sipname(fobj) + + distname = build_distname(sipname,npolname,d2imname) + return {'DISTNAME':distname,'SIPNAME':sipname} + +def build_distname(sipname,npolname,d2imname): + """ + Core function to build DISTNAME keyword value without the HSTWCS input. + """ + distname = sipname.strip() if npolname != 'NONE' or d2imname != 'NONE': if d2imname != 'NONE': @@ -89,4 +98,38 @@ def construct_distname(fobj,wcsobj): else: distname+='-'+npolname.strip() - return {'DISTNAME':distname,'SIPNAME':sipname}
\ No newline at end of file + return distname + +def build_sipname(fobj): + try: + sipname = fobj[0].header["SIPNAME"] + except KeyError: + try: + sipname = fobj[0].header['rootname']+'_'+ \ + extract_rootname(fobj[0].header["IDCTAB"]) + except KeyError: + if 'A_ORDER' in fobj[1].header or 'B_ORDER' in fobj[1].header: + sipname = 'UNKNOWN' + else: + sipname = 'NOMODEL' + return sipname + +def build_npolname(fobj): + try: + npolfile = extract_rootname(fobj[0].header["NPOLFILE"]) + except KeyError: + if countExtn(f, 'WCSDVARR'): + npolfile = 'UNKNOWN' + else: + npolfile = 'NOMODEL' + return npolfile + +def build_d2imname(fobj): + try: + d2imfile = extract_rootname(fobj[0].header["D2IMFILE"]) + except KeyError: + if countExtn(f, 'D2IMARR'): + d2imfile = 'UNKNOWN' + else: + d2imfile = 'NOMODEL' + return d2imfile
\ No newline at end of file |