diff options
author | hack <hack@stsci.edu> | 2013-11-18 16:19:58 -0500 |
---|---|---|
committer | hack <hack@stsci.edu> | 2013-11-18 16:19:58 -0500 |
commit | 07ea21e51912020afa6d244ab30eafcdb192571a (patch) | |
tree | ac8d0a63e7cb28d72c053cb3d793ce59ea99a111 /lib/stwcs/wcsutil/hstwcs.py | |
parent | bd55a281889fd75227626180fa0ed56c8fcfb494 (diff) | |
download | stwcs_hcf-07ea21e51912020afa6d244ab30eafcdb192571a.tar.gz |
Updated API for stwcs.wcsutil.hstwcs.HSTWCS.all_sky2pix() to accept both 1-D arrays for Ra,Dec and a single 2-D array to be consistent with pywcs.WCS.all_pix2sky().
This resolves #1076.
git-svn-id: http://svn.stsci.edu/svn/ssb/stsci_python/stwcs/trunk@27470 fe389314-cf27-0410-b35b-8c050e845b92
Diffstat (limited to 'lib/stwcs/wcsutil/hstwcs.py')
-rw-r--r-- | lib/stwcs/wcsutil/hstwcs.py | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/lib/stwcs/wcsutil/hstwcs.py b/lib/stwcs/wcsutil/hstwcs.py index 4bee8bb..71a8530 100644 --- a/lib/stwcs/wcsutil/hstwcs.py +++ b/lib/stwcs/wcsutil/hstwcs.py @@ -401,13 +401,17 @@ class HSTWCS(WCS): def pc2cd(self): self.wcs.cd = self.wcs.pc.copy() - def all_sky2pix(self,ra,dec,origin): + def all_sky2pix(self,*args): """ Performs full inverse transformation using iterative solution on full forward transformation with complete distortion model. NOTES ----- + Inputs can either be (RA, Dec, origin) or (RADec, origin) where RA and Dec + are 1-D arrays/lists of coordinates and RADec is an array/list of pairs + of coordinates. + We now need to find the position we want by iterative improvement of an initial guess - the centre of the chip @@ -421,6 +425,30 @@ class HSTWCS(WCS): """ from stwcs.distortion import utils + if len(args) == 2: + xy, origin = args + try: + xy = np.asarray(xy) + ra = xy[:,0] + dec = xy[:,1] + origin = int(origin) + except: + raise TypeError( + "When providing two arguments, they must be (RADec, origin)") + elif len(args) == 3: + ra, dec, origin = args + try: + ra = np.asarray(ra) + dec = np.asarray(dec) + origin = int(origin) + except: + raise TypeError( + "When providing three arguments, they must be (RA, Dec, origin)") + if ra.size != dec.size: + raise ValueError("RA and Dec arrays are not the same size") + else: + raise TypeError("Expected 2 or 3 arguments, %d given" % len(args)) + # Define some output arrays xout = np.zeros(len(ra),dtype=np.float64) yout = np.zeros(len(ra),dtype=np.float64) |