LSSTApplications  10.0+286,10.0+36,10.0+46,10.0-2-g4f67435,10.1+152,10.1+37,11.0,11.0+1,11.0-1-g47edd16,11.0-1-g60db491,11.0-1-g7418c06,11.0-2-g04d2804,11.0-2-g68503cd,11.0-2-g818369d,11.0-2-gb8b8ce7
LSSTDataManagementBasePackage
Classes | Functions | Variables
lsst.meas.astrom.approximateWcs Namespace Reference

Classes

class  _MockTestCase
 

Functions

def approximateWcs
 

Variables

list __all__ = ["approximateWcs"]
 

Function Documentation

def lsst.meas.astrom.approximateWcs.approximateWcs (   wcs,
  bbox,
  order = 3,
  nx = 20,
  ny = 20,
  iterations = 3,
  skyTolerance = 0.001*afwGeom.arcseconds,
  pixelTolerance = 0.02,
  useTanWcs = False 
)
Approximate an existing WCS as a TAN-SIP WCS

The fit is performed by evaluating the WCS at a uniform grid of points within a bounding box.

@param[in] wcs  wcs to approximate
@param[in] bbox  the region over which the WCS will be fit
@param[in] order  order of SIP fit
@param[in] nx  number of grid points along x
@param[in] ny  number of grid points along y
@param[in] iterations number of times to iterate over fitting
@param[in] skyTolerance maximum allowed difference in world coordinates between
           input wcs and approximate wcs (default is 0.001 arcsec)
@param[in] pixelTolerance maximum allowed difference in pixel coordinates between
           input wcs and approximate wcs (default is 0.02 pixels)
@param[in] useTanWcs  send a TAN version of wcs to the fitter? It is documented to require that,
    but I don't think the fitter actually cares
@return the fit TAN-SIP WCS

Definition at line 42 of file approximateWcs.py.

42 
43  skyTolerance=0.001*afwGeom.arcseconds, pixelTolerance=0.02, useTanWcs=False):
44  """Approximate an existing WCS as a TAN-SIP WCS
45 
46  The fit is performed by evaluating the WCS at a uniform grid of points within a bounding box.
47 
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
61  """
62  if useTanWcs:
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])
67  else:
68  tanWcs = wcs
69 
70  # create a matchList consisting of a grid of points covering the bbox
71  refSchema = afwTable.SimpleTable.makeMinimalSchema()
72  refCoordKey = afwTable.CoordKey(refSchema["coord"])
73  refCat = afwTable.SimpleCatalog(refSchema)
74 
75  sourceSchema = afwTable.SourceTable.makeMinimalSchema()
76  SingleFrameMeasurementTask(schema=sourceSchema) # expand the schema
77  sourceCentroidKey = afwTable.Point2DKey(sourceSchema["slot_Centroid"])
78 
79  sourceCat = afwTable.SourceCatalog(sourceSchema)
80 
81  matchList = afwTable.ReferenceMatchVector()
82 
83  bboxd = afwGeom.Box2D(bbox)
84  for x in numpy.linspace(bboxd.getMinX(), bboxd.getMaxX(), nx):
85  for y in numpy.linspace(bboxd.getMinY(), bboxd.getMaxY(), ny):
86  pixelPos = afwGeom.Point2D(x, y)
87  skyCoord = wcs.pixelToSky(pixelPos)
88 
89  refObj = refCat.addNew()
90  refObj.set(refCoordKey, skyCoord)
91 
92  source = sourceCat.addNew()
93  source.set(sourceCentroidKey, pixelPos)
94 
95  matchList.append(afwTable.ReferenceMatch(refObj, source, 0.0))
96 
97  # The TAN-SIP fitter is fitting x and y separately, so we have to iterate to make it converge
98  for indx in range(iterations) :
99  sipObject = makeCreateWcsWithSip(matchList, tanWcs, order, bbox)
100  tanWcs = sipObject.getNewWcs()
101  fitWcs = sipObject.getNewWcs()
102 
103  mockTest = _MockTestCase()
104  assertWcsNearlyEqualOverBBox(mockTest, wcs, fitWcs, bbox, maxDiffSky=skyTolerance,
105  maxDiffPix=pixelTolerance)
106 
107  return fitWcs
std::vector< ReferenceMatch > ReferenceMatchVector
Definition: fwd.h:97
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.
Definition: fwd.h:55
Lightweight representation of a geometric match between two records.
Definition: fwd.h:90
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) ...
Definition: makeWcs.cc:141
A floating-point coordinate rectangle geometry.
Definition: Box.h:271
def assertWcsNearlyEqualOverBBox
Compare pixelToSky and skyToPixel for two WCS over a rectangular grid of pixel positions.
Definition: basicUtils.py:151
A FunctorKey used to get or set celestial coordiantes from a pair of Angle keys.
Definition: aggregates.h:119

Variable Documentation

list lsst.meas.astrom.approximateWcs.__all__ = ["approximateWcs"]

Definition at line 32 of file approximateWcs.py.