1 from builtins
import range
2 from builtins
import object
34 __all__ = [
"approximateWcs"]
38 """A fake unit test case class that will enable us to call
39 assertWcsNearlyEqualOverBBox from the method approximateWcs"""
42 raise UserWarning(
"WCS fitting failed " + msgStr)
46 skyTolerance=0.001*afwGeom.arcseconds, pixelTolerance=0.02, useTanWcs=
False):
47 """Approximate an existing WCS as a TAN-SIP WCS
49 The fit is performed by evaluating the WCS at a uniform grid of points within a bounding box.
51 @param[in] wcs wcs to approximate
52 @param[in] bbox the region over which the WCS will be fit
53 @param[in] order order of SIP fit
54 @param[in] nx number of grid points along x
55 @param[in] ny number of grid points along y
56 @param[in] iterations number of times to iterate over fitting
57 @param[in] skyTolerance maximum allowed difference in world coordinates between
58 input wcs and approximate wcs (default is 0.001 arcsec)
59 @param[in] pixelTolerance maximum allowed difference in pixel coordinates between
60 input wcs and approximate wcs (default is 0.02 pixels)
61 @param[in] useTanWcs send a TAN version of wcs to the fitter? It is documented to require that,
62 but I don't think the fitter actually cares
63 @return the fit TAN-SIP WCS
66 crCoord = wcs.getSkyOrigin()
67 crPix = wcs.getPixelOrigin()
68 cdMat = wcs.getCDMatrix()
69 tanWcs =
afwImage.makeWcs(crCoord, crPix, cdMat[0, 0], cdMat[0, 1], cdMat[1, 0], cdMat[1, 1])
74 refSchema = afwTable.SimpleTable.makeMinimalSchema()
78 sourceSchema = afwTable.SourceTable.makeMinimalSchema()
79 SingleFrameMeasurementTask(schema=sourceSchema)
87 for x
in np.linspace(bboxd.getMinX(), bboxd.getMaxX(), nx):
88 for y
in np.linspace(bboxd.getMinY(), bboxd.getMaxY(), ny):
90 skyCoord = wcs.pixelToSky(pixelPos)
92 refObj = refCat.addNew()
93 refObj.set(refCoordKey, skyCoord)
95 source = sourceCat.addNew()
96 source.set(sourceCentroidKey, pixelPos)
101 for indx
in range(iterations):
103 tanWcs = sipObject.getNewWcs()
104 fitWcs = sipObject.getNewWcs()
108 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.
boost::shared_ptr< Wcs > 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 coordinates from a pair of Angle keys.