lsst.afw  14.0-40-g0271be365
testUtils.py
Go to the documentation of this file.
1 #
2 # LSST Data Management System
3 # Copyright 2016 LSST Corporation.
4 #
5 # This product includes software developed by the
6 # LSST Project (http://www.lsst.org/).
7 #
8 # This program is free software: you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation, either version 3 of the License, or
11 # (at your option) any later version.
12 #
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
17 #
18 # You should have received a copy of the LSST License Statement and
19 # the GNU General Public License along with this program. If not,
20 # see <http://www.lsstcorp.org/LegalNotices/>.
21 #
22 from __future__ import absolute_import, division, print_function
23 
24 __all__ = ["BoxGrid", "makeFitsHeaderFromMetadata", "makeSipIwcToPixel", "makeSipPixelToIwc"]
25 
26 from builtins import range
27 from builtins import object
28 
29 import itertools
30 import math
31 import os
32 import pickle
33 
34 import astshim as ast
35 import numpy as np
36 from numpy.testing import assert_allclose, assert_array_equal
37 from astshim.test import makeForwardPolyMap, makeTwoWayPolyMap
38 import lsst.afw.coord # required to use IcrsCoordEndpoint
39 from lsst.afw.geom.wcsUtils import getCdMatrixFromMetadata
40 
41 from .box import Box2I, Box2D
42 import lsst.afw.geom as afwGeom
43 from lsst.pex.exceptions import InvalidParameterError
44 import lsst.utils
45 import lsst.utils.tests
46 
47 
48 class BoxGrid(object):
49  """!Divide a box into nx by ny sub-boxes that tile the region
50  """
51 
52  def __init__(self, box, numColRow):
53  """!Construct a BoxGrid
54 
55  The sub-boxes will be of the same type as `box` and will exactly tile `box`;
56  they will also all be the same size, to the extent possible (some variation
57  is inevitable for integer boxes that cannot be evenly divided.
58 
59  @param[in] box box (an lsst.afw.geom.Box2I or Box2D);
60  the boxes in the grid will be of the same type
61  @param[in] numColRow number of columns and rows (a pair of ints)
62  """
63  if len(numColRow) != 2:
64  raise RuntimeError(
65  "numColRow=%r; must be a sequence of two integers" % (numColRow,))
66  self._numColRow = tuple(int(val) for val in numColRow)
67 
68  if isinstance(box, Box2I):
69  stopDelta = 1
70  elif isinstance(box, Box2D):
71  stopDelta = 0
72  else:
73  raise RuntimeError("Unknown class %s of box %s" % (type(box), box))
74  self.boxClass = type(box)
75  self.stopDelta = stopDelta
76 
77  minPoint = box.getMin()
78  self.pointClass = type(minPoint)
79  dtype = np.array(minPoint).dtype
80 
81  self._divList = [np.linspace(start=box.getMin()[i],
82  stop=box.getMax()[i] + self.stopDelta,
83  num=self._numColRow[i] + 1,
84  endpoint=True,
85  dtype=dtype) for i in range(2)]
86 
87  @property
88  def numColRow(self):
89  return self._numColRow
90 
91  def __getitem__(self, indXY):
92  """!Return the box at the specified x,y index (a pair of ints)
93  """
94  beg = self.pointClass(*[self._divList[i][indXY[i]] for i in range(2)])
95  end = self.pointClass(
96  *[self._divList[i][indXY[i] + 1] - self.stopDelta for i in range(2)])
97  return self.boxClass(beg, end)
98 
99  def __len__(self):
100  return self.shape[0]*self.shape[1]
101 
102  def __iter__(self):
103  """!Return an iterator over all boxes, where column varies most quickly
104  """
105  for row in range(self.numColRow[1]):
106  for col in range(self.numColRow[0]):
107  yield self[col, row]
108 
109 
110 class FrameSetInfo(object):
111  """Information about a FrameSet
112 
113  Attributes
114  ----------
115  baseInd : `int`
116  Index of base frame
117  currInd : `int`
118  Index of current frame
119  isBaseSkyFrame : `bool`
120  Is the base frame an `ast.SkyFrame`?
121  isCurrSkyFrame : `bool`
122  Is the current frame an `ast.SkyFrame`?
123  """
124  def __init__(self, frameSet):
125  """Construct a FrameSetInfo
126 
127  Parameters
128  ----------
129  frameSet : `ast.FrameSet`
130  The FrameSet about which you want information
131  """
132  self.baseInd = frameSet.base
133  self.currInd = frameSet.current
134  self.isBaseSkyFrame = frameSet.getFrame(self.baseInd).className == "SkyFrame"
135  self.isCurrSkyFrame = frameSet.getFrame(self.currInd).className == "SkyFrame"
136 
137 
139  """Make a FITS header string from metadata
140  """
141  strList = []
142  for name in metadata.names(False):
143  value = metadata.get(name)
144  if len(name) > 8:
145  raise RuntimeError("Name %r too long" % (name,))
146  if isinstance(value, float):
147  # keep astropy.wcs from warning about invalid format for floats
148  nameValStr = "%-8s= %0.25f" % (name, value)
149  else:
150  nameValStr = "%-8s= %r" % (name, value)
151  strList.append("%-80s" % (nameValStr,))
152  return "".join(strList)
153 
154 
155 def makeSipPolyMapCoeffs(metadata, name):
156  """Return a list of ast.PolyMap coefficients for the specified SIP matrix
157 
158  Include a term for out = in
159 
160  This is an internal function for use by makeSipIwcToPixel and makeSipPixelToIwc
161  """
162  outAxisDict = dict(A=1, B=2, AP=1, BP=2)
163  outAxis = outAxisDict.get(name)
164  if outAxis is None:
165  raise RuntimeError("%s not a supported SIP name" % (name,))
166  width = metadata.getAsInt("%s_ORDER" % (name,)) + 1
167  found = False
168  # start with a term for out = in
169  coeffs = []
170  if outAxis == 1:
171  coeffs.append([1.0, outAxis, 1, 0])
172  else:
173  coeffs.append([1.0, outAxis, 0, 1])
174  # add SIP distortion terms
175  for xPower in range(width):
176  for yPower in range(width):
177  coeffName = "%s_%s_%s" % (name, xPower, yPower)
178  if not metadata.exists(coeffName):
179  continue
180  found = True
181  coeff = metadata.getAsDouble(coeffName)
182  coeffs.append([coeff, outAxis, xPower, yPower])
183  if not found:
184  raise RuntimeError("No %s coefficients found" % (name,))
185  return coeffs
186 
187 
188 def makeSipIwcToPixel(metadata):
189  """Make an iwcToPixel transform witH SIP distortion from FITS-WCS metadata
190 
191  pixelPos = crpix + uv + sipMatrix(uv)
192  where uv = inverseCdMatrix(iwcPos)
193 
194  The transform has no inverse
195  """
196  crpix = (metadata.get("CRPIX1") - 1, metadata.get("CRPIX2") - 1)
197  pixelRelativeToAbsoluteMap = ast.ShiftMap(crpix)
198  cdMatrix = getCdMatrixFromMetadata(metadata)
199  cdMatrixMap = ast.MatrixMap(cdMatrix.copy())
200  coeffList = makeSipPolyMapCoeffs(metadata, "AP") + makeSipPolyMapCoeffs(metadata, "BP")
201  coeffArr = np.array(coeffList, dtype=float)
202  sipPolyMap = ast.PolyMap(coeffArr, 2, "IterInverse=0")
203 
204  iwcToPixelMap = cdMatrixMap.getInverse().then(sipPolyMap).then(pixelRelativeToAbsoluteMap)
205  return afwGeom.TransformPoint2ToPoint2(iwcToPixelMap)
206 
207 
208 def makeSipPixelToIwc(metadata):
209  """Make a pixelToIwc transform with SIP distortion from FITS-WCS metadata
210 
211  iwcPos = cdMatrix[dxy + sipMatrix(dxy)]
212  where dxy = pixelPos - crpix
213 
214  The transform has no inverse
215  """
216  crpix = (metadata.get("CRPIX1") - 1, metadata.get("CRPIX2") - 1)
217  pixelAbsoluteToRelativeMap = ast.ShiftMap(crpix).getInverse()
218  cdMatrix = getCdMatrixFromMetadata(metadata)
219  cdMatrixMap = ast.MatrixMap(cdMatrix.copy())
220  coeffList = makeSipPolyMapCoeffs(metadata, "A") + makeSipPolyMapCoeffs(metadata, "B")
221  coeffArr = np.array(coeffList, dtype=float)
222  sipPolyMap = ast.PolyMap(coeffArr, 2, "IterInverse=0")
223  pixelToIwcMap = pixelAbsoluteToRelativeMap.then(sipPolyMap).then(cdMatrixMap)
224  return afwGeom.TransformPoint2ToPoint2(pixelToIwcMap)
225 
226 
227 class PermutedFrameSet(object):
228  """A FrameSet with base or current frame possibly permuted, with associated
229  information
230 
231  Only two-axis frames will be permuted.
232 
233  Attributes
234  ----------
235  frameSet : `ast.FrameSet`
236  The FrameSet that may be permuted. A local copy is made.
237  isBaseSkyFrame : `bool`
238  Is the base frame an `ast.SkyFrame`?
239  isCurrSkyFrame : `bool`
240  Is the current frame an `ast.SkyFrame`?
241  isBasePermuted : `bool`
242  Are the base frame axes permuted?
243  isCurrPermuted : `bool`
244  Are the current frame axes permuted?
245  """
246  def __init__(self, frameSet, permuteBase, permuteCurr):
247  """Construct a PermutedFrameSet
248 
249  Make a copy of a FrameSet and permute the base and/or current frames if
250  requested
251 
252  Parameters
253  ----------
254  frameSet : `ast.FrameSet`
255  The FrameSet you wish to permute. A deep copy is made.
256  permuteBase : `bool`
257  Permute the base frame's axes?
258  permuteCurr : `bool`
259  Permute the current frame's axes?
260 
261  Raises
262  ------
263  `RuntimeError`
264  If you try to permute a frame that does not have 2 axes
265  """
266  self.frameSet = frameSet.copy()
267  fsInfo = FrameSetInfo(self.frameSet)
268  self.isBaseSkyFrame = fsInfo.isBaseSkyFrame
269  self.isCurrSkyFrame = fsInfo.isCurrSkyFrame
270  if permuteBase:
271  baseNAxes = self.frameSet.getFrame(fsInfo.baseInd).nAxes
272  if baseNAxes != 2:
273  raise RuntimeError("Base frame has {} axes; 2 required to permute".format(baseNAxes))
274  self.frameSet.current = fsInfo.baseInd
275  self.frameSet.permAxes([2, 1])
276  self.frameSet.current = fsInfo.currInd
277  if permuteCurr:
278  currNAxes = self.frameSet.getFrame(fsInfo.currInd).nAxes
279  if currNAxes != 2:
280  raise RuntimeError("Current frame has {} axes; 2 required to permute".format(currNAxes))
281  assert self.frameSet.getFrame(fsInfo.currInd).nAxes == 2
282  self.frameSet.permAxes([2, 1])
283  self.isBasePermuted = permuteBase
284  self.isCurrPermuted = permuteCurr
285 
286 
288  """Base class for unit tests of Transform<X>To<Y>
289 
290  Subclasses must call `TransformTestBaseClass.setUp(self)`
291  if they provide their own version.
292 
293  If a package other than afw uses this class then it must
294  override the `getTestDir` method to avoid writing into
295  afw's test directory.
296  """
297 
298  def getTestDir(self):
299  """Return a directory where temporary test files can be written
300 
301  The default implementation returns the test directory of the `afw`
302  package.
303 
304  If this class is used by a test in a package other than `afw`
305  then the subclass must override this method.
306  """
307  return os.path.join(lsst.utils.getPackageDir("afw"), "tests")
308 
309  def setUp(self):
310  """Set up a test
311 
312  Subclasses should call this method if they override setUp.
313  """
314  # tell unittest to use the msg argument of asserts as a supplement
315  # to the error message, rather than as the whole error message
316  self.longMessage = True
317 
318  # list of endpoint class name prefixes; the full name is prefix + "Endpoint"
319  self.endpointPrefixes = ("Generic", "Point2", "IcrsCoord")
320 
321  # GoodNAxes is dict of endpoint class name prefix:
322  # tuple containing 0 or more valid numbers of axes
323  self.goodNAxes = {
324  "Generic": (1, 2, 3, 4), # all numbers of axes are valid for GenericEndpoint
325  "Point2": (2,),
326  "IcrsCoord": (2,),
327  }
328 
329  # BadAxes is dict of endpoint class name prefix:
330  # tuple containing 0 or more invalid numbers of axes
331  self.badNAxes = {
332  "Generic": (), # all numbers of axes are valid for GenericEndpoint
333  "Point2": (1, 3, 4),
334  "IcrsCoord": (1, 3, 4),
335  }
336 
337  # Dict of frame index: identity name for frames created by makeFrameSet
338  self.frameIdentDict = {
339  1: "baseFrame",
340  2: "frame2",
341  3: "frame3",
342  4: "currFrame",
343  }
344 
345  @staticmethod
346  def makeRawArrayData(nPoints, nAxes, delta=0.123):
347  """Make an array of generic point data
348 
349  The data will be suitable for spherical points
350 
351  Parameters
352  ----------
353  nPoints : `int`
354  Number of points in the array
355  nAxes : `int`
356  Number of axes in the point
357 
358  Returns
359  -------
360  np.array of floats with shape (nAxes, nPoints)
361  The values are as follows; if nAxes != 2:
362  The first point has values `[0, delta, 2*delta, ..., (nAxes-1)*delta]`
363  The Nth point has those values + N
364  if nAxes == 2 then the data is scaled so that the max value of axis 1
365  is a bit less than pi/2
366  """
367  delta = 0.123
368  # oneAxis = [0, 1, 2, ...nPoints-1]
369  oneAxis = np.arange(nPoints, dtype=float) # [0, 1, 2...]
370  # rawData = [oneAxis, oneAxis + delta, oneAxis + 2 delta, ...]
371  rawData = np.array([j * delta + oneAxis for j in range(nAxes)], dtype=float)
372  if nAxes == 2:
373  # scale rawData so that max value of 2nd axis is a bit less than pi/2,
374  # thus making the data safe for IcrsCoord
375  maxLatitude = np.max(rawData[1])
376  rawData *= math.pi * 0.4999 / maxLatitude
377  return rawData
378 
379  @staticmethod
380  def makeRawPointData(nAxes, delta=0.123):
381  """Make one generic point
382 
383  Parameters
384  ----------
385  nAxes : `int`
386  Number of axes in the point
387  delta : `float`
388  Increment between axis values
389 
390  Returns
391  -------
392  A list of `nAxes` floats with values `[0, delta, ..., (nAxes-1)*delta]
393  """
394  return [i*delta for i in range(nAxes)]
395 
396  @staticmethod
397  def makeEndpoint(name, nAxes=None):
398  """Make an endpoint
399 
400  Parameters
401  ----------
402  name : `str`
403  Endpoint class name prefix; the full class name is name + "Endpoint"
404  nAxes : `int` or `None`, optional
405  number of axes; an int is required if `name` == "Generic";
406  otherwise ignored
407 
408  Returns
409  -------
410  subclass of `lsst.afw.geom.BaseEndpoint`
411  The constructed endpoint
412 
413  Raises
414  ------
415  `TypeError`
416  If `name` == "Generic" and `nAxes` is None or <= 0
417  """
418  EndpointClassName = name + "Endpoint"
419  EndpointClass = getattr(afwGeom, EndpointClassName)
420  if name == "Generic":
421  if nAxes is None:
422  raise TypeError("nAxes must be an integer for GenericEndpoint")
423  return EndpointClass(nAxes)
424  return EndpointClass()
425 
426  @classmethod
427  def makeGoodFrame(cls, name, nAxes=None):
428  """Return the appropriate frame for the given name and nAxes
429 
430  Parameters
431  ----------
432  name : `str`
433  Endpoint class name prefix; the full class name is name + "Endpoint"
434  nAxes : `int` or `None`, optional
435  number of axes; an int is required if `name` == "Generic";
436  otherwise ignored
437 
438  Returns
439  -------
440  `ast.Frame`
441  The constructed frame
442 
443  Raises
444  ------
445  `TypeError`
446  If `name` == "Generic" and `nAxes` is `None` or <= 0
447  """
448  return cls.makeEndpoint(name, nAxes).makeFrame()
449 
450  @staticmethod
451  def makeBadFrames(name):
452  """Return a list of 0 or more frames that are not a valid match for the
453  named endpoint
454 
455  Parameters
456  ----------
457  name : `str`
458  Endpoint class name prefix; the full class name is name + "Endpoint"
459 
460  Returns
461  -------
462  Collection of `ast.Frame`
463  A collection of 0 or more frames
464  """
465  return {
466  "Generic": [],
467  "Point2": [
468  ast.SkyFrame(),
469  ast.Frame(1),
470  ast.Frame(3),
471  ],
472  "IcrsCoord": [
473  ast.Frame(1),
474  ast.Frame(2),
475  ast.Frame(3),
476  ],
477  }[name]
478 
479  def makeFrameSet(self, baseFrame, currFrame):
480  """Make a FrameSet
481 
482  The FrameSet will contain 4 frames and three transforms connecting them.
483  The idenity of each frame is provided by self.frameIdentDict
484 
485  Frame Index Mapping from this frame to the next
486  `baseFrame` 1 `ast.UnitMap(nIn)`
487  Frame(nIn) 2 `polyMap`
488  Frame(nOut) 3 `ast.UnitMap(nOut)`
489  `currFrame` 4
490 
491  where:
492  - `nIn` = `baseFrame.nAxes`
493  - `nOut` = `currFrame.nAxes`
494  - `polyMap` = `makeTwoWayPolyMap(nIn, nOut)`
495 
496  Return
497  ------
498  `ast.FrameSet`
499  The FrameSet as described above
500 
501  Parameters
502  ----------
503  baseFrame : `ast.Frame`
504  base frame
505  currFrame : `ast.Frame`
506  current frame
507  """
508  nIn = baseFrame.nAxes
509  nOut = currFrame.nAxes
510  polyMap = makeTwoWayPolyMap(nIn, nOut)
511 
512  # The only way to set the Ident of a frame in a FrameSet is to set it in advance,
513  # and I don't want to modify the inputs, so replace the input frames with copies
514  baseFrame = baseFrame.copy()
515  baseFrame.ident = self.frameIdentDict[1]
516  currFrame = currFrame.copy()
517  currFrame.ident = self.frameIdentDict[4]
518 
519  frameSet = ast.FrameSet(baseFrame)
520  frame2 = ast.Frame(nIn)
521  frame2.ident = self.frameIdentDict[2]
522  frameSet.addFrame(ast.FrameSet.CURRENT, ast.UnitMap(nIn), frame2)
523  frame3 = ast.Frame(nOut)
524  frame3.ident = self.frameIdentDict[3]
525  frameSet.addFrame(ast.FrameSet.CURRENT, polyMap, frame3)
526  frameSet.addFrame(ast.FrameSet.CURRENT, ast.UnitMap(nOut), currFrame)
527  return frameSet
528 
529  @staticmethod
530  def permuteFrameSetIter(frameSet):
531  """Iterator over 0 or more frameSets with SkyFrames axes permuted
532 
533  Only base and current SkyFrames are permuted. If neither the base nor
534  the current frame is a SkyFrame then no frames are returned.
535 
536  Returns
537  -------
538  iterator over `PermutedFrameSet`
539  """
540 
541  fsInfo = FrameSetInfo(frameSet)
542  if not (fsInfo.isBaseSkyFrame or fsInfo.isCurrSkyFrame):
543  return
544 
545  permuteBaseList = [False, True] if fsInfo.isBaseSkyFrame else [False]
546  permuteCurrList = [False, True] if fsInfo.isCurrSkyFrame else [False]
547  for permuteBase in permuteBaseList:
548  for permuteCurr in permuteCurrList:
549  yield PermutedFrameSet(frameSet, permuteBase, permuteCurr)
550 
551  @staticmethod
552  def makeJacobian(nIn, nOut, inPoint):
553  """Make a Jacobian matrix for the equation described by
554  `makeTwoWayPolyMap`.
555 
556  Parameters
557  ----------
558  nIn, nOut : `int`
559  the dimensions of the input and output data; see makeTwoWayPolyMap
560  inPoint : `numpy.ndarray`
561  an array of size `nIn` representing the point at which the Jacobian
562  is measured
563 
564  Returns
565  -------
566  J : `numpy.ndarray`
567  an `nOut` x `nIn` array of first derivatives
568  """
569  basePolyMapCoeff = 0.001 # see makeTwoWayPolyMap
570  baseCoeff = 2.0 * basePolyMapCoeff
571  coeffs = np.empty((nOut, nIn))
572  for iOut in range(nOut):
573  coeffOffset = baseCoeff * iOut
574  for iIn in range(nIn):
575  coeffs[iOut, iIn] = baseCoeff * (iIn + 1) + coeffOffset
576  coeffs[iOut, iIn] *= inPoint[iIn]
577  assert coeffs.ndim == 2
578  # Avoid spurious errors when comparing to a simplified array
579  assert coeffs.shape == (nOut, nIn)
580  return coeffs
581 
582  def checkTransformation(self, transform, mapping, msg=""):
583  """Check applyForward and applyInverse for a transform
584 
585  Parameters
586  ----------
587  transform : `lsst.afw.geom.Transform`
588  The transform to check
589  mapping : `ast.Mapping`
590  The mapping the transform should use. This mapping
591  must contain valid forward or inverse transformations,
592  but they need not match if both present. Hence the
593  mappings returned by make*PolyMap are acceptable.
594  msg : `str`
595  Error message suffix describing test parameters
596  """
597  fromEndpoint = transform.fromEndpoint
598  toEndpoint = transform.toEndpoint
599  frameSet = transform.getFrameSet()
600 
601  nIn = mapping.nIn
602  nOut = mapping.nOut
603  self.assertEqual(nIn, fromEndpoint.nAxes, msg=msg)
604  self.assertEqual(nOut, toEndpoint.nAxes, msg=msg)
605 
606  # forward transformation of one point
607  rawInPoint = self.makeRawPointData(nIn)
608  inPoint = fromEndpoint.pointFromData(rawInPoint)
609 
610  # forward transformation of an array of points
611  nPoints = 7 # arbitrary
612  rawInArray = self.makeRawArrayData(nPoints, nIn)
613  inArray = fromEndpoint.arrayFromData(rawInArray)
614 
615  if mapping.hasForward:
616  self.assertTrue(transform.hasForward)
617  outPoint = transform.applyForward(inPoint)
618  rawOutPoint = toEndpoint.dataFromPoint(outPoint)
619  assert_allclose(rawOutPoint, mapping.applyForward(rawInPoint), err_msg=msg)
620  assert_allclose(rawOutPoint, frameSet.applyForward(rawInPoint), err_msg=msg)
621 
622  outArray = transform.applyForward(inArray)
623  rawOutArray = toEndpoint.dataFromArray(outArray)
624  self.assertFloatsAlmostEqual(rawOutArray, mapping.applyForward(rawInArray), msg=msg)
625  self.assertFloatsAlmostEqual(rawOutArray, frameSet.applyForward(rawInArray), msg=msg)
626  else:
627  # Need outPoint, but don't need it to be consistent with inPoint
628  rawOutPoint = self.makeRawPointData(nOut)
629  outPoint = toEndpoint.pointFromData(rawOutPoint)
630  rawOutArray = self.makeRawArrayData(nPoints, nOut)
631  outArray = toEndpoint.arrayFromData(rawOutArray)
632 
633  self.assertFalse(transform.hasForward)
634 
635  if mapping.hasInverse:
636  self.assertTrue(transform.hasInverse)
637  # inverse transformation of one point;
638  # remember that the inverse need not give the original values
639  # (see the description of the `mapping` parameter)
640  inversePoint = transform.applyInverse(outPoint)
641  rawInversePoint = fromEndpoint.dataFromPoint(inversePoint)
642  assert_allclose(rawInversePoint, mapping.applyInverse(rawOutPoint), err_msg=msg)
643  assert_allclose(rawInversePoint, frameSet.applyInverse(rawOutPoint), err_msg=msg)
644 
645  # inverse transformation of an array of points;
646  # remember that the inverse will not give the original values
647  # (see the description of the `mapping` parameter)
648  inverseArray = transform.applyInverse(outArray)
649  rawInverseArray = fromEndpoint.dataFromArray(inverseArray)
650  self.assertFloatsAlmostEqual(rawInverseArray, mapping.applyInverse(rawOutArray), msg=msg)
651  self.assertFloatsAlmostEqual(rawInverseArray, frameSet.applyInverse(rawOutArray), msg=msg)
652  else:
653  self.assertFalse(transform.hasInverse)
654 
655  def checkInverseTransformation(self, forward, inverse, msg=""):
656  """Check that two Transforms are each others' inverses.
657 
658  Parameters
659  ----------
660  forward : `lsst.afw.geom.Transform`
661  the reference Transform to test
662  inverse : `lsst.afw.geom.Transform`
663  the transform that should be the inverse of `forward`
664  msg : `str`
665  error message suffix describing test parameters
666  """
667  fromEndpoint = forward.fromEndpoint
668  toEndpoint = forward.toEndpoint
669  frameSet = forward.getFrameSet()
670  invFrameSet = inverse.getFrameSet()
671 
672  # properties
673  self.assertEqual(forward.fromEndpoint,
674  inverse.toEndpoint, msg=msg)
675  self.assertEqual(forward.toEndpoint,
676  inverse.fromEndpoint, msg=msg)
677  self.assertEqual(forward.hasForward, inverse.hasInverse, msg=msg)
678  self.assertEqual(forward.hasInverse, inverse.hasForward, msg=msg)
679 
680  # transformations of one point
681  # we don't care about whether the transformation itself is correct
682  # (see checkTransformation), so inPoint/outPoint need not be related
683  rawInPoint = self.makeRawPointData(fromEndpoint.nAxes)
684  inPoint = fromEndpoint.pointFromData(rawInPoint)
685  rawOutPoint = self.makeRawPointData(toEndpoint.nAxes)
686  outPoint = toEndpoint.pointFromData(rawOutPoint)
687 
688  # transformations of arrays of points
689  nPoints = 7 # arbitrary
690  rawInArray = self.makeRawArrayData(nPoints, fromEndpoint.nAxes)
691  inArray = fromEndpoint.arrayFromData(rawInArray)
692  rawOutArray = self.makeRawArrayData(nPoints, toEndpoint.nAxes)
693  outArray = toEndpoint.arrayFromData(rawOutArray)
694 
695  if forward.hasForward:
696  self.assertEqual(forward.applyForward(inPoint),
697  inverse.applyInverse(inPoint), msg=msg)
698  self.assertEqual(frameSet.applyForward(rawInPoint),
699  invFrameSet.applyInverse(rawInPoint), msg=msg)
700  # Assertions must work with both lists and numpy arrays
701  assert_array_equal(forward.applyForward(inArray),
702  inverse.applyInverse(inArray),
703  err_msg=msg)
704  assert_array_equal(frameSet.applyForward(rawInArray),
705  invFrameSet.applyInverse(rawInArray),
706  err_msg=msg)
707 
708  if forward.hasInverse:
709  self.assertEqual(forward.applyInverse(outPoint),
710  inverse.applyForward(outPoint), msg=msg)
711  self.assertEqual(frameSet.applyInverse(rawOutPoint),
712  invFrameSet.applyForward(rawOutPoint), msg=msg)
713  assert_array_equal(forward.applyInverse(outArray),
714  inverse.applyForward(outArray),
715  err_msg=msg)
716  assert_array_equal(frameSet.applyInverse(rawOutArray),
717  invFrameSet.applyForward(rawOutArray),
718  err_msg=msg)
719 
720  def checkTransformFromMapping(self, fromName, toName):
721  """Check Transform_<fromName>_<toName> using the Mapping constructor
722 
723  Parameters
724  ----------
725  fromName, toName : `str`
726  Endpoint name prefix for "from" and "to" endpoints, respectively,
727  e.g. "Point2" for `lsst.afw.geom.Point2Endpoint`
728  fromAxes, toAxes : `int`
729  number of axes in fromFrame and toFrame, respectively
730  """
731  transformClassName = "Transform{}To{}".format(fromName, toName)
732  TransformClass = getattr(afwGeom, transformClassName)
733  baseMsg = "TransformClass={}".format(TransformClass.__name__)
734 
735  # check valid numbers of inputs and outputs
736  for nIn, nOut in itertools.product(self.goodNAxes[fromName],
737  self.goodNAxes[toName]):
738  msg = "{}, nIn={}, nOut={}".format(baseMsg, nIn, nOut)
739  polyMap = makeTwoWayPolyMap(nIn, nOut)
740  transform = TransformClass(polyMap)
741 
742  # desired output from `str(transform)`
743  desStr = "{}[{}->{}]".format(transformClassName, nIn, nOut)
744  self.assertEqual("{}".format(transform), desStr)
745  self.assertEqual(repr(transform), "lsst.afw.geom." + desStr)
746 
747  self.checkTransformation(transform, polyMap, msg=msg)
748 
749  # Forward transform but no inverse
750  polyMap = makeForwardPolyMap(nIn, nOut)
751  transform = TransformClass(polyMap)
752  self.checkTransformation(transform, polyMap, msg=msg)
753 
754  # Inverse transform but no forward
755  polyMap = makeForwardPolyMap(nOut, nIn).getInverse()
756  transform = TransformClass(polyMap)
757  self.checkTransformation(transform, polyMap, msg=msg)
758 
759  # check invalid # of output against valid # of inputs
760  for nIn, badNOut in itertools.product(self.goodNAxes[fromName],
761  self.badNAxes[toName]):
762  badPolyMap = makeTwoWayPolyMap(nIn, badNOut)
763  msg = "{}, nIn={}, badNOut={}".format(baseMsg, nIn, badNOut)
764  with self.assertRaises(InvalidParameterError, msg=msg):
765  TransformClass(badPolyMap)
766 
767  # check invalid # of inputs against valid and invalid # of outputs
768  for badNIn, nOut in itertools.product(self.badNAxes[fromName],
769  self.goodNAxes[toName] + self.badNAxes[toName]):
770  badPolyMap = makeTwoWayPolyMap(badNIn, nOut)
771  msg = "{}, badNIn={}, nOut={}".format(baseMsg, nIn, nOut)
772  with self.assertRaises(InvalidParameterError, msg=msg):
773  TransformClass(badPolyMap)
774 
775  def checkTransformFromFrameSet(self, fromName, toName):
776  """Check Transform_<fromName>_<toName> using the FrameSet constructor
777 
778  Parameters
779  ----------
780  fromName, toName : `str`
781  Endpoint name prefix for "from" and "to" endpoints, respectively,
782  e.g. "Point2" for `lsst.afw.geom.Point2Endpoint`
783  """
784  transformClassName = "Transform{}To{}".format(fromName, toName)
785  TransformClass = getattr(afwGeom, transformClassName)
786  baseMsg = "TransformClass={}".format(TransformClass.__name__)
787  for nIn, nOut in itertools.product(self.goodNAxes[fromName],
788  self.goodNAxes[toName]):
789  msg = "{}, nIn={}, nOut={}".format(baseMsg, nIn, nOut)
790 
791  baseFrame = self.makeGoodFrame(fromName, nIn)
792  currFrame = self.makeGoodFrame(toName, nOut)
793  frameSet = self.makeFrameSet(baseFrame, currFrame)
794  self.assertEqual(frameSet.nFrame, 4)
795 
796  # construct 0 or more frame sets that are invalid for this transform class
797  for badBaseFrame in self.makeBadFrames(fromName):
798  badFrameSet = self.makeFrameSet(badBaseFrame, currFrame)
799  with self.assertRaises(InvalidParameterError):
800  TransformClass(badFrameSet)
801  for badCurrFrame in self.makeBadFrames(toName):
802  reallyBadFrameSet = self.makeFrameSet(badBaseFrame, badCurrFrame)
803  with self.assertRaises(InvalidParameterError):
804  TransformClass(reallyBadFrameSet)
805  for badCurrFrame in self.makeBadFrames(toName):
806  badFrameSet = self.makeFrameSet(baseFrame, badCurrFrame)
807  with self.assertRaises(InvalidParameterError):
808  TransformClass(badFrameSet)
809 
810  transform = TransformClass(frameSet)
811 
812  desStr = "{}[{}->{}]".format(transformClassName, nIn, nOut)
813  self.assertEqual("{}".format(transform), desStr)
814  self.assertEqual(repr(transform), "lsst.afw.geom." + desStr)
815 
816  self.checkPersistence(transform)
817 
818  frameSetCopy = transform.getFrameSet()
819  transformCopy = TransformClass(frameSetCopy)
820  self.assertEqual(type(transform), type(transformCopy))
821  self.assertEqual(transform.getFrameSet(), transformCopy.getFrameSet())
822 
823  desNFrame = 4 # desired number of frames
824  self.assertEqual(frameSet.nFrame, desNFrame)
825  self.assertEqual(frameSetCopy.nFrame, desNFrame)
826  for frameInd in range(1, 1 + desNFrame):
827  self.assertEqual(frameSet.getFrame(frameInd).ident,
828  self.frameIdentDict[frameInd])
829 
830  polyMap = makeTwoWayPolyMap(nIn, nOut)
831 
832  self.checkTransformation(transform, mapping=polyMap, msg=msg)
833 
834  # If the base and/or current frame of frameSet is a SkyFrame,
835  # try permuting that frame (in place, so the connected mappings are
836  # correctly updated). The Transform constructor should undo the permutation,
837  # (via IcrsCoordEndpoint.normalizeFrame) in its internal copy of frameSet,
838  # forcing the axes of the SkyFrame into standard (longitude, latitude) order
839  for permutedFS in self.permuteFrameSetIter(frameSet):
840  if permutedFS.isBaseSkyFrame:
841  baseFrame = permutedFS.frameSet.getFrame(ast.FrameSet.BASE)
842  # desired base longitude axis
843  desBaseLonAxis = 2 if permutedFS.isBasePermuted else 1
844  self.assertEqual(baseFrame.lonAxis, desBaseLonAxis)
845  if permutedFS.isCurrSkyFrame:
846  currFrame = permutedFS.frameSet.getFrame(ast.FrameSet.CURRENT)
847  # desired current base longitude axis
848  desCurrLonAxis = 2 if permutedFS.isCurrPermuted else 1
849  self.assertEqual(currFrame.lonAxis, desCurrLonAxis)
850 
851  permTransform = TransformClass(permutedFS.frameSet)
852  # If the base and/or current frame is a SkyFrame then make sure the frame
853  # in the *Transform* has axes in standard (longitude, latitude) order
854  unpermFrameSet = permTransform.getFrameSet()
855  if permutedFS.isBaseSkyFrame:
856  self.assertEqual(unpermFrameSet.getFrame(ast.FrameSet.BASE).lonAxis, 1)
857  if permutedFS.isCurrSkyFrame:
858  self.assertEqual(unpermFrameSet.getFrame(ast.FrameSet.CURRENT).lonAxis, 1)
859 
860  self.checkTransformation(permTransform, mapping=polyMap, msg=msg)
861 
862  def checkGetInverse(self, fromName, toName):
863  """Test Transform<fromName>To<toName>.getInverse
864 
865  Parameters
866  ----------
867  fromName, toName : `str`
868  Endpoint name prefix for "from" and "to" endpoints, respectively,
869  e.g. "Point2" for `lsst.afw.geom.Point2Endpoint`
870  """
871  transformClassName = "Transform{}To{}".format(fromName, toName)
872  TransformClass = getattr(afwGeom, transformClassName)
873  baseMsg = "TransformClass={}".format(TransformClass.__name__)
874  for nIn, nOut in itertools.product(self.goodNAxes[fromName],
875  self.goodNAxes[toName]):
876  msg = "{}, nIn={}, nOut={}".format(baseMsg, nIn, nOut)
877  self.checkInverseMapping(
878  TransformClass,
879  makeTwoWayPolyMap(nIn, nOut),
880  "{}, Map={}".format(msg, "TwoWay"))
881  self.checkInverseMapping(
882  TransformClass,
883  makeForwardPolyMap(nIn, nOut),
884  "{}, Map={}".format(msg, "Forward"))
885  self.checkInverseMapping(
886  TransformClass,
887  makeForwardPolyMap(nOut, nIn).getInverse(),
888  "{}, Map={}".format(msg, "Inverse"))
889 
890  self.checkInverseFrameSet(TransformClass,
891  self.makeGoodFrame(fromName, nIn),
892  self.makeGoodFrame(toName, nOut))
893 
894  def checkInverseMapping(self, TransformClass, mapping, msg):
895  """Test Transform<fromName>To<toName>.getInverse for a specific mapping.
896 
897  Parameters
898  ----------
899  TransformClass : `type`
900  The class of transform to test, such as TransformPoint2ToIcrsCoord
901  mapping : `ast.Mapping`
902  The mapping to use for the transform
903  msg : `str`
904  Error message suffix
905  """
906  transform = TransformClass(mapping)
907  inverse = transform.getInverse()
908  inverseInverse = inverse.getInverse()
909 
910  self.checkInverseTransformation(transform, inverse, msg=msg)
911  self.checkInverseTransformation(inverse, inverseInverse, msg=msg)
912  self.checkTransformation(inverseInverse, mapping, msg=msg)
913 
914  def checkInverseFrameSet(self, TransformClass, frameIn, frameOut):
915  """Test whether inverting a Transform preserves all information
916  in its FrameSet.
917 
918  Parameters
919  ----------
920  TransformClass : `type`
921  the transform to test
922  frameIn, frameOut : `ast.Frame`
923  the frames to between which `TransformClass` shall convert. Must be
924  compatible with `TransformClass`.
925  """
926  desNFrame = 4 # desired number of frames
927  frameSet = self.makeFrameSet(frameIn, frameOut)
928  self.assertEqual(frameSet.nFrame, desNFrame)
929 
930  baseMsg = "TransformClass={}, nIn={}, nOut={}".format(
931  TransformClass.__name__, frameIn.nAxes, frameOut.nAxes)
932  transform = TransformClass(frameSet)
933  forwardFrames = transform.getFrameSet()
934  self.assertFalse(forwardFrames.isInverted)
935  self.assertEqual(forwardFrames.base, 1)
936  self.assertEqual(forwardFrames.current, desNFrame)
937 
938  self.assertEqual(forwardFrames.nFrame, desNFrame, msg=baseMsg)
939  for frameInd in range(1, 1 + desNFrame):
940  self.assertEqual(forwardFrames.getFrame(frameInd).ident,
941  self.frameIdentDict[frameInd], msg=baseMsg)
942 
943  reverseFrames = transform.getInverse().getFrameSet()
944  self.assertTrue(reverseFrames.isInverted)
945  self.assertEqual(reverseFrames.base, desNFrame)
946  self.assertEqual(reverseFrames.current, 1)
947  self.assertEqual(reverseFrames.nFrame, desNFrame, msg=baseMsg)
948  for frameInd in range(1, 1 + desNFrame):
949  self.assertEqual(reverseFrames.getFrame(frameInd).ident,
950  self.frameIdentDict[frameInd], msg=baseMsg)
951 
952  def checkGetJacobian(self, fromName, toName):
953  """Test Transform<fromName>To<toName>.getJacobian
954 
955  Parameters
956  ----------
957  fromName, toName : `str`
958  Endpoint name prefix for "from" and "to" endpoints, respectively,
959  e.g. "Point2" for `lsst.afw.geom.Point2Endpoint`
960  """
961  transformClassName = "Transform{}To{}".format(fromName, toName)
962  TransformClass = getattr(afwGeom, transformClassName)
963  baseMsg = "TransformClass={}".format(TransformClass.__name__)
964  for nIn, nOut in itertools.product(self.goodNAxes[fromName],
965  self.goodNAxes[toName]):
966  msg = "{}, nIn={}, nOut={}".format(baseMsg, nIn, nOut)
967  polyMap = makeForwardPolyMap(nIn, nOut)
968  transform = TransformClass(polyMap)
969  fromEndpoint = transform.fromEndpoint
970 
971  # Test multiple points to ensure correct functional form
972  rawInPoint = self.makeRawPointData(nIn)
973  inPoint = fromEndpoint.pointFromData(rawInPoint)
974  jacobian = transform.getJacobian(inPoint)
975  assert_allclose(jacobian, self.makeJacobian(nIn, nOut, rawInPoint),
976  err_msg=msg)
977 
978  rawInPoint = self.makeRawPointData(nIn, 0.111)
979  inPoint = fromEndpoint.pointFromData(rawInPoint)
980  jacobian = transform.getJacobian(inPoint)
981  assert_allclose(jacobian, self.makeJacobian(nIn, nOut, rawInPoint),
982  err_msg=msg)
983 
984  def checkThen(self, fromName, midName, toName):
985  """Test Transform<fromName>To<midName>.then(Transform<midName>To<toName>)
986 
987  Parameters
988  ----------
989  fromName : `str`
990  the prefix of the starting endpoint (e.g., "Point2" for a
991  Point2Endpoint) for the final, concatenated Transform
992  midName : `str`
993  the prefix for the shared endpoint where two Transforms will be
994  concatenated
995  toName : `str`
996  the prefix of the ending endpoint for the final, concatenated
997  Transform
998  """
999  TransformClass1 = getattr(afwGeom,
1000  "Transform{}To{}".format(fromName, midName))
1001  TransformClass2 = getattr(afwGeom,
1002  "Transform{}To{}".format(midName, toName))
1003  baseMsg = "{}.then({})".format(TransformClass1.__name__,
1004  TransformClass2.__name__)
1005  for nIn, nMid, nOut in itertools.product(self.goodNAxes[fromName],
1006  self.goodNAxes[midName],
1007  self.goodNAxes[toName]):
1008  msg = "{}, nIn={}, nMid={}, nOut={}".format(
1009  baseMsg, nIn, nMid, nOut)
1010  polyMap1 = makeTwoWayPolyMap(nIn, nMid)
1011  transform1 = TransformClass1(polyMap1)
1012  polyMap2 = makeTwoWayPolyMap(nMid, nOut)
1013  transform2 = TransformClass2(polyMap2)
1014  transform = transform1.then(transform2)
1015 
1016  fromEndpoint = transform1.fromEndpoint
1017  toEndpoint = transform2.toEndpoint
1018 
1019  inPoint = fromEndpoint.pointFromData(self.makeRawPointData(nIn))
1020  outPointMerged = transform.applyForward(inPoint)
1021  outPointSeparate = transform2.applyForward(
1022  transform1.applyForward(inPoint))
1023  assert_allclose(toEndpoint.dataFromPoint(outPointMerged),
1024  toEndpoint.dataFromPoint(outPointSeparate),
1025  err_msg=msg)
1026 
1027  outPoint = toEndpoint.pointFromData(self.makeRawPointData(nOut))
1028  inPointMerged = transform.applyInverse(outPoint)
1029  inPointSeparate = transform1.applyInverse(
1030  transform2.applyInverse(outPoint))
1031  assert_allclose(
1032  fromEndpoint.dataFromPoint(inPointMerged),
1033  fromEndpoint.dataFromPoint(inPointSeparate),
1034  err_msg=msg)
1035 
1036  # Mismatched number of axes should fail
1037  if midName == "Generic":
1038  nIn = self.goodNAxes[fromName][0]
1039  nOut = self.goodNAxes[toName][0]
1040  polyMap = makeTwoWayPolyMap(nIn, 3)
1041  transform1 = TransformClass1(polyMap)
1042  polyMap = makeTwoWayPolyMap(2, nOut)
1043  transform2 = TransformClass2(polyMap)
1044  with self.assertRaises(InvalidParameterError):
1045  transform = transform1.then(transform2)
1046 
1047  # Mismatched types of endpoints should fail
1048  if fromName != midName:
1049  # Use TransformClass1 for both args to keep test logic simple
1050  outName = midName
1051  joinNAxes = set(self.goodNAxes[fromName]).intersection(
1052  self.goodNAxes[outName])
1053 
1054  for nIn, nMid, nOut in itertools.product(self.goodNAxes[fromName],
1055  joinNAxes,
1056  self.goodNAxes[outName]):
1057  polyMap = makeTwoWayPolyMap(nIn, nMid)
1058  transform1 = TransformClass1(polyMap)
1059  polyMap = makeTwoWayPolyMap(nMid, nOut)
1060  transform2 = TransformClass1(polyMap)
1061  with self.assertRaises(InvalidParameterError):
1062  transform = transform1.then(transform2)
1063 
1064  def assertTransformsEqual(self, transform1, transform2):
1065  """Assert that two transforms are equal"""
1066  self.assertEqual(type(transform1), type(transform2))
1067  self.assertEqual(transform1.fromEndpoint, transform2.fromEndpoint)
1068  self.assertEqual(transform1.toEndpoint, transform2.toEndpoint)
1069  self.assertEqual(transform1.getFrameSet(), transform2.getFrameSet())
1070 
1071  fromEndpoint = transform1.fromEndpoint
1072  toEndpoint = transform1.toEndpoint
1073  frameSet = transform1.getFrameSet()
1074  nIn = frameSet.nIn
1075  nOut = frameSet.nOut
1076 
1077  if frameSet.hasForward:
1078  nPoints = 7 # arbitrary
1079  rawInArray = self.makeRawArrayData(nPoints, nIn)
1080  inArray = fromEndpoint.arrayFromData(rawInArray)
1081  outArray = transform1.applyForward(inArray)
1082  outData = toEndpoint.dataFromArray(outArray)
1083  outArrayRoundTrip = transform2.applyForward(inArray)
1084  outDataRoundTrip = toEndpoint.dataFromArray(outArrayRoundTrip)
1085  assert_allclose(outData, outDataRoundTrip)
1086 
1087  if frameSet.hasInverse:
1088  nPoints = 7 # arbitrary
1089  rawOutArray = self.makeRawArrayData(nPoints, nOut)
1090  outArray = toEndpoint.arrayFromData(rawOutArray)
1091  inArray = transform1.applyInverse(outArray)
1092  inData = fromEndpoint.dataFromArray(inArray)
1093  inArrayRoundTrip = transform2.applyInverse(outArray)
1094  inDataRoundTrip = fromEndpoint.dataFromArray(inArrayRoundTrip)
1095  assert_allclose(inData, inDataRoundTrip)
1096 
1097  def checkPersistence(self, transform):
1098  """Check persistence of a transform
1099  """
1100  className = type(transform).__name__
1101 
1102  # check writeString and readString
1103  transformStr = transform.writeString()
1104  serialVersion, serialClassName, serialRest = transformStr.split(" ", 2)
1105  self.assertEqual(int(serialVersion), 1)
1106  self.assertEqual(serialClassName, className)
1107  badStr1 = " ".join(["2", serialClassName, serialRest])
1108  with self.assertRaises(lsst.pex.exceptions.InvalidParameterError):
1109  transform.readString(badStr1)
1110  badClassName = "x" + serialClassName
1111  badStr2 = " ".join(["1", badClassName, serialRest])
1112  with self.assertRaises(lsst.pex.exceptions.InvalidParameterError):
1113  transform.readString(badStr2)
1114  transformFromStr1 = transform.readString(transformStr)
1115  self.assertTransformsEqual(transform, transformFromStr1)
1116 
1117  # check transformFromString
1118  transformFromStr2 = afwGeom.transformFromString(transformStr)
1119  self.assertTransformsEqual(transform, transformFromStr2)
1120 
1121  # Check pickling
1122  self.assertTransformsEqual(transform, pickle.loads(pickle.dumps(transform)))
1123 
1124  # Check afw::table::io persistence round-trip
1125  with lsst.utils.tests.getTempFilePath(".fits") as filename:
1126  transform.writeFits(filename)
1127  self.assertTransformsEqual(transform, type(transform).readFits(filename))
def makeFitsHeaderFromMetadata(metadata)
Definition: testUtils.py:138
def __init__(self, frameSet, permuteBase, permuteCurr)
Definition: testUtils.py:246
Eigen::Matrix2d getCdMatrixFromMetadata(daf::base::PropertySet &metadata)
Read a CD matrix from FITS WCS metadata.
def makeGoodFrame(cls, name, nAxes=None)
Definition: testUtils.py:427
def checkThen(self, fromName, midName, toName)
Definition: testUtils.py:984
def checkTransformFromFrameSet(self, fromName, toName)
Definition: testUtils.py:775
def makeRawArrayData(nPoints, nAxes, delta=0.123)
Definition: testUtils.py:346
def checkTransformation(self, transform, mapping, msg="")
Definition: testUtils.py:582
def checkInverseTransformation(self, forward, inverse, msg="")
Definition: testUtils.py:655
std::string getPackageDir(std::string const &packageName)
def checkGetJacobian(self, fromName, toName)
Definition: testUtils.py:952
def checkInverseFrameSet(self, TransformClass, frameIn, frameOut)
Definition: testUtils.py:914
Divide a box into nx by ny sub-boxes that tile the region.
Definition: testUtils.py:48
def makeSipPixelToIwc(metadata)
Definition: testUtils.py:208
def __getitem__(self, indXY)
Return the box at the specified x,y index (a pair of ints)
Definition: testUtils.py:91
def getTempFilePath(ext, expectOutput=True)
def checkGetInverse(self, fromName, toName)
Definition: testUtils.py:862
def __init__(self, box, numColRow)
Construct a BoxGrid.
Definition: testUtils.py:52
def __iter__(self)
Return an iterator over all boxes, where column varies most quickly.
Definition: testUtils.py:102
def assertTransformsEqual(self, transform1, transform2)
Definition: testUtils.py:1064
def makeSipPolyMapCoeffs(metadata, name)
Definition: testUtils.py:155
def makeSipIwcToPixel(metadata)
Definition: testUtils.py:188
def checkInverseMapping(self, TransformClass, mapping, msg)
Definition: testUtils.py:894
Transform LSST spatial data, such as Point2D and IcrsCoord, using an AST transform.
Definition: Transform.h:69
def makeFrameSet(self, baseFrame, currFrame)
Definition: testUtils.py:479
def checkTransformFromMapping(self, fromName, toName)
Definition: testUtils.py:720