• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python mlab.close函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中mayavi.mlab.close函数的典型用法代码示例。如果您正苦于以下问题:Python close函数的具体用法?Python close怎么用?Python close使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了close函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: short_branches

def short_branches():
    """
    Visualization of short branches of the skeleton.
    
    """
    data1_sk = glob.glob('/backup/yuliya/vsi05/skeletons_largdom/*.h5')
    data1_sk.sort()

    for i,j, k in zip(d[1][37:47], data1_sk[46:56], ell[1][37:47]):
        g = nx.read_gpickle(i)
        dat = tb.openFile(j)
        skel = np.copy(dat.root.skel)
        bra = np.copy(dat.root.branches)
        mask = np.zeros_like(skel)    
        dat.close()
    
        length = nx.get_edge_attributes(g, 'length')
        number = nx.get_edge_attributes(g, 'number')
        num_dict = {}
        for m in number:
            for v in number[m]:
                num_dict.setdefault(v, []).append(m)
        find_br = ndimage.find_objects(bra)
        for l in list(length.keys()):
            if length[l]<0.5*k: #Criteria
                for b in number[l]:
                    mask[find_br[b-1]] = bra[find_br[b-1]]==b
        mlab.figure(bgcolor=(1,1,1), size=(1200,1200))
        mlab.contour3d(skel, colormap='hot')
        mlab.contour3d(mask)
        mlab.savefig('/backup/yuliya/vsi05/skeletons/short_bran/'+ i[42:-10] + '.png')
        mlab.close()
开发者ID:YuliyaKar,项目名称:Skeleton_to_graph-labeling-,代码行数:32,代码来源:graph_analisys.py


示例2: toggleshow3

 def toggleshow3(self):
     if not self.show3On:
         self.show3On = True
         self.show3()
     elif self.show3On:
         mlab.close()
         self.show3On = False
开发者ID:donelectrone,项目名称:pylayers,代码行数:7,代码来源:editor.py


示例3: test_empty

    def test_empty(self):

        data=numpy.zeros((20,20,20))

        mlab.figure( bgcolor=(0,0,0), size=(1000,845) )
        ATMA.GUI.DataVisualizer.segmentation( data )
        mlab.close()
开发者ID:BioinformaticsArchive,项目名称:ATMA,代码行数:7,代码来源:test_DataVisualizer.py


示例4: Main

def Main(outputFolder, isData, normalized = True):
    assert isinstance(outputFolder, str)
    min, max = 0., 1.
    if os.path.splitext(args.file)[1] == '.arff':
        datasets, targets, targetMap = loadFromArff(args.file)
    elif os.path.splitext(args.file)[1] == '.npy':
        datasets = numpy.load(args.file)
        min = -1.
    else:
        assert False

    datasets = (lambda x : histogramEqualization(x, min=min, max=max) if normalized else x)(datasets)
    if normalized : assert (datasets.min(), datasets.max()) == (min, max)

    if not os.path.isdir("%s/Pictures" % outputFolder):
        os.makedirs("%s/Pictures" % outputFolder)

    global listIndex
    if listIndex is None or (len(listIndex) >= len(datasets)):
        listIndex = xrange(len(datasets))

    for index in listIndex:
        assert 0 <= index < len(datasets)
        mlab.figure("Index : %d" % index, bgcolor=(1,1,1))
        showArray(datasets[index], isData)
        mlab.savefig("%s/Pictures/Index_%d.png" % (outputFolder, index))
        if isData:
            saveData('%s/Pictures/%s_Index_%d.txt' % (outputFolder, targetMap.reverse_mapping[targets[index]], index), datasets[index])
        else:
            saveData('%s/Pictures/Index_%d.txt' % (outputFolder, index), datasets[index])
        mlab.close()
开发者ID:mehdidc,项目名称:boosting,代码行数:31,代码来源:ILC_showDataset.py


示例5: test_rawData

    def test_rawData(self):

        raw=numpy.uint32(numpy.random.rand(200,200,200)*255)

        mlab.figure( bgcolor=(0,0,0), size=(1000,845) )
        ATMA.GUI.DataVisualizer.rawSlider( raw )
        mlab.close()
开发者ID:BioinformaticsArchive,项目名称:ATMA,代码行数:7,代码来源:test_DataVisualizer.py


示例6: savefig

