Exemple #1
0
    def setUp(self):
        self.fakeVel2D = np.asarray(
            [
                [1, 2, 3],
                [4, 5, 6],
                [7, 8, 9]
            ]
        )

        self.fakePressure2D = np.asarray(
            [
                [11, 22, 33],
                [44, 55, 66],
                [77, 88, 99],
            ]
        )

        self.fakeOccupancy2D = np.asarray(
            [
                [2, 2, 2],
                [2, 0, 2],
                [2, 2, 2],
            ]
        )
        IO.createPath(os.path.dirname(__file__) +
                      "/data_for_testing_2D/")
        np.savez(os.path.dirname(__file__) +
                 "/data_for_testing_2D/div_vel_0000", self.fakeVel2D)
        np.savez(os.path.dirname(__file__) +
                 "/data_for_testing_2D/pressure_0000", self.fakePressure2D)
        np.savez(os.path.dirname(__file__) +
                 "/data_for_testing_2D/flags_0000", self.fakePressure2D)

        self.fakeVel3D = np.asarray([
            [[1,   2,  3], [4,   5,  6], [7,   8,  9]],
            [[10, 11, 12], [13, 14, 15], [16, 17, 18]],
            [[19, 20, 21], [22, 23, 24], [25, 26, 27]],
        ])
        self.fakePressure3D = np.asarray([
            [[111, 222, 333], [444, 555, 666], [777, 888, 999]],
            [[1111, 2222, 3333], [4444, 5555, 6666], [7777, 8888, 9999]],
            [[11111, 22222, 33333], [44444, 55555, 66666], [77777, 88888, 99999]],
        ])
        self.fakeOccupancy3D = np.asarray([
            [[0, 0, 0], [0, 0, 0], [0, 0, 0]],
            [[0, 0, 0], [0, 0, 0], [0, 0, 0]],
            [[0, 0, 0], [0, 0, 0], [0, 0, 0]]
        ])
        IO.createPath(os.path.dirname(__file__) +
                      "/data_for_testing_3D/")
        np.savez(os.path.dirname(__file__) +
                 "/data_for_testing_3D/div_vel_0000", self.fakeVel3D)
        np.savez(os.path.dirname(__file__) +
                 "/data_for_testing_3D/pressure_0000", self.fakePressure3D)
        np.savez(os.path.dirname(__file__) +
                 "/data_for_testing_3D/flags_0000", self.fakePressure3D)
Exemple #2
0
    def plot_grids(grids,
                   gridType="div_vel",
                   movie_path=os.path.dirname(__file__) +
                   "/../visuals/movies"):

        IO.createPath(movie_path)

        f_name_pattern = movie_path + "/" + gridType

        for i, grid in enumerate(grids):
            Visualize.plot_grid(grid,
                                f_name_pattern + "_{:04d}".format(i) + ".png")

        # turn it into gif
        subprocess.call([
            'ffmpeg', '-i', f_name_pattern + "_%04d.png", '-y',
            f_name_pattern + ".gif"
        ])

        files_in_dir = os.listdir(movie_path)
        for item in files_in_dir:
            if item.endswith(".png") or item.endswith(".mp4"):
                os.remove(os.path.join(movie_path, item))