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