當前位置: 首頁>>代碼示例>>Python>>正文


Python mlab.contour3d方法代碼示例

本文整理匯總了Python中mayavi.mlab.contour3d方法的典型用法代碼示例。如果您正苦於以下問題:Python mlab.contour3d方法的具體用法?Python mlab.contour3d怎麽用?Python mlab.contour3d使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在mayavi.mlab的用法示例。


在下文中一共展示了mlab.contour3d方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: main

# 需要導入模塊: from mayavi import mlab [as 別名]
# 或者: from mayavi.mlab import contour3d [as 別名]
def main():
    mu = np.array([1, 10, 20])
    sigma = np.matrix([[20, 10, 10],
                       [10, 25, 1],
                       [10, 1, 50]])
    np.random.seed(100)
    data = np.random.multivariate_normal(mu, sigma, 1000)
    values = data.T

    kde = stats.gaussian_kde(values)

    # Create a regular 3D grid with 50 points in each dimension
    xmin, ymin, zmin = data.min(axis=0)
    xmax, ymax, zmax = data.max(axis=0)
    xi, yi, zi = np.mgrid[xmin:xmax:50j, ymin:ymax:50j, zmin:zmax:50j]

    # Evaluate the KDE on a regular grid...
    coords = np.vstack([item.ravel() for item in [xi, yi, zi]])
    density = kde(coords).reshape(xi.shape)

    # Visualize the density estimate as isosurfaces
    mlab.contour3d(xi, yi, zi, density, opacity=0.5)
    mlab.axes()
    mlab.show() 
開發者ID:kklmn,項目名稱:xrt,代碼行數:26,代碼來源:kde_mlab.py

示例2: plot_contour3d

# 需要導入模塊: from mayavi import mlab [as 別名]
# 或者: from mayavi.mlab import contour3d [as 別名]
def plot_contour3d(self, **kwargs):
        '''
        use mayavi.mlab to plot 3d contour.

        Parameter
        ---------
        kwargs: {
            'maxct'   : float,max contour number,
            'nct'     : int, number of contours,
            'opacity' : float, opacity of contour,
            'widths'   : tuple of int
                        number of replication on x, y, z axis,
        }
        '''
        if not mayavi_installed:
            self.__logger.warning("Mayavi is not installed on your device.")
            return
        # set parameters
        widths = kwargs['widths'] if 'widths' in kwargs else (1, 1, 1)
        elf_data, grid = self.expand_data(self.elf_data, self.grid, widths)
#        import pdb; pdb.set_trace()
        maxdata = np.max(elf_data)
        maxct = kwargs['maxct'] if 'maxct' in kwargs else maxdata
        # check maxct
        if maxct > maxdata:
            self.__logger.warning("maxct is larger than %f", maxdata)
        opacity = kwargs['opacity'] if 'opacity' in kwargs else 0.6
        nct = kwargs['nct'] if 'nct' in kwargs else 5
        # plot surface
        surface = mlab.contour3d(elf_data)
        # set surface attrs
        surface.actor.property.opacity = opacity
        surface.contour.maximum_contour = maxct
        surface.contour.number_of_contours = nct
        # reverse axes labels
        mlab.axes(xlabel='z', ylabel='y', zlabel='x')  # 是mlab參數順序問題?
        mlab.outline()
        mlab.show()

        return 
開發者ID:PytLab,項目名稱:VASPy,代碼行數:42,代碼來源:electro.py

示例3: process

# 需要導入模塊: from mayavi import mlab [as 別名]
# 或者: from mayavi.mlab import contour3d [as 別名]
def process(path):
    mrc = mrcfile.open(path)
    print(type(mrc.data))
    obj = contour3d(mrc.data, contours=10)
    obj.module_manager.source.save_output(savepath)
    return obj 
開發者ID:xulabs,項目名稱:aitom,代碼行數:8,代碼來源:contour.py

示例4: evolve_visual3d

# 需要導入模塊: from mayavi import mlab [as 別名]
# 或者: from mayavi.mlab import contour3d [as 別名]
def evolve_visual3d(msnake, levelset=None, num_iters=20):
    """
    Visual evolution of a three-dimensional morphological snake.

    Parameters
    ----------
    msnake : MorphGAC or MorphACWE instance
        The morphological snake solver.
    levelset : array-like, optional
        If given, the levelset of the solver is initialized to this. If not
        given, the evolution will use the levelset already set in msnake.
    num_iters : int, optional
        The number of iterations.
    """
    from mayavi import mlab
    # import matplotlib.pyplot as ppl

    if levelset is not None:
        msnake.levelset = levelset

    fig = mlab.gcf()
    mlab.clf()
    src = mlab.pipeline.scalar_field(msnake.data)
    mlab.pipeline.image_plane_widget(
        src, plane_orientation='x_axes', colormap='gray')
    cnt = mlab.contour3d(msnake.levelset, contours=[0.5])

    @mlab.animate(ui=True)
    def anim():
        for i in range(num_iters):
            msnake.step()
            cnt.mlab_source.scalars = msnake.levelset
            yield

    anim()
    mlab.show()

    # Return the last levelset.
    return msnake.levelset 
開發者ID:RivuletStudio,項目名稱:rivuletpy,代碼行數:41,代碼來源:soma.py


注:本文中的mayavi.mlab.contour3d方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。