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


Python grid.EclGrid类代码示例

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


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

示例1: test_cell_containment

    def test_cell_containment(self):

        grid_location = "local/ECLIPSE/faarikaal/faarikaal%d.EGRID"
        well_location = "local/ECLIPSE/faarikaal/faarikaal%d.txt"

        for i in range(1, 8):
            grid_file = self.createTestPath(grid_location % i)
            well_file = self.createTestPath(well_location % i)

            grid = EclGrid(grid_file)

            # Load well data
            with open(well_file, "r") as f:
                lines = [line.split() for line in f.readlines()]

            points = [map(float, line[:3:]) for line in lines]
            exp_cells = [tuple(map(int, line[3::])) for line in lines]

            msg = "Expected point %s to be in cell %s, was in %s."
            for point, exp_cell in zip(points, exp_cells):
                reported_cell = grid.find_cell(*point)
                self.assertEqual(
                        exp_cell,
                        reported_cell,
                        msg % (str(point), str(exp_cell), str(reported_cell))
                        )
开发者ID:OPM,项目名称:ResInsight,代码行数:26,代码来源:test_fk_user_data.py

示例2: test_actnum_extraction

    def test_actnum_extraction(self):
        dims = (4,4,4)

        coord = GridGen.create_coord(dims, (1,1,1))
        zcorn = GridGen.create_zcorn(dims, (1,1,1), offset=0)

        actnum = EclKW("ACTNUM", six.functools.reduce(operator.mul, dims),
                       EclDataType.ECL_INT)
        random.seed(1337)
        for i in range(len(actnum)):
            actnum[i] = random.randint(0, 1)

        grid = EclGrid.create(dims, zcorn, coord, actnum)

        ijk_bounds = generate_ijk_bounds(dims)
        for ijk_bound in ijk_bounds:
            if not decomposition_preserving(ijk_bound):
                continue

            sub = GridGen.extract_subgrid_data(
                                         dims,
                                         coord,
                                         zcorn,
                                         ijk_bound,
                                         actnum=actnum
                                       )

            sub_coord, sub_zcorn, sub_actnum = sub
            sub_dims = tuple([u-l+1 for l, u in ijk_bound])
            subgrid = EclGrid.create(sub_dims, sub_zcorn, sub_coord, sub_actnum)
            self.assertEqual(sub_dims, subgrid.getDims()[:-1:])
            self.assertSubgrid(grid, subgrid, ijk_bound)
开发者ID:OPM,项目名称:ResInsight,代码行数:32,代码来源:test_grid_generator.py

示例3: test_translation

    def test_translation(self):
        dims = (3,3,3)

        coord = GridGen.create_coord(dims, (1,1,1))
        zcorn = GridGen.create_zcorn(dims, (1,1,1), offset=0)
        grid = EclGrid.create(dims, zcorn, coord, None)

        ijk_bound = [(0, d-1) for d in dims]
        translation = (1, 2, 3)
        sub_coord, sub_zcorn, _ = GridGen.extract_subgrid_data(
                                                        dims,
                                                        coord,
                                                        zcorn,
                                                        ijk_bound,
                                                        translation=translation
                                                       )

        tgrid = EclGrid.create(dims, sub_zcorn, sub_coord, None)
        self.assertEqual(grid.getGlobalSize(), tgrid.getGlobalSize())

        for gi in range(grid.getGlobalSize()):
            translation = numpy.array(translation)
            corners = [grid.getCellCorner(i, gi) for i in range(8)]
            corners = [tuple(numpy.array(c)+translation) for c in corners]

            tcorners = [tgrid.getCellCorner(i, gi) for i in range(8)]

            self.assertEqual(corners, tcorners)
开发者ID:OPM,项目名称:ResInsight,代码行数:28,代码来源:test_grid_generator.py

