23 __all__ = [
"approximateWcs"]
30 from lsst.meas.base
import SingleFrameMeasurementTask
36 """A fake unit test case class that will enable us to call 37 assertWcsAlmostEqualOverBBox from the method approximateWcs""" 40 raise UserWarning(
"WCS fitting failed " + msgStr)
44 skyTolerance=0.001*lsst.geom.arcseconds, pixelTolerance=0.02, useTanWcs=False):
45 """Approximate an existing WCS as a TAN-SIP WCS 47 The fit is performed by evaluating the WCS at a uniform grid of points within a bounding box. 49 @param[in] wcs wcs to approximate 50 @param[in] bbox the region over which the WCS will be fit 51 @param[in] order order of SIP fit 52 @param[in] nx number of grid points along x 53 @param[in] ny number of grid points along y 54 @param[in] iterations number of times to iterate over fitting 55 @param[in] skyTolerance maximum allowed difference in world coordinates between 56 input wcs and approximate wcs (default is 0.001 arcsec) 57 @param[in] pixelTolerance maximum allowed difference in pixel coordinates between 58 input wcs and approximate wcs (default is 0.02 pixels) 59 @param[in] useTanWcs send a TAN version of wcs to the fitter? It is documented to require that, 60 but I don't think the fitter actually cares 61 @return the fit TAN-SIP WCS 64 crpix = wcs.getPixelOrigin()
65 crval = wcs.getSkyOrigin()
66 cdMatrix = wcs.getCdMatrix(crpix)
67 tanWcs = afwGeom.makeSkyWcs(crpix=crpix, crval=crval, cdMatrix=cdMatrix)
72 refSchema = afwTable.SimpleTable.makeMinimalSchema()
76 sourceSchema = afwTable.SourceTable.makeMinimalSchema()
77 SingleFrameMeasurementTask(schema=sourceSchema)
85 for x
in np.linspace(bboxd.getMinX(), bboxd.getMaxX(), nx):
86 for y
in np.linspace(bboxd.getMinY(), bboxd.getMaxY(), ny):
88 skyCoord = wcs.pixelToSky(pixelPos)
90 refObj = refCat.addNew()
91 refObj.set(refCoordKey, skyCoord)
93 source = sourceCat.addNew()
94 source.set(sourceCentroidKey, pixelPos)
99 for indx
in range(iterations):
101 tanWcs = sipObject.getNewWcs()
102 fitWcs = sipObject.getNewWcs()
105 assertWcsAlmostEqualOverBBox(mockTest, wcs, fitWcs, bbox, maxDiffSky=skyTolerance,
106 maxDiffPix=pixelTolerance)
def approximateWcs(wcs, bbox, order=3, nx=20, ny=20, iterations=3, skyTolerance=0.001 *lsst.geom.arcseconds, pixelTolerance=0.02, useTanWcs=False)
CreateWcsWithSip< MatchT > makeCreateWcsWithSip(std::vector< MatchT > const &matches, afw::geom::SkyWcs const &linearWcs, int const order, geom::Box2I const &bbox=geom::Box2I(), int const ngrid=0)
Factory function for CreateWcsWithSip.