23__all__ = [
"approximateWcs"]
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
48 within a bounding box.
55 the region over which the WCS will be fit
59 number of grid points along x
61 number of grid points along y
63 number of times to iterate over fitting
65 maximum allowed difference
in world coordinates between
66 input wcs
and approximate wcs (default
is 0.001 arcsec)
67 pixelTolerance : `float`
68 maximum allowed difference
in pixel coordinates between
69 input wcs
and approximate wcs (default
is 0.02 pixels)
71 send a TAN version of wcs to the fitter? It
is documented to require that,
72 but I don
't think the fitter actually cares
80 crpix = wcs.getPixelOrigin()
81 crval = wcs.getSkyOrigin()
82 cdMatrix = wcs.getCdMatrix(crpix)
88 refSchema = afwTable.SimpleTable.makeMinimalSchema()
92 sourceSchema = afwTable.SourceTable.makeMinimalSchema()
101 for x
in np.linspace(bboxd.getMinX(), bboxd.getMaxX(), nx):
102 for y
in np.linspace(bboxd.getMinY(), bboxd.getMaxY(), ny):
104 skyCoord = wcs.pixelToSky(pixelPos)
106 refObj = refCat.addNew()
107 refObj.set(refCoordKey, skyCoord)
109 source = sourceCat.addNew()
110 source.set(sourceCentroidKey, pixelPos)
115 for indx
in range(iterations):
117 tanWcs = sipObject.getNewWcs()
118 fitWcs = sipObject.getNewWcs()
122 maxDiffPix=pixelTolerance)
A 2-dimensional celestial WCS that transform pixels to ICRS RA/Dec, using the LSST standard for pixel...
A FunctorKey used to get or set celestial coordinates from a pair of lsst::geom::Angle keys.
Custom catalog class for record/table subclasses that are guaranteed to have an ID,...
A class representing an angle.
A floating-point coordinate rectangle geometry.
An integer coordinate rectangle.
def assertWcsAlmostEqualOverBBox(testCase, wcs0, wcs1, bbox, maxDiffSky=0.01 *lsst.geom.arcseconds, maxDiffPix=0.01, nx=5, ny=5, msg="WCSs differ")
std::shared_ptr< SkyWcs > makeSkyWcs(daf::base::PropertySet &metadata, bool strip=false)
Construct a SkyWcs from FITS keywords.
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.
Lightweight representation of a geometric match between two records.