Exemplo n.º 1
0
    def test_split_path_at_interface_intersections(self):
        """
        Should split a path into layer segments 
        """
        sym = [".-r", ".-c", ".-m", ".-w"]
        for path in self.raypaths:
            _path = np.asarray(path)
            px, py, pz = _path[:, 0], _path[:, 1], _path[:, 2]

            _px, _, _pz, _ = insert_intersections(self.vm, px, py, pz)
            if PLOT:
                fig = plt.figure()
                ax = fig.add_subplot(111)
                self.vm.plot(ax=ax, show_grid=True)
                ax.plot(px, pz, ".-g", markersize=20, lw=5)
                ax.plot(_px, _pz, ".-k", markersize=10, lw=3)

            segments = split_path_at_interface_intersections(self.vm, px, py, pz)

            if PLOT:
                for i, segments in enumerate(segments):
                    for p in segments:
                        if len(p) == 0:
                            continue

                        ax.plot(p[:, 0], p[:, 2], sym[i])

                plt.show()

            self.assertEqual(len(segments), self.vm.nr + 1)
Exemplo n.º 2
0
    def test_insert_intersections(self):
        """
        Should add layer intersections
        """
        for path in self.raypaths[0:1]:
            _path = np.asarray(path)
            px, py, pz = _path[:, 0], _path[:, 1], _path[:, 2]

            for duplicate in [True, False]:
                if PLOT:
                    fig = plt.figure()
                    ax = fig.add_subplot(111)
                    plt.title("duplicate = {}".format(duplicate))
                    self.vm.plot(ax=ax, show_grid=True)
                    ax.plot(px, pz, ".-g", markersize=10, lw=3)

                px, py, pz, pi = insert_intersections(self.vm, px, py, pz, duplicate=duplicate)

                if PLOT:
                    ax.plot(px, pz, ".-m")
                    plt.show()

                self.assertEqual(len(px), len(pi))
                self.assertEqual(len(py), len(pi))
                self.assertEqual(len(pz), len(pi))