def test_tan_sip_wcs(self): """ Test that getTanSipWcs works by fitting a TAN WCS and a TAN-SIP WCS to the a detector with distortions and verifying that the TAN-SIP WCS better approximates the truth. """ arcsec_per_radian = 180.0*3600.0/np.pi tanWcs = self.wcs.getTanWcs() tanSipWcs = self.wcs.getTanSipWcs() tanWcsRa = [] tanWcsDec = [] tanSipWcsRa = [] tanSipWcsDec = [] xPixList = [] yPixList = [] for xx in np.arange(0.0, 4001.0, 1000.0): for yy in np.arange(0.0, 4001.0, 1000.0): xPixList.append(xx) yPixList.append(yy) pt = afwGeom.Point2D(xx ,yy) skyPt = tanWcs.pixelToSky(pt).getPosition() tanWcsRa.append(skyPt.getX()) tanWcsDec.append(skyPt.getY()) skyPt = tanSipWcs.pixelToSky(pt).getPosition() tanSipWcsRa.append(skyPt.getX()) tanSipWcsDec.append(skyPt.getY()) tanWcsRa = np.radians(np.array(tanWcsRa)) tanWcsDec = np.radians(np.array(tanWcsDec)) tanSipWcsRa = np.radians(np.array(tanSipWcsRa)) tanSipWcsDec = np.radians(np.array(tanSipWcsDec)) xPixList = np.array(xPixList) yPixList = np.array(yPixList) raTest, decTest = \ self.wcs._camera.raDecFromPixelCoords(xPixList, yPixList, [self.wcs._chip_name]*len(xPixList)) for rrTest, ddTest, rrTan, ddTan, rrSip, ddSip in \ zip(raTest, decTest, tanWcsRa, tanWcsDec, tanSipWcsRa, tanSipWcsDec): pp = CelestialCoord(rrTest*galsim.radians, ddTest*galsim.radians) distTan = \ pp.distanceTo(CelestialCoord(rrTan*galsim.radians, ddTan*galsim.radians))/galsim.arcsec distSip = \ pp.distanceTo(CelestialCoord(rrSip*galsim.radians, ddSip*galsim.radians))/galsim.arcsec msg = 'error in TAN WCS %e arcsec; error in TAN-SIP WCS %e arcsec' % (distTan, distSip) self.assertLess(distSip, 0.001, msg=msg) self.assertGreater(distTan-distSip, 1.0e-10, msg=msg)
def test_tan_sip_wcs(self): """ Test that getTanSipWcs works by fitting a TAN WCS and a TAN-SIP WCS to the a detector with distortions and verifying that the TAN-SIP WCS better approximates the truth. """ arcsec_per_radian = 180.0*3600.0/np.pi tanWcs = self.wcs.getTanWcs() tanSipWcs = self.wcs.getTanSipWcs() tanWcsRa = [] tanWcsDec = [] tanSipWcsRa = [] tanSipWcsDec = [] xPixList = [] yPixList = [] for xx in np.arange(0.0, 4001.0, 1000.0): for yy in np.arange(0.0, 4001.0, 1000.0): xPixList.append(xx) yPixList.append(yy) pt = afwGeom.Point2D(xx ,yy) skyPt = tanWcs.pixelToSky(pt).getPosition() tanWcsRa.append(skyPt.getX()) tanWcsDec.append(skyPt.getY()) skyPt = tanSipWcs.pixelToSky(pt).getPosition() tanSipWcsRa.append(skyPt.getX()) tanSipWcsDec.append(skyPt.getY()) tanWcsRa = np.radians(np.array(tanWcsRa)) tanWcsDec = np.radians(np.array(tanWcsDec)) tanSipWcsRa = np.radians(np.array(tanSipWcsRa)) tanSipWcsDec = np.radians(np.array(tanSipWcsDec)) xPixList = np.array(xPixList) yPixList = np.array(yPixList) raTest, decTest = \ self.wcs._camera.raDecFromPixelCoords(xPixList, yPixList, [self.wcs._chip_name]*len(xPixList)) for rrTest, ddTest, rrTan, ddTan, rrSip, ddSip in \ zip(raTest, decTest, tanWcsRa, tanWcsDec, tanSipWcsRa, tanSipWcsDec): pp = CelestialCoord(rrTest*galsim.radians, ddTest*galsim.radians) distTan = \ pp.distanceTo(CelestialCoord(rrTan*galsim.radians, ddTan*galsim.radians))/galsim.arcsec distSip = \ pp.distanceTo(CelestialCoord(rrSip*galsim.radians, ddSip*galsim.radians))/galsim.arcsec msg = 'error in TAN WCS %e arcsec; error in TAN-SIP WCS %e arcsec' % (distTan, distSip) self.assertLess(distSip, 0.001, msg=msg) self.assertGreater(distTan-distSip, 1.0e-10, msg=msg)
def test_tan_wcs(self): """ Test method to return a Tan WCS by generating a bunch of pixel coordinates in the undistorted TAN-PIXELS coordinate system. Then, use sims_coordUtils to convert those pixel coordinates into RA and Dec. Compare these to the RA and Dec returned by the WCS. Demand agreement to witin 0.001 arcseconds. Note: if you use a bigger camera, it is possible to have disagreements of order a few milliarcseconds. """ start = time.clock() xPixList = [] yPixList = [] tanWcs = self.wcs.getTanWcs() wcsRa = [] wcsDec = [] for xx in np.arange(0.0, 4001.0, 1000.0): for yy in np.arange(0.0, 4001.0, 1000.0): xPixList.append(xx) yPixList.append(yy) pt = afwGeom.Point2D(xx ,yy) skyPt = tanWcs.pixelToSky(pt).getPosition() wcsRa.append(skyPt.getX()) wcsDec.append(skyPt.getY()) wcsRa = np.radians(np.array(wcsRa)) wcsDec = np.radians(np.array(wcsDec)) xPixList = np.array(xPixList) yPixList = np.array(yPixList) raTest, decTest = \ self.wcs._camera.raDecFromTanPixelCoords(xPixList, yPixList, [self.wcs._chip_name]*len(xPixList)) for rr1, dd1, rr2, dd2 in zip(raTest, decTest, wcsRa, wcsDec): pp = CelestialCoord(rr1*galsim.radians, dd1*galsim.radians) dist = \ pp.distanceTo(CelestialCoord(rr2*galsim.radians, dd2*galsim.radians))/galsim.arcsec msg = 'error in tanWcs was %e arcsec' % dist self.assertLess(dist, 0.001, msg=msg) print 'time to run %s = %e sec' % (funcname(), time.clock()-start)