当前位置: 首页>>代码示例>>Python>>正文


Python pyvista.UnstructuredGrid方法代码示例

本文整理汇总了Python中pyvista.UnstructuredGrid方法的典型用法代码示例。如果您正苦于以下问题:Python pyvista.UnstructuredGrid方法的具体用法?Python pyvista.UnstructuredGrid怎么用?Python pyvista.UnstructuredGrid使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pyvista的用法示例。


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

示例1: test_get_array

# 需要导入模块: import pyvista [as 别名]
# 或者: from pyvista import UnstructuredGrid [as 别名]
def test_get_array():
    grid = pyvista.UnstructuredGrid(ex.hexbeamfile)
    # add array to both point/cell data with same name
    carr = np.random.rand(grid.n_cells)
    grid._add_cell_array(carr, 'test_data')
    parr = np.random.rand(grid.n_points)
    grid._add_point_array(parr, 'test_data')
    # add other data
    oarr = np.random.rand(grid.n_points)
    grid._add_point_array(oarr, 'other')
    farr = np.random.rand(grid.n_points * grid.n_cells)
    grid._add_field_array(farr, 'field_data')
    assert np.allclose(carr, helpers.get_array(grid, 'test_data', preference='cell'))
    assert np.allclose(parr, helpers.get_array(grid, 'test_data', preference='point'))
    assert np.allclose(oarr, helpers.get_array(grid, 'other'))
    assert helpers.get_array(grid, 'foo') is None
    assert helpers.get_array(grid, 'test_data', preference='field') is None
    assert np.allclose(farr, helpers.get_array(grid, 'field_data', preference='field')) 
开发者ID:pyvista,项目名称:pyvista,代码行数:20,代码来源:test_utilities.py

示例2: test_threshold_percent

# 需要导入模块: import pyvista [as 别名]
# 或者: from pyvista import UnstructuredGrid [as 别名]
def test_threshold_percent():
    percents = [25, 50, [18.0, 85.0], [19.0, 80.0], 0.70]
    inverts = [False, True, False, True, False]
    # Only test data sets that have arrays
    for i, dataset in enumerate(DATASETS[0:3]):
        thresh = dataset.threshold_percent(percent=percents[i], invert=inverts[i])
        assert thresh is not None
        assert isinstance(thresh, pyvista.UnstructuredGrid)
    dataset = examples.load_uniform()
    result = dataset.threshold_percent(0.75, scalars='Spatial Cell Data')
    with pytest.raises(ValueError):
        result = dataset.threshold_percent(20000)
    with pytest.raises(ValueError):
        result = dataset.threshold_percent(0.0)
    # allow Sequence but not Iterable
    with pytest.raises(TypeError):
        dataset.threshold_percent({18.0, 85.0}) 
开发者ID:pyvista,项目名称:pyvista,代码行数:19,代码来源:test_filters.py

示例3: triangulate

# 需要导入模块: import pyvista [as 别名]
# 或者: from pyvista import UnstructuredGrid [as 别名]
def triangulate(dataset, inplace=False):
        """Return an all triangle mesh.

        More complex polygons will be broken down into triangles.

        Parameters
        ----------
        inplace : bool, optional
            Updates mesh in-place while returning ``None``.

        Return
        ------
        mesh : pyvista.UnstructuredGrid
            Mesh containing only triangles. ``None`` when ``inplace=True``

        """
        alg = vtk.vtkDataSetTriangleFilter()
        alg.SetInputData(dataset)
        alg.Update()

        mesh = _get_output(alg)
        if inplace:
            dataset.overwrite(mesh)
        else:
            return mesh 
开发者ID:pyvista,项目名称:pyvista,代码行数:27,代码来源:filters.py

示例4: test_pyvista

# 需要导入模块: import pyvista [as 别名]
# 或者: from pyvista import UnstructuredGrid [as 别名]
def test_pyvista(self):
        mesh = self.srf_structured.to_pyvista()
        self.assertIsInstance(mesh, pv.RectilinearGrid)
        mesh = self.srf_unstructured.to_pyvista()
        self.assertIsInstance(mesh, pv.UnstructuredGrid) 
开发者ID:GeoStat-Framework,项目名称:GSTools,代码行数:7,代码来源:test_export.py

示例5: test_read

# 需要导入模块: import pyvista [as 别名]
# 或者: from pyvista import UnstructuredGrid [as 别名]
def test_read(tmpdir):
    fnames = (ex.antfile, ex.planefile, ex.hexbeamfile, ex.spherefile,
              ex.uniformfile, ex.rectfile)
    types = (pyvista.PolyData, pyvista.PolyData, pyvista.UnstructuredGrid,
             pyvista.PolyData, pyvista.UniformGrid, pyvista.RectilinearGrid)
    for i, filename in enumerate(fnames):
        obj = fileio.read(filename)
        assert isinstance(obj, types[i])
    # Now test the standard_reader_routine
    for i, filename in enumerate(fnames):
        # Pass attrs to for the standard_reader_routine to be used
        obj = fileio.read(filename, attrs={'DebugOn': None})
        assert isinstance(obj, types[i])
    # this is also tested for each mesh types init from file tests
    filename = str(tmpdir.mkdir("tmpdir").join('tmp.%s' % 'npy'))
    arr = np.random.rand(10, 10)
    np.save(filename, arr)
    with pytest.raises(IOError):
        _ = pyvista.read(filename)
    # read non existing file
    with pytest.raises(IOError):
        _ = pyvista.read('this_file_totally_does_not_exist.vtk')
    # Now test reading lists of files as multi blocks
    multi = pyvista.read(fnames)
    assert isinstance(multi, pyvista.MultiBlock)
    assert multi.n_blocks == len(fnames)
    nested = [ex.planefile,
              [ex.hexbeamfile, ex.uniformfile]]

    multi = pyvista.read(nested)
    assert isinstance(multi, pyvista.MultiBlock)
    assert multi.n_blocks == 2
    assert isinstance(multi[1], pyvista.MultiBlock)
    assert multi[1].n_blocks == 2 
开发者ID:pyvista,项目名称:pyvista,代码行数:36,代码来源:test_utilities.py

示例6: test_progress_monitor

# 需要导入模块: import pyvista [as 别名]
# 或者: from pyvista import UnstructuredGrid [as 别名]
def test_progress_monitor():
    mesh = pyvista.Sphere()
    ugrid = mesh.delaunay_3d(progress_bar=True)
    assert isinstance(ugrid, pyvista.UnstructuredGrid) 
开发者ID:pyvista,项目名称:pyvista,代码行数:6,代码来源:test_utilities.py

示例7: test_download_blood_vessels

# 需要导入模块: import pyvista [as 别名]
# 或者: from pyvista import UnstructuredGrid [as 别名]
def test_download_blood_vessels():
        """Tests the parallel VTU reader"""
        data = examples.download_blood_vessels()
        assert isinstance(data, pyvista.UnstructuredGrid) 
开发者ID:pyvista,项目名称:pyvista,代码行数:6,代码来源:test_examples.py

示例8: test_clip_filter

# 需要导入模块: import pyvista [as 别名]
# 或者: from pyvista import UnstructuredGrid [as 别名]
def test_clip_filter():
    """This tests the clip filter on all datatypes available filters"""
    for i, dataset in enumerate(DATASETS):
        clp = dataset.clip(normal=normals[i], invert=True)
        assert clp is not None
        if isinstance(dataset, pyvista.PolyData):
            assert isinstance(clp, pyvista.PolyData)
        else:
            assert isinstance(clp, pyvista.UnstructuredGrid) 
开发者ID:pyvista,项目名称:pyvista,代码行数:11,代码来源:test_filters.py

示例9: test_clip_surface

# 需要导入模块: import pyvista [as 别名]
# 或者: from pyvista import UnstructuredGrid [as 别名]
def test_clip_surface():
    surface = pyvista.Cone(direction=(0,0,-1),
                           height=3.0, radius=1, resolution=50, )
    xx = yy = zz = 1 - np.linspace(0, 51, 11) * 2 / 50
    dataset = pyvista.RectilinearGrid(xx, yy, zz)
    clipped = dataset.clip_surface(surface, invert=False)
    assert isinstance(clipped, pyvista.UnstructuredGrid)
    clipped = dataset.clip_surface(surface, invert=False, compute_distance=True)
    assert isinstance(clipped, pyvista.UnstructuredGrid)
    assert 'implicit_distance' in clipped.array_names
    clipped = dataset.clip_surface(surface.cast_to_unstructured_grid(),)
    assert isinstance(clipped, pyvista.UnstructuredGrid)
    assert 'implicit_distance' in clipped.array_names 