示例4: test_output_units

    def test_output_units(self):
        n = 10
        a = 1
        grid = GridGen.createRectangular( (n,n,n), (a,a,a))

        with TestAreaContext("python/ecl_grid/units"):
            grid.save_EGRID( "CASE.EGRID" , output_unit = EclUnitTypeEnum.ECL_FIELD_UNITS )
            f = EclFile("CASE.EGRID")
            g = f["GRIDUNIT"][0]
            self.assertEqual( g[0].strip( ) , "FEET" )
            g2 = EclGrid("CASE.EGRID")
            self.assertFloatEqual( g2.cell_volume( global_index = 0 ) , 3.28084*3.28084*3.28084)


            grid.save_EGRID( "CASE.EGRID" )
            f = EclFile("CASE.EGRID")
            g = f["GRIDUNIT"][0]
            self.assertEqual( g[0].strip( ) , "METRES" )

            grid.save_EGRID( "CASE.EGRID" , output_unit = EclUnitTypeEnum.ECL_LAB_UNITS)
            f = EclFile("CASE.EGRID")
            g = f["GRIDUNIT"][0]
            self.assertEqual( g[0].strip() , "CM" )
            g2 = EclGrid("CASE.EGRID")
            self.assertFloatEqual( g2.cell_volume( global_index = 0 ) , 100*100*100 )
开发者ID:,项目名称:,代码行数:25,代码来源:

示例5: test_EGRID

 def test_EGRID( self ):
     grid = EclGrid(self.egrid_file())
     self.assertTrue(grid)
     dims = grid.getDims()
     self.assertEqual(dims[0] , grid.getNX())
     self.assertEqual(dims[1] , grid.getNY())
     self.assertEqual(dims[2] , grid.getNZ())
开发者ID:,项目名称:,代码行数:7,代码来源:

示例6: test_grdecl_load

    def test_grdecl_load(self):
        with self.assertRaises(IOError):
            grid = EclGrid.loadFromGrdecl("/file/does/not/exists")

        with TestAreaContext("python/grid-test/grdeclLoad"):
            with open("grid.grdecl","w") as f:
                f.write("Hei ...")

            with self.assertRaises(ValueError):
                grid = EclGrid.loadFromGrdecl("grid.grdecl")

            actnum = IntVector(default_value = 1 , initial_size = 1000)
            actnum[0] = 0
            g1 = EclGrid.createRectangular((10,10,10) , (1,1,1) , actnum = actnum )
            self.assertEqual( g1.getNumActive() , actnum.elementSum() )
            g1.save_EGRID("G.EGRID")

            with open("grid.grdecl" , "w") as f2:
                f2.write("SPECGRID\n")
                f2.write("  10  10  10  \'F\' /\n")

            with openEclFile("G.EGRID") as f:
                with copen("grid.grdecl" , "a") as f2:

                    coord_kw = f["COORD"][0]
                    coord_kw.write_grdecl( f2 )

                    zcorn_kw = f["ZCORN"][0]
                    zcorn_kw.write_grdecl( f2 )

                    actnum_kw = f["ACTNUM"][0]
                    actnum_kw.write_grdecl( f2 )

            g2 = EclGrid.loadFromGrdecl("grid.grdecl")
            self.assertTrue( g1.equal( g2 ))
开发者ID:,项目名称:,代码行数:35,代码来源:

示例7: test_num_active_large_memory

    def test_num_active_large_memory(self):
        case = self.createTestPath("Statoil/ECLIPSE/Gurbat/ECLIPSE")
        vecList = []
        for i in range(12500):
            vec = DoubleVector()
            vec[81920] = 0
            vecList.append(vec)

        grid1 = EclGrid(case)
        grid2 = EclGrid(case)
        self.assertEqual(grid1.getNumActive(), grid2.getNumActive())
        self.assertEqual(grid1.getNumActive(), 34770)
开发者ID:,项目名称:,代码行数:12,代码来源:

