diff options
author | dencheva <dencheva@stsci.edu> | 2009-03-26 11:26:59 -0400 |
---|---|---|
committer | dencheva <dencheva@stsci.edu> | 2009-03-26 11:26:59 -0400 |
commit | faf6b5f51af44a794f743a2e2b5de3f176023185 (patch) | |
tree | 87cb7e4db10e17062a5af526c2896e950550a54a | |
parent | 39238c106e18b47b5f6f9be3352a01743342f59a (diff) | |
download | stwcs_hcf-faf6b5f51af44a794f743a2e2b5de3f176023185.tar.gz |
Changed imports of numpy (as np).
Added d2imcorr parameter to top level updatewcs function.
git-svn-id: http://svn.stsci.edu/svn/ssb/stsci_python/development/trunk/updatewcs@7803 fe389314-cf27-0410-b35b-8c050e845b92
-rw-r--r-- | hstwcs/__init__.py | 11 | ||||
-rw-r--r-- | hstwcs/det2im.py | 3 | ||||
-rw-r--r-- | hstwcs/dgeo.py | 9 | ||||
-rw-r--r-- | hstwcs/makewcs.py | 30 |
4 files changed, 24 insertions, 29 deletions
diff --git a/hstwcs/__init__.py b/hstwcs/__init__.py index a843888..7de38fe 100644 --- a/hstwcs/__init__.py +++ b/hstwcs/__init__.py @@ -7,7 +7,6 @@ from updatewcs.wcsutil import HSTWCS from updatewcs import utils import corrections, makewcs import dgeo, det2im -import time from pytools import parseinput, fileutil import apply_corrections @@ -17,7 +16,7 @@ __docformat__ = 'restructuredtext' __version__ = '0.3' -def updatewcs(input, vacorr=True, tddcorr=True, dgeocorr=True, checkfiles=True): +def updatewcs(input, vacorr=True, tddcorr=True, dgeocorr=True, checkfiles=True, d2imcorr=True): """ Purpose ======= @@ -33,7 +32,6 @@ def updatewcs(input, vacorr=True, tddcorr=True, dgeocorr=True, checkfiles=True): `pytools` `pyfits` `pywcs` - `numpy` :Parameters: `input`: a python list of file names or a string (wild card characters allowed) @@ -47,15 +45,16 @@ def updatewcs(input, vacorr=True, tddcorr=True, dgeocorr=True, checkfiles=True): geis and waiver fits files will be converted to MEF format. Default value is True for standalone mode. """ - files = parseinput.parseinput(input)[0] if checkfiles: files = checkFiles(files) if not files: print 'No valid input, quitting ...\n' - return + return for f in files: - acorr = apply_corrections.setCorrections(f, vacorr=vacorr, tddcorr=tddcorr,dgeocorr=dgeocorr) + acorr = apply_corrections.setCorrections(f, vacorr=vacorr, \ + tddcorr=tddcorr,dgeocorr=dgeocorr, d2imcorr=d2imcorr) + #restore the original WCS keywords utils.restoreWCS(f) makecorr(f, acorr) diff --git a/hstwcs/det2im.py b/hstwcs/det2im.py index 0835e98..7ec9fc2 100644 --- a/hstwcs/det2im.py +++ b/hstwcs/det2im.py @@ -1,8 +1,5 @@ import pyfits from pytools import fileutil -#from hstwcs.mappings import dgeo_vals -import numpy - class DET2IMCorr(object): def updateWCS(cls, fobj): diff --git a/hstwcs/dgeo.py b/hstwcs/dgeo.py index d6313d7..00178d9 100644 --- a/hstwcs/dgeo.py +++ b/hstwcs/dgeo.py @@ -1,7 +1,6 @@ import pyfits from pytools import fileutil -#from hstwcs.mappings import dgeo_vals -import numpy +import numpy as np class DGEOCorr(object): """ @@ -148,8 +147,8 @@ class DGEOCorr(object): """ coeffs = cls.getCoeffs(header) idcscale = header['IDCSCALE'] - sclcoeffs = numpy.linalg.inv(coeffs/idcscale) - ndx, ndy = numpy.dot(sclcoeffs, [dx.ravel(), dy.ravel()]) + sclcoeffs = np.linalg.inv(coeffs/idcscale) + ndx, ndy = np.dot(sclcoeffs, [dx.ravel(), dy.ravel()]) ndx.shape = dx.shape ndy.shape=dy.shape return ndx, ndy @@ -168,7 +167,7 @@ class DGEOCorr(object): print 'First order IDCTAB coefficients are not available.\n' print 'Cannot convert SIP to IDC coefficients.\n' return None - return numpy.array([[ocx11, ocx10], [ocy11,ocy10]], dtype=numpy.float32) + return np.array([[ocx11, ocx10], [ocy11,ocy10]], dtype=np.float32) getCoeffs = classmethod(getCoeffs) diff --git a/hstwcs/makewcs.py b/hstwcs/makewcs.py index 014df07..49ed824 100644 --- a/hstwcs/makewcs.py +++ b/hstwcs/makewcs.py @@ -1,5 +1,5 @@ from updatewcs import DEGTORAD, RADTODEG -import numpy +import numpy as np from math import sin, sqrt, pow, cos, asin, atan2,pi from updatewcs import utils from pytools import fileutil @@ -89,16 +89,16 @@ class MakeWCS(object): dX=(off*sin(theta)) + offshiftx dY=(off*cos(theta)) + offshifty - px = numpy.array([[dX,dY]]) + px = np.array([[dX,dY]]) newcrval = ref_wcs.wcs.p2s(px, 1)['world'][0] - newcrpix = numpy.array([ext_wcs.idcmodel.refpix['XREF'] + ltvoffx, + newcrpix = np.array([ext_wcs.idcmodel.refpix['XREF'] + ltvoffx, ext_wcs.idcmodel.refpix['YREF'] + ltvoffy]) ext_wcs.wcs.crval = newcrval ext_wcs.wcs.crpix = newcrpix ext_wcs.wcs.set() # Create a small vector, in reference image pixel scale - delmat = numpy.array([[fx[1,1], fy[1,1]], \ + delmat = np.array([[fx[1,1], fy[1,1]], \ [fx[1,0], fy[1,0]]]) / R_scale/3600. # Account for subarray offset @@ -110,7 +110,7 @@ class MakeWCS(object): rrmat = fileutil.buildRotMatrix(dtheta) # Rotate the vectors - dxy = numpy.dot(delmat, rrmat) + dxy = np.dot(delmat, rrmat) wc = ref_wcs.wcs.p2s((px + dxy), 1)['world'] # Calculate the new CDs and convert to degrees @@ -118,7 +118,7 @@ class MakeWCS(object): cd12 = utils.diff_angles(wc[1,0],newcrval[0])*cos(newcrval[1]*pi/180.0) cd21 = utils.diff_angles(wc[0,1],newcrval[1]) cd22 = utils.diff_angles(wc[1,1],newcrval[1]) - cd = numpy.array([[cd11, cd12], [cd21, cd22]]) + cd = np.array([[cd11, cd12], [cd21, cd22]]) ext_wcs.wcs.cd = cd ext_wcs.wcs.set() @@ -135,7 +135,7 @@ class MakeWCS(object): rv23 = [ref_wcs.idcmodel.refpix['V2REF'] + (rv23_corr_tdd[0,0] *tddscale), ref_wcs.idcmodel.refpix['V3REF'] - (rv23_corr_tdd[1,0] * tddscale)] # Get an approximate reference position on the sky - rref = numpy.array([[ref_wcs.idcmodel.refpix['XREF']+ltvoffx , + rref = np.array([[ref_wcs.idcmodel.refpix['XREF']+ltvoffx , ref_wcs.idcmodel.refpix['YREF']+ltvoffy]]) crval = ref_wcs.wcs.p2s(rref, 1)['world'][0] @@ -151,7 +151,7 @@ class MakeWCS(object): # Set values for the rest of the reference WCS ref_wcs.wcs.crval = crval - ref_wcs.wcs.crpix = numpy.array([0.0,0.0])+offsh + ref_wcs.wcs.crpix = np.array([0.0,0.0])+offsh parity = ref_wcs.parity R_scale = ref_wcs.idcmodel.refpix['PSCALE']/3600.0 cd11 = parity[0][0] * cos(pv*pi/180.0)*R_scale @@ -159,7 +159,7 @@ class MakeWCS(object): cd21 = parity[1][1] * sin(pv*pi/180.0)*R_scale cd22 = parity[1][1] * cos(pv*pi/180.0)*R_scale - rcd = numpy.array([[cd11, cd12], [cd21, cd22]]) + rcd = np.array([[cd11, cd12], [cd21, cd22]]) ref_wcs.wcs.cd = rcd ref_wcs.wcs.set() @@ -170,12 +170,12 @@ class MakeWCS(object): alpha = hwcs.idcmodel.refpix['TDDALPHA'] beta = hwcs.idcmodel.refpix['TDDBETA'] except KeyError: - return numpy.array([[0., 0.],[0.,0.]]) + return np.array([[0., 0.],[0.,0.]]) - tdd = numpy.array([[beta, alpha], [alpha, -beta]]) + tdd = np.array([[beta, alpha], [alpha, -beta]]) mrotp = fileutil.buildRotMatrix(2.234529)/2048. - xy0 = numpy.array([[cls.tdd_xyref[hwcs.chip][0]-2048.], [cls.tdd_xyref[hwcs.chip][1]-2048.]]) - v23_corr = numpy.dot(mrotp,numpy.dot(tdd,xy0)) * 0.05 + xy0 = np.array([[cls.tdd_xyref[hwcs.chip][0]-2048.], [cls.tdd_xyref[hwcs.chip][1]-2048.]]) + v23_corr = np.dot(mrotp,np.dot(tdd,xy0)) * 0.05 return v23_corr @@ -201,8 +201,8 @@ class MakeWCS(object): offshiftx = 0. offshifty = 0. - ltvoff = numpy.array([ltvoffx, ltvoffy]) - offshift = numpy.array([offshiftx, offshifty]) + ltvoff = np.array([ltvoffx, ltvoffy]) + offshift = np.array([offshiftx, offshifty]) return ltvoff, offshift getOffsets = classmethod(getOffsets) |