def savefig(filename,mlabview=[],magnification = 3):
    """
    Save mayavi figure

    Parameters
    ----------

    name : str
        name of the figure
    mlabview : [] | (x,y,z, np.array([ xroll,yroll,zroll]))
        specifyy angle of camera view ( see mayavi.view )
    magnification : int
        resolution of the generated image ( see mayavi.savefig)

    """
    import os


    path = os.path.dirname(filename)
    if not mlabview == []:
        mlab.view(mlabview)
    if os.path.exists(path):
        mlab.savefig(filename+'.png',magnification=magnification )
    else:
        os.mkdir(path)
        mlab.savefig(filename+'.png',magnification=magnification )
    mlab.close()
开发者ID:mmhedhbi,项目名称:pylayers,代码行数:27,代码来源:mayautil.py


示例7: mayavi_scraper

def mayavi_scraper(block, block_vars, gallery_conf):
    """Scrape Mayavi images.

    Parameters
    ----------
    block : tuple
        A tuple containing the (label, content, line_number) of the block.
    block_vars : dict
        Dict of block variables.
    gallery_conf : dict
        Contains the configuration of Sphinx-Gallery

    Returns
    -------
    rst : str
        The ReSTructuredText that will be rendered to HTML containing
        the images. This is often produced by
        :func:`sphinx_gallery.gen_rst.figure_rst`.
    """
    from mayavi import mlab
    image_path_iterator = block_vars['image_path_iterator']
    image_paths = list()
    e = mlab.get_engine()
    for scene, image_path in zip(e.scenes, image_path_iterator):
        mlab.savefig(image_path, figure=scene)
        # make sure the image is not too large
        scale_image(image_path, image_path, 850, 999)
        image_paths.append(image_path)
    mlab.close(all=True)
    return figure_rst(image_paths, gallery_conf['src_dir'])
开发者ID:Titan-C,项目名称:sphinx-gallery,代码行数:30,代码来源:scrapers.py


示例8: vis_breakups

def vis_breakups():
    """
    This function allows to visualize break-ups as the highlighted branches in
    the original skeleton.
    """
    data_sk = glob.glob('/backup/yuliya/vsi05/skeletons_largdom/*.h5')
    data_sk.sort()
    
    data_br = glob.glob('/backup/yuliya/vsi05/breakups_con_correction/dict/*.npy')
    data_br.sort()
    
    for i,j in zip(data_sk[27:67][::-1], data_br[19:][::-1]):
        d = tb.openFile(i, mode='r')
        bran1 = np.copy(d.root.branches)
        skel1 = np.copy(d.root.skel)
        d.close() 

        br = np.load(j).item()
        
        mlab.figure(1, bgcolor=(1,1,1), size=(1200,1200))
        surf_skel = mlab.contour3d(skel1, colormap='hot')
        surf_skel.actor.property.representation = 'points'
        surf_skel.actor.property.line_width = 2.3
        mask = np.zeros_like(skel1)
        for k in br:
            sl = br[k]            
            mask[sl] = (bran1[sl] == k)
        surf_mask = mlab.contour3d(mask.astype('uint8'))
        surf_mask.actor.property.representation = 'wireframe'
        surf_mask.actor.property.line_width = 5
        
        mlab.savefig('/backup/yuliya/vsi05/breakups_con_correction/video_hot/' + i[39:-3] + '.png')
        mlab.close()
开发者ID:YuliyaKar,项目名称:Skeleton_to_graph-labeling-,代码行数:33,代码来源:graph_vis.py


示例9: test_close

    def test_close(self):
        """ Various tests for mlab.close().
        """
        f = mlab.figure()
        self.assertTrue(f.running)
        mlab.close(f)
        self.assertFalse(f.running)

        f = mlab.figure(314)
        self.assertTrue(f.running)
        mlab.close(314)
        self.assertFalse(f.running)

        f = mlab.figure('test_figure')
        self.assertTrue(f.running)
        mlab.close('test_figure')
        self.assertFalse(f.running)

        f = mlab.figure()
        self.assertTrue(f.running)
        mlab.close()
        self.assertFalse(f.running)

        figs = [mlab.figure() for i in range(5)]
        for f in figs:
            self.assertTrue(f.running)
        mlab.close(all=True)
        for f in figs:
            self.assertFalse(f.running)
开发者ID:enthought,项目名称:mayavi,代码行数:29,代码来源:test_mlab_integration.py


示例10: plot_inverse_operator

