def plot_3D_surfaces(inputfolder, outputfolder, points=True, gridsize=100): """ Plot 3D views of surfaces located in a given directory. Parameters ---------- inputfolder : str Input directory with surfaces. outputfolder : str Output directory to save the plots. points : bool, optional If True, surface points will be displayed. Default is True. gridsize : int, optional Dimension of the square grid to interpolate the surface points. Default is 100. """ files = filelib.list_subfolders(inputfolder, extensions=['csv']) for fn in files: s = Surface(filename=inputfolder + fn) s.centrate() s.to_spherical() s.Rgrid = s.interpolate(grid_size=gridsize) mesh = s.plot_surface(points=points) mesh.magnification = 3 filelib.make_folders([os.path.dirname(outputfolder + fn[:-4])]) mesh.save(outputfolder + fn[:-4] + '.png', size=(200, 200))
def test05_plot(self): path = site.getsitepackages()[0] + '/SPHARM/tests/' fn = path + 'data/synthetic_cell.txt' surf = Surface(filename=fn) with warnings.catch_warnings(): warnings.simplefilter("ignore") mesh = surf.plot_points() os.makedirs('data/test_data') mesh.save('data/test_data/points_3D.png', size=(200, 200)) surf.centrate() surf.to_spherical() surf.Rgrid = surf.interpolate(grid_size=100) with warnings.catch_warnings(): warnings.simplefilter("ignore") mesh = surf.plot_surface(points=False) mesh.save('data/test_data/surface_3D.png', size=(200, 200)) with warnings.catch_warnings(): warnings.simplefilter("ignore") mesh = surf.plot_surface(points=True) mesh.save('data/test_data/surface_with_points_3D.png', size=(200, 200)) self.assertEqual(os.path.exists('data/test_data/surface_3D.png'), True) self.assertEqual(os.path.exists('data/test_data/points_3D.png'), True) self.assertEqual( os.path.exists('data/test_data/surface_with_points_3D.png'), True) shutil.rmtree('data/test_data/')