示例8: test_repr_and_name

 def test_repr_and_name(self):
     grid = GridGen.createRectangular((2,2,2), (10,10,10), actnum=[0,0,0,0,1,1,1,1])
     pfx = 'EclGrid('
     rep = repr(grid)
     self.assertEqual(pfx, rep[:len(pfx)])
     self.assertEqual(type(rep), type(''))
     self.assertEqual(type(grid.getName()), type(''))
     with TestAreaContext("python/ecl_grid/repr"):
         grid.save_EGRID("CASE.EGRID")
         g2 = EclGrid("CASE.EGRID")
         r2 = repr(g2)
         self.assertEqual(pfx, r2[:len(pfx)])
         self.assertEqual(type(r2), type(''))
         self.assertEqual(type(g2.getName()), type(''))
开发者ID:,项目名称:,代码行数:14,代码来源:

示例9: test_heidrun

    def test_heidrun(self):
        root = self.createTestPath("Statoil/ECLIPSE/Heidrun")
        grid = EclGrid( "%s/FF12_2013B2_AMAP_AOP-J15_NO62_MOVEX.EGRID" % root)

        polygon = []
        with open("%s/polygon.ply" % root) as fileH:
            for line in fileH.readlines():
                tmp = line.split()
                polygon.append( (float(tmp[0]) , float(tmp[1])))
        self.assertEqual( len(polygon) , 11 )

        reg = EclRegion( grid , False )
        reg.select_inside_polygon( polygon )
        self.assertEqual( 0 , len(reg.getGlobalList()) % grid.getNZ())
开发者ID:OPM,项目名称:ResInsight,代码行数:14,代码来源:test_region_statoil.py

示例10: test_rect

    def test_rect(self):
        with TestAreaContext("python/grid-test/testRect"):
            a1 = 1.0
            a2 = 2.0
            a3 = 3.0
            grid = EclGrid.createRectangular((9, 9, 9), (a1, a2, a3))
            grid.save_EGRID("rect.EGRID")
            grid2 = EclGrid("rect.EGRID")
            self.assertTrue(grid)
            self.assertTrue(grid2)

            (x, y, z) = grid.get_xyz(ijk=(4, 4, 4))
            self.assertAlmostEqualList([x, y, z], [4.5 * a1, 4.5 * a2, 4.5 * a3])

            v = grid.cell_volume(ijk=(4, 4, 4))
            self.assertFloatEqual(v, a1 * a2 * a3)

            z = grid.depth(ijk=(4, 4, 4 ))
            self.assertFloatEqual(z, 4.5 * a3)

            g1 = grid.global_index(ijk=(2, 2, 2))
            g2 = grid.global_index(ijk=(4, 4, 4))
            (dx, dy, dz) = grid.distance(g2, g1)
            self.assertAlmostEqualList([dx, dy, dz], [2 * a1, 2 * a2, 2 * a3])

            self.assertTrue(grid.cell_contains(2.5 * a1, 2.5 * a2, 2.5 * a3, ijk=(2, 2, 2)))
开发者ID:,项目名称:,代码行数:26,代码来源:

示例11: test_get_ijk

    def test_get_ijk(self):
        with TestAreaContext("python/fault_block_layer/neighbour") as work_area:
            with open("kw.grdecl","w") as fileH:
                fileH.write("FAULTBLK \n")
                fileH.write("1 1 1 0 0\n")
                fileH.write("1 2 2 0 3\n")
                fileH.write("4 2 2 3 3\n")
                fileH.write("4 4 4 0 0\n")
                fileH.write("4 4 4 0 5\n")
                fileH.write("/\n")
            with cwrap.open("kw.grdecl") as f:
                kw = EclKW.read_grdecl(
                    f, "FAULTBLK", ecl_type=EclDataType.ECL_INT)

        grid = EclGrid.createRectangular( (5,5,1) , (1,1,1) )
        layer = FaultBlockLayer( grid , 0 )
        layer.loadKeyword( kw )

        block = layer[0,0]
        self.assertEqual( block.getBlockID() , 1 )

        block = layer[2,2]
        self.assertEqual( block.getBlockID() , 2 )

        with self.assertRaises(ValueError):
            layer[3,3]

        with self.assertRaises(IndexError):
            layer[5,5]
开发者ID:OPM,项目名称:ResInsight,代码行数:29,代码来源:test_fault_blocks.py

示例12: make_grid

def make_grid( ):
    grid = EclGrid.createRectangular( (nx,ny,nz) , (1,1,1) )
    if not os.path.isdir("grid"):
        os.makedirs("grid")
    grid.save_EGRID("grid/CASE.EGRID")

    return grid
开发者ID:berland,项目名称:ert,代码行数:7,代码来源:make_data.py

示例13: test_extend_to_polyline

    def test_extend_to_polyline(self):
        grid = EclGrid.createRectangular( (3,3,1) , (1 , 1 , 1))

        #  o   o   o   o
        #               
        #  o---o---o---o
        #  
        #  o===+   o   o
        #  |   
        #  o   o   o   o

        fault1 = Fault(grid , "Fault")

        fault1.addRecord(0 , 0 , 0 , 0 , 0 , 0 , "X-")
        fault1.addRecord(0 , 0 , 0 , 0 , 0 , 0 , "Y")

        polyline = CPolyline( init_points = [(0,2) , (3,2)])
        points = fault1.extendToPolyline( polyline , 0 )
        self.assertEqual( points , [(1,1) , (2,2)])

        end_join = fault1.endJoin( polyline , 0 )
        self.assertEqual( end_join, [(1,1) , (0,2)] )
        
        polyline2 = CPolyline( init_points = [(0.8,2) , (0.8,0.8)])
        end_join = fault1.endJoin( polyline2 , 0 )
        self.assertIsNone( end_join )
开发者ID:OPM,项目名称:ResInsight,代码行数:26,代码来源:test_faults.py

示例14: test_truth_and_size

    def test_truth_and_size(self):
        actnum = IntVector( initial_size = 100, default_value = 0)
        actnum[0:50] = 1
        grid = EclGrid.createRectangular( (10,10,1) , (1,1,1), actnum = actnum)
        region = EclRegion(grid, False)

        self.assertFalse( region )
        self.assertEqual( 0, region.active_size( ))
        self.assertEqual( 0, region.global_size( ))

        region.select_all( )
        self.assertTrue( region )
        self.assertEqual( 50, region.active_size( ))
        self.assertEqual( 100, region.global_size( ))
        
        region.deselect_all()
        self.assertFalse( region )
        self.assertEqual( 0, region.active_size( ))
        self.assertEqual( 0, region.global_size( ))
        
        region = EclRegion(grid, False)
        region.select_inactive()
        self.assertTrue( region )
        self.assertEqual( 0 , region.active_size( ))
        self.assertEqual( 50, region.global_size( ))
开发者ID:OPM,项目名称:ResInsight,代码行数:25,代码来源:test_region.py

示例15: test_contact2

    def test_contact2(self):
        nx = 10
        ny = 10
        layer = Layer(nx,ny)
        grid = EclGrid.createRectangular( (nx,ny,1) , (1,1,1) )

        # Too short
        with self.assertRaises(ValueError):
            layer.addIJBarrier( [(1,5)] )

        # Out of range
        with self.assertRaises(ValueError):
            layer.addIJBarrier( [(10,15),(5,5)] )

        # Out of range
        with self.assertRaises(ValueError):
            layer.addIJBarrier( [(7,7),(-5,5)] )
            
        # Must have either i1 == i2 or j1 == j2
        with self.assertRaises(ValueError):
            layer.addIJBarrier( [(7,8),(6,5)] )

        p1 = (0 , 4)
        p2 = (0 , 5)
        self.assertTrue(layer.cellContact( p1 , p2 ))
        layer.addIJBarrier( [(0,5) , (nx , 5)] )
        self.assertFalse(layer.cellContact( p1 , p2 ))
开发者ID:OPM,项目名称:ResInsight,代码行数:27,代码来源:test_layer.py


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