def plot_inverse_operator(subject, fnout_img=None, verbose=None):
    """"Reads in and plots the inverse solution."""

    # get name of inverse solution-file
    subjects_dir = os.environ.get('SUBJECTS_DIR')
    fname_dir_inv = os.path.join(subjects_dir,
                                 subject)

    for files in os.listdir(fname_dir_inv):
        if files.endswith(",cleaned_epochs_avg-7-src-meg-inv.fif"):
            fname_inv = os.path.join(fname_dir_inv,
                                     files)
            break

    try:
        fname_inv
    except NameError:
        print "ERROR: No forward solution found!"
        sys.exit()


    # read inverse solution
    inv = min_norm.read_inverse_operator(fname_inv)

    # print some information if desired
    if verbose is not None:
        print "Method: %s" % inv['methods']
        print "fMRI prior: %s" % inv['fmri_prior']
        print "Number of sources: %s" % inv['nsource']
        print "Number of channels: %s" % inv['nchan']


    # show 3D source space
    lh_points = inv['src'][0]['rr']
    lh_faces = inv['src'][0]['tris']
    rh_points = inv['src'][1]['rr']
    rh_faces = inv['src'][1]['tris']

    # create figure and plot results
    fig_inverse = mlab.figure(size=(1200, 1200),
                              bgcolor=(0, 0, 0))

    mlab.triangular_mesh(lh_points[:, 0],
                         lh_points[:, 1],
                         lh_points[:, 2],
                         lh_faces)

    mlab.triangular_mesh(rh_points[:, 0],
                         rh_points[:, 1],
                         rh_points[:, 2],
                         rh_faces)

    # save result
    if fnout_img is not None:
        mlab.savefig(fnout_img,
                     figure=fig_inverse,
                     size=(1200, 1200))

    mlab.close(all=True)
开发者ID:VolkanChen,项目名称:jumeg,代码行数:59,代码来源:meg_source_localization.py


示例11: close

    def close(self):
        """Close the figure and cleanup data structure."""
        try:
            from mayavi import mlab
        except ImportError:
            from enthought.mayavi import mlab

        mlab.close(self._f)
开发者ID:hanke,项目名称:PySurfer,代码行数:8,代码来源:viz.py


示例12: close

 def close(self):
     for f in self.figures.itervalues():
         plt.close(f)
     self.figures = {}
     
     self.figMslices.close()
     mlab.close(self.fig1)
     if self.show_grad:
         self.figdMslices.close()
开发者ID:Veterun,项目名称:cryoem-cvpr2015,代码行数:9,代码来源:visualizer.py


示例13: test_save_load_visualization_with_mlab

    def test_save_load_visualization_with_mlab(self):
        # test mlab.get_engine
        engine = mlab.get_engine()

        try:
            self.check_save_load_visualization(engine)
        finally:
            mlab.clf()
            mlab.close(all=True)
开发者ID:simphony,项目名称:simphony-mayavi,代码行数:9,代码来源:test_cuds_source.py


示例14: surfacePlot

def surfacePlot(
    Hmap,
    nrows,
    ncols,
    xyspacing,
    zscale,
    name,
    hRange,
    file_path,
    lutfromfile,
    lut,
    lut_file_path,
    colorbar_on,
    save,
    show,
):

    # Create a grid of the x and y coordinates corresponding to each pixel in the height matrix
    x, y = np.mgrid[0 : ncols * xyspacing : xyspacing, 0 : nrows * xyspacing : xyspacing]

    # Create a new figure
    mlab.figure(size=(1000, 1000))

    # Set the background color if desired
    # bgcolor=(0.16, 0.28, 0.46)

    # Create the surface plot of the reconstructed data
    plot = mlab.surf(x, y, Hmap, warp_scale=zscale, vmin=hRange[0], vmax=hRange[1], colormap=lut)

    # Import the LUT from a file if necessary
    if lutfromfile:
        plot.module_manager.scalar_lut_manager.load_lut_from_file(lut_file_path)

    # Draw the figure with the new LUT if necessary
    mlab.draw()

    # Zoom in to fill the entire window
    f = mlab.gcf()
    f.scene.camera.zoom(1.05)

    # Change the view to a top-down perspective
    mlab.view(270, 0)

    # Add a colorbar if indicated by colorbar_on (=True)
    if colorbar_on:
        # mlab.colorbar(title='Height (nm)', orientation='vertical')
        mlab.colorbar(orientation="vertical")

    # Save the figure if indicated by save (=True)
    if save:
        mlab.savefig(file_path, size=(1000, 1000))
        if show == False:
            mlab.close()

    # Keep the figure open if indicated by show (=True)
    if show:
        mlab.show()
开发者ID:gogqou,项目名称:SAIM,代码行数:57,代码来源:surfacePlot.py


示例15: mayavi_plt

def mayavi_plt():
    
    ml.test_plot3d()
    arr = ml.screenshot()
    ml.close()

    plt.imshow(arr)
    plt.axis('off')
    plt.show()
开发者ID:tthieme,项目名称:Akamai2016,代码行数:9,代码来源:practice.py


示例16: new_func

 def new_func(test_case):
     try:
         func(test_case)
     finally:
         num_scenes = len(mlab.get_engine().scenes)
         test_case.assertNotEqual(num_scenes, 0,
                                  "No scene is opened")
         # close everything
         mlab.close(all=True)
开发者ID:simphony,项目名称:simphony-mayavi,代码行数:9,代码来源:test_show.py


示例17: test_three_lines

    def test_three_lines(self):

        data=numpy.zeros((200,200,160))
        data[50,50,:]=1
        data[150,150,:]=2
        data[50,150,:]=3

        mlab.figure( bgcolor=(0,0,0), size=(1000,845) )
        ATMA.GUI.DataVisualizer.segmentation( data )
        mlab.close()
开发者ID:BioinformaticsArchive,项目名称:ATMA,代码行数:10,代码来源:test_DataVisualizer.py


示例18: f

def f(arr):
    from mayavi import mlab
    fig = mlab.figure(size=(800,800))
    n_x = arr[0]
    n_y = arr[1]
    n_z = arr[2]
    name = arr[3]
    d = exponential(size=(n_x,n_y,n_z))
    mlab.points3d(d[0], d[1], d[2], figure=fig)
    mlab.savefig(name+'.png', figure=fig)
    mlab.close(fig)
    return name
开发者ID:Thalos12,项目名称:astro_utils,代码行数:12,代码来源:prova_multprocessing.py


示例19: save_figures

def save_figures(image_path, fig_count, gallery_conf):
    """Save all open matplotlib figures of the example code-block

    Parameters
    ----------
    image_path : str
        Path where plots are saved (format string which accepts figure number)
    fig_count : int
        Previous figure number count. Figure number add from this number
    gallery_conf : dict
        Contains the configuration of Sphinx-Gallery

    Returns
    -------
    images_rst : str
        rst code to embed the images in the document
    fig_num : int
        number of figures saved
    """
    figure_list = []

    for fig_num in plt.get_fignums():
        # Set the fig_num figure as the current figure as we can't
        # save a figure that's not the current figure.
        fig = plt.figure(fig_num)
        kwargs = {}
        to_rgba = matplotlib.colors.colorConverter.to_rgba
        for attr in ['facecolor', 'edgecolor']:
            fig_attr = getattr(fig, 'get_' + attr)()
            default_attr = matplotlib.rcParams['figure.' + attr]
            if to_rgba(fig_attr) != to_rgba(default_attr):
                kwargs[attr] = fig_attr

        current_fig = image_path.format(fig_count + fig_num)
        fig.savefig(current_fig, **kwargs)
        figure_list.append(current_fig)

    if gallery_conf.get('find_mayavi_figures', False):
        from mayavi import mlab
        e = mlab.get_engine()
        last_matplotlib_fig_num = fig_count + len(figure_list)
        total_fig_num = last_matplotlib_fig_num + len(e.scenes)
        mayavi_fig_nums = range(last_matplotlib_fig_num + 1, total_fig_num + 1)

        for scene, mayavi_fig_num in zip(e.scenes, mayavi_fig_nums):
            current_fig = image_path.format(mayavi_fig_num)
            mlab.savefig(current_fig, figure=scene)
            # make sure the image is not too large
            scale_image(current_fig, current_fig, 850, 999)
            figure_list.append(current_fig)
        mlab.close(all=True)

    return figure_rst(figure_list, gallery_conf['src_dir'])
开发者ID:alpinho,项目名称:nistats,代码行数:53,代码来源:gen_rst.py


示例20: save_frames

def save_frames(source, vertices, images_dir):
    print('Saving frames...')
    if not os.path.isdir(images_dir):
        os.makedirs(images_dir)
    bar = IncrementalBar(max=len(vertices))
    angle_change = 360 // len(vertices)
    for i, v in enumerate(vertices):
        update(source, v, angle_change=angle_change)
        mlab.savefig(filename=os.path.join(images_dir, frame_fn(i)))
        bar.next()
    bar.finish()
    mlab.close()
开发者ID:DrXuQian,项目名称:template_ffd,代码行数:12,代码来源:sup_vid.py



注:本文中的mayavi.mlab.close函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python mlab.colorbar函数代码示例发布时间:2022-05-27
下一篇:
Python mlab.clf函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap