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 crCoord = wcs.getSkyOrigin()
64 crPix = wcs.getPixelOrigin()
65 cdMat = wcs.getCDMatrix()
66 tanWcs =
afwImage.makeWcs(crCoord, crPix, cdMat[0,0], cdMat[0,1], cdMat[1,0], cdMat[1,1])
71 refSchema = afwTable.SimpleTable.makeMinimalSchema()
75 sourceSchema = afwTable.SourceTable.makeMinimalSchema()
76 SingleFrameMeasurementTask(schema=sourceSchema)
84 for x
in numpy.linspace(bboxd.getMinX(), bboxd.getMaxX(), nx):
85 for y
in numpy.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()
105 maxDiffPix=pixelTolerance)
std::vector< ReferenceMatch > ReferenceMatchVector
CreateWcsWithSip< MatchT > makeCreateWcsWithSip(std::vector< MatchT > const &matches, afw::image::Wcs const &linearWcs, int const order, afw::geom::Box2I const &bbox=afw::geom::Box2I(), int const ngrid=0)
Factory function for CreateWcsWithSip.
Custom catalog class for record/table subclasses that are guaranteed to have an ID, and should generally be sorted by that ID.
Lightweight representation of a geometric match between two records.
Wcs::Ptr makeWcs(coord::Coord const &crval, geom::Point2D const &crpix, double CD11, double CD12, double CD21, double CD22)
Create a Wcs object from crval, crpix, CD, using CD elements (useful from python) ...
A floating-point coordinate rectangle geometry.
def assertWcsNearlyEqualOverBBox
Compare pixelToSky and skyToPixel for two WCS over a rectangular grid of pixel positions.
A FunctorKey used to get or set celestial coordiantes from a pair of Angle keys.