LSSTApplications  11.0-24-g0a022a1,14.0+77,15.0,15.0+1
LSSTDataManagementBasePackage
Functions | Variables
lsst.afw.coord.utils Namespace Reference

Functions

def assertCoordsAlmostEqual (testCase, coord0, coord1, maxDiff=0.001 *afwGeom.arcseconds, msg="Coords differ")
 Assert that two coords represent almost the same point on the sky. More...
 
def assertCoordListsAlmostEqual (testCase, coordlist0, coordlist1, maxDiff=0.001 *afwGeom.arcseconds, msg=None)
 Assert that two lists of IcrsCoords represent almost the same point on the sky. More...
 
def assertCoordsNearlyEqual (args, kwargs)
 

Variables

list __all__ = ["assertCoordsAlmostEqual", "assertCoordsNearlyEqual"]
 

Function Documentation

◆ assertCoordListsAlmostEqual()

def lsst.afw.coord.utils.assertCoordListsAlmostEqual (   testCase,
  coordlist0,
  coordlist1,
  maxDiff = 0.001*afwGeom.arcseconds,
  msg = None 
)

Assert that two lists of IcrsCoords represent almost the same point on the sky.

Warning
the coordinate systems are not compared; instead both sets of angles are converted to ICRS and the angular separation measured.
Parameters
[in]testCaseunittest.TestCase instance the test is part of; an object supporting one method: fail(self, msgStr)
[in]coordlist0list of IcrsCoords 0
[in]coordlist1list of IcrsCoords 1
[in]maxDiffmaximum angular separation, an lsst.afw.geom.Angle
[in]msgexception message prefix; details of the error are appended after ": "

Definition at line 60 of file utils.py.

60 def assertCoordListsAlmostEqual(testCase, coordlist0, coordlist1, maxDiff=0.001*afwGeom.arcseconds, msg=None):
61  """!Assert that two lists of IcrsCoords represent almost the same point on the sky
62 
63  @warning the coordinate systems are not compared; instead both sets of angles are converted to ICRS
64  and the angular separation measured.
65 
66  @param[in] testCase unittest.TestCase instance the test is part of;
67  an object supporting one method: fail(self, msgStr)
68  @param[in] coordlist0 list of IcrsCoords 0
69  @param[in] coordlist1 list of IcrsCoords 1
70  @param[in] maxDiff maximum angular separation, an lsst.afw.geom.Angle
71  @param[in] msg exception message prefix; details of the error are appended after ": "
72  """
73  testCase.assertEqual(len(coordlist0), len(coordlist1), msg=msg)
74  sepArr = np.array([sp0.toIcrs().angularSeparation(sp1.toIcrs())
75  for sp0, sp1 in zip(coordlist0, coordlist1)])
76  badArr = sepArr > maxDiff
77  if np.any(badArr):
78  msg = "" if msg is None else msg + ": "
79  maxInd = np.argmax(sepArr)
80  testCase.fail("%sIcrsCoordLists differ in %s places; max separation is at %s: %s\" > %s\"" %
81  (msg, np.sum(badArr), maxInd, sepArr[maxInd].asArcseconds(),
82  maxDiff.asArcseconds()))
83 
84 
85 @lsst.utils.tests.inTestCase
def assertCoordListsAlmostEqual(testCase, coordlist0, coordlist1, maxDiff=0.001 *afwGeom.arcseconds, msg=None)
Assert that two lists of IcrsCoords represent almost the same point on the sky.
Definition: utils.py:60

◆ assertCoordsAlmostEqual()

def lsst.afw.coord.utils.assertCoordsAlmostEqual (   testCase,
  coord0,
  coord1,
  maxDiff = 0.001*afwGeom.arcseconds,
  msg = "Coords differ" 
)

Assert that two coords represent almost the same point on the sky.

Warning
the coordinate systems are not compared; instead both angles are converted to ICRS and the angular separation measured.
Parameters
[in]testCaseunittest.TestCase instance the test is part of; an object supporting one method: fail(self, msgStr)
[in]coord0coord 0 (an lsst.afw.geom.Coord)
[in]coord1coord 1 (an lsst.afw.geom.Coord)
[in]maxDiffmaximum angular separation between the two coords (an lsst.afw.geom.Angle)
[in]msgexception message prefix; details of the error are appended after ": "
Exceptions
AssertionErrorif the unwrapped difference is greater than maxDiff

Definition at line 38 of file utils.py.

38 def assertCoordsAlmostEqual(testCase, coord0, coord1, maxDiff=0.001*afwGeom.arcseconds, msg="Coords differ"):
39  """!Assert that two coords represent almost the same point on the sky
40 
41  @warning the coordinate systems are not compared; instead both angles are converted to ICRS
42  and the angular separation measured.
43 
44  @param[in] testCase unittest.TestCase instance the test is part of;
45  an object supporting one method: fail(self, msgStr)
46  @param[in] coord0 coord 0 (an lsst.afw.geom.Coord)
47  @param[in] coord1 coord 1 (an lsst.afw.geom.Coord)
48  @param[in] maxDiff maximum angular separation between the two coords (an lsst.afw.geom.Angle)
49  @param[in] msg exception message prefix; details of the error are appended after ": "
50 
51  @throw AssertionError if the unwrapped difference is greater than maxDiff
52  """
53  measDiff = coord0.toIcrs().angularSeparation(coord1.toIcrs())
54  if measDiff > maxDiff:
55  testCase.fail("%s: measured angular separation %s arcsec > max allowed %s arcsec" %
56  (msg, measDiff.asArcseconds(), maxDiff.asArcseconds()))
57 
58 
59 @lsst.utils.tests.inTestCase
def assertCoordsAlmostEqual(testCase, coord0, coord1, maxDiff=0.001 *afwGeom.arcseconds, msg="Coords differ")
Assert that two coords represent almost the same point on the sky.
Definition: utils.py:38

◆ assertCoordsNearlyEqual()

def lsst.afw.coord.utils.assertCoordsNearlyEqual (   args,
  kwargs 
)

Definition at line 86 of file utils.py.

86 def assertCoordsNearlyEqual(*args, **kwargs):
87  warnings.warn("Deprecated. Use assertCoordsAlmostEqual",
88  DeprecationWarning, 2)
89  assertCoordsAlmostEqual(*args, **kwargs)
90 
def assertCoordsAlmostEqual(testCase, coord0, coord1, maxDiff=0.001 *afwGeom.arcseconds, msg="Coords differ")
Assert that two coords represent almost the same point on the sky.
Definition: utils.py:38
def assertCoordsNearlyEqual(args, kwargs)
Definition: utils.py:86

Variable Documentation

◆ __all__

list lsst.afw.coord.utils.__all__ = ["assertCoordsAlmostEqual", "assertCoordsNearlyEqual"]
private

Definition at line 27 of file utils.py.