Exemplo n.º 1
0
    def test_assign_points_to_layers(self):
        """
        Should assign a layer index to each point.
        """

        # Should label each point with its layer index
        pi = assign_points_to_layers(self.vm, self.px, self.py, self.pz)
        for _pi0, _pi in zip(self.pi, pi):
            self.assertEqual(_pi0, _pi)
Exemplo n.º 2
0
 def test_get_piercing_points(self):
     """
     Should find coordinates of piercing points.
     """
     iref = 0
     # indices of points near the piercing points
     ip = get_indices_near_piercing(self.pi, iref)
     # should find piercing points if path crosses interface
     pp = get_piercing_points(self.vm, iref, self.px, self.py, self.pz,
                              ip)
     self.assertEqual(pp[0, 0], 1.)
     self.assertEqual(pp[0, 1], 1.8)
     self.assertEqual(pp[0, 2], 5.)
     self.assertEqual(pp[1, 0], 1.)
     self.assertEqual(pp[1, 1], 8.75)
     self.assertEqual(pp[1, 2], 5.)
     # should return empty array if path does not cross interface
     px = np.ones(len(self.pi))
     py = np.linspace(1, 9, len(self.pi))
     pz = 12 * np.ones(len(self.pi))
     pi = assign_points_to_layers(self.vm, px, py, pz)
     ip = get_indices_near_piercing(pi, iref)
     pp = get_piercing_points(self.vm, 0, px, py, pz, ip)
     self.assertEqual(len(pp), 0)
     # should just return points on the downward leg
     ip = get_indices_near_piercing(self.pi, iref, downward=True,
                                    upward=False)
     pp = get_piercing_points(self.vm, 0, self.px, self.py, self.pz, ip)
     self.assertEqual(pp[0, 0], 1.)
     self.assertEqual(pp[0, 1], 1.8)
     self.assertEqual(pp[0, 2], 5.)
     # should just return points on the upward leg
     ip = get_indices_near_piercing(self.pi, iref, downward=False,
                                    upward=True)
     pp = get_piercing_points(self.vm, 0, self.px, self.py, self.pz, ip)
     self.assertEqual(pp[0, 0], 1.)
     self.assertEqual(pp[0, 1], 8.75)
     self.assertEqual(pp[0, 2], 5.)