开发者ID:pyvista,项目名称:pyvista,代码行数:15,代码来源:test_filters.py

示例10: test_threshold

# 需要导入模块: import pyvista [as 别名]
# 或者: from pyvista import UnstructuredGrid [as 别名]
def test_threshold():
    for i, dataset in enumerate(DATASETS[0:3]):
        thresh = dataset.threshold()
        assert thresh is not None
        assert isinstance(thresh, pyvista.UnstructuredGrid)
    # Test value ranges
    dataset = examples.load_uniform() # UniformGrid
    thresh = dataset.threshold(100, invert=False)
    assert thresh is not None
    assert isinstance(thresh, pyvista.UnstructuredGrid)
    thresh = dataset.threshold([100, 500], invert=False)
    assert thresh is not None
    assert isinstance(thresh, pyvista.UnstructuredGrid)
    thresh = dataset.threshold([100, 500], invert=True)
    assert thresh is not None
    assert isinstance(thresh, pyvista.UnstructuredGrid)
    # allow Sequence but not Iterable
    with pytest.raises(TypeError):
        dataset.threshold({100, 500})
    # Now test DATASETS without arrays
    with pytest.raises(ValueError):
        for i, dataset in enumerate(DATASETS[3:-1]):
            thresh = dataset.threshold()
            assert thresh is not None
            assert isinstance(thresh, pyvista.UnstructuredGrid)
    dataset = examples.load_uniform()
    with pytest.raises(ValueError):
        dataset.threshold([10, 100, 300]) 
开发者ID:pyvista,项目名称:pyvista,代码行数:30,代码来源:test_filters.py

示例11: test_delaunay_2d

# 需要导入模块: import pyvista [as 别名]
# 或者: from pyvista import UnstructuredGrid [as 别名]
def test_delaunay_2d():
    mesh = DATASETS[2].delaunay_2d()  # UnstructuredGrid
    assert isinstance(mesh, pyvista.PolyData)
    assert mesh.n_points 
开发者ID:pyvista,项目名称:pyvista,代码行数:6,代码来源:test_filters.py

示例12: test_triangulate

# 需要导入模块: import pyvista [as 别名]
# 或者: from pyvista import UnstructuredGrid [as 别名]
def test_triangulate():
    data = examples.load_uniform()
    tri = data.triangulate()
    assert isinstance(tri, pyvista.UnstructuredGrid)
    assert np.any(tri.cells) 
开发者ID:pyvista,项目名称:pyvista,代码行数:7,代码来源:test_filters.py

示例13: test_init_from_structured

# 需要导入模块: import pyvista [as 别名]
# 或者: from pyvista import UnstructuredGrid [as 别名]
def test_init_from_structured(struct_grid):
    unstruct_grid = pyvista.UnstructuredGrid(struct_grid)
    assert unstruct_grid.points.shape[0] == struct_grid.x.size
    assert np.all(unstruct_grid.celltypes == 12) 
开发者ID:pyvista,项目名称:pyvista,代码行数:6,代码来源:test_grid.py

示例14: test_init_from_unstructured

# 需要导入模块: import pyvista [as 别名]
# 或者: from pyvista import UnstructuredGrid [as 别名]
def test_init_from_unstructured(hexbeam):
    grid = pyvista.UnstructuredGrid(hexbeam, deep=True)
    grid.points += 1
    assert not np.any(grid.points == hexbeam.points) 
开发者ID:pyvista,项目名称:pyvista,代码行数:6,代码来源:test_grid.py

示例15: test_init_bad_input

# 需要导入模块: import pyvista [as 别名]
# 或者: from pyvista import UnstructuredGrid [as 别名]
def test_init_bad_input():
    with pytest.raises(TypeError):
        unstruct_grid = pyvista.UnstructuredGrid(np.array(1))

    with pytest.raises(TypeError):
        unstruct_grid = pyvista.UnstructuredGrid(np.array(1),
                                                 np.array(1),
                                                 np.array(1),
                                                 'woa') 
开发者ID:pyvista,项目名称:pyvista,代码行数:11,代码来源:test_grid.py


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