From 7b04268af9bf0f2a7c29fcc53266fddec672793e Mon Sep 17 00:00:00 2001 From: dencheva Date: Mon, 28 Apr 2014 19:42:57 +0000 Subject: changes to use astropy instead of pyfits and pywcs git-svn-id: http://svn.stsci.edu/svn/ssb/stsci_python/stsci.sphere/trunk@31238 fe389314-cf27-0410-b35b-8c050e845b92 Former-commit-id: c1b6745fb638349430fb6b33079113dcb80c5a18 --- stsci/sphere/polygon.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'stsci/sphere/polygon.py') diff --git a/stsci/sphere/polygon.py b/stsci/sphere/polygon.py index e9ad379..1dc33cd 100644 --- a/stsci/sphere/polygon.py +++ b/stsci/sphere/polygon.py @@ -254,8 +254,10 @@ class SphericalPolygon(object): ------- polygon : `SphericalPolygon` object """ - import pywcs - import pyfits + #import pywcs + #import pyfits + from astropy import wcs as pywcs + from astropy.io import fits as pyfits if isinstance(fitspath, pyfits.Header): header = fitspath @@ -266,7 +268,7 @@ class SphericalPolygon(object): wcs = pywcs.WCS(fitspath) if crval is not None: wcs.wcs.crval = crval - xa, ya = [wcs.naxis1, wcs.naxis2] + xa, ya = [wcs._naxis1, wcs._naxis2] length = steps * 4 + 1 X = np.empty(length) @@ -285,13 +287,13 @@ class SphericalPolygon(object): Y[-1] = 1 # Use wcslib to convert to (ra, dec) - ra, dec = wcs.all_pix2sky(X, Y, 1) + ra, dec = wcs.all_pix2world(X, Y, 1) # Convert to Cartesian x, y, z = vector.radec_to_vector(ra, dec) # Calculate an inside point - ra, dec = wcs.all_pix2sky(xa / 2.0, ya / 2.0, 1) + ra, dec = wcs.all_pix2world(xa / 2.0, ya / 2.0, 1) xc, yc, zc = vector.radec_to_vector(ra, dec) return cls(np.dstack((x, y, z))[0], (xc[0], yc[0], zc[0])) -- cgit