예제 #1
0
    def test_sum(self):
        grid = EclGrid.createRectangular((10, 10, 1), (1, 1, 1))
        kw_mask = EclKW("INT", grid.getGlobalSize(), EclDataType.ECL_INT)
        int_value = EclKW("INT", grid.getGlobalSize(), EclDataType.ECL_INT)
        float_value = EclKW("FLOAT", grid.getGlobalSize(),
                            EclDataType.ECL_FLOAT)
        double_value = EclKW("DOUBLE", grid.getGlobalSize(),
                             EclDataType.ECL_DOUBLE)
        bool_value = EclKW("BOOL", grid.getGlobalSize(), EclDataType.ECL_BOOL)

        kw_mask[0:50] = 1

        for i in range(len(int_value)):
            float_value[i] = i
            double_value[i] = i
            int_value[i] = i
            bool_value[i] = True

        region = EclRegion(grid, False)
        region.select_equal(kw_mask, 1)

        self.assertEqual(int_value.sum(), 99 * 100 / 2)
        self.assertEqual(int_value.sum(mask=region), 49 * 50 / 2)
        self.assertEqual(double_value.sum(mask=region), 1.0 * 49 * 50 / 2)
        self.assertEqual(float_value.sum(mask=region), 1.0 * 49 * 50 / 2)
        self.assertEqual(bool_value.sum(mask=region), 50)
예제 #2
0
 def test_polygon(self):
     reg = EclRegion(self.grid, False)
     (x, y, z) = self.grid.get_xyz(ijk=(10, 10, 0))
     dx = 0.1
     dy = 0.1
     reg.select_inside_polygon([(x - dx, y - dy), (x - dx, y + dy),
                                (x + dx, y + dy), (x + dx, y - dy)])
     self.assertTrue(self.grid.getNZ() == len(reg.getGlobalList()))
예제 #3
0
    def test_kw_isub(self):
        P = self.rst_file["PRESSURE"][5]
        fipnum = self.init_file["FIPNUM"][0]
        fipnum_copy = fipnum.deep_copy()

        reg = EclRegion(self.grid, False)
        reg.select_more(P, 260)
        fipnum.sub(1, mask=reg)
        self.assertFalse(fipnum.equal(fipnum_copy))
        fipnum.add(1, mask=reg)
        self.assertTrue(fipnum.equal(fipnum_copy))
예제 #4
0
    def test_local_field(self):
        with ErtTestContext('python/enkf/data/local_config', self.field_config) as test_context:
            main = test_context.getErt()
            local_config = main.getLocalConfig()

            # Creating dataset
            data_scale = local_config.createDataset('DATA_SCALE')
            grid = local_config.getGrid()
            ecl_reg = EclRegion(grid, False)
            ecl_reg.select_islice(10, 20)
            data_scale.addField('PERMX', ecl_reg)
            self.assertEqual(1, len(data_scale))
예제 #5
0
    def test_equal(self):
        reg1 = EclRegion(self.grid, False)
        reg2 = EclRegion(self.grid, False)

        self.assertTrue(reg1 == reg2)

        reg1.select_islice(4, 6)
        self.assertFalse(reg1 == reg2)
        reg2.select_islice(4, 7)
        self.assertFalse(reg1 == reg2)
        reg1.select_islice(7, 7)
        self.assertTrue(reg1 == reg2)
예제 #6
0
파일: grid_info.py 프로젝트: OPM/ResInsight
def main(grid):
    vmin,vmax = volume_min_max(grid)

    dz_limit = 0.3
    region = EclRegion(grid, False)
    region.select_thin(dz_limit)

    print "Smallest cell     : %g" % vmin
    print "Largest cell      : %g" % vmax
    print "Thin active cells : %d" % region.active_size()

    for ai in region.get_active_list():
        c = grid.cell(active_index=ai)
        print('dz(%2d, %2d, %2d) = %.3f' % (c.i, c.j, c.k, c.dz))
예제 #7
0
    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())
예제 #8
0
    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( ))
예제 #9
0
    def test_equal(self):
        grid = EclGrid.createRectangular((10, 10, 1), (1, 1, 1))
        kw_int = EclKW("INT", grid.getGlobalSize(), EclDataType.ECL_INT)
        kw_float = EclKW("FLOAT", grid.getGlobalSize(), EclDataType.ECL_FLOAT)

        kw_int[0:49] = 1
        region = EclRegion(grid, False)
        region.select_equal(kw_int, 1)
        glist = region.getGlobalList()
        for g in glist:
            self.assertEqual(kw_int[g], 1)

        with self.assertRaises(ValueError):
            region.select_equal(kw_float, 1)
예제 #10
0
    def setUp(self):
        self.grid = EclGrid.createRectangular((10, 10, 10), (1, 1, 1))
        self.kw = EclKW("FAULTBLK", self.grid.getGlobalSize(),
                        EclDataType.ECL_INT)
        self.kw.assign(1)

        reg = EclRegion(self.grid, False)

        for k in range(self.grid.getNZ()):
            reg.clear()
            reg.select_kslice(k, k)
            self.kw.assign(k, mask=reg)
            self.kw[k * self.grid.getNX() * self.grid.getNY() + 7] = 177
예제 #11
0
def main(grid):
    vmin, vmax = volume_min_max(grid)

    dz_limit = 0.3
    region = EclRegion(grid, False)
    region.select_thin(dz_limit)

    print "Smallest cell     : %g" % vmin
    print "Largest cell      : %g" % vmax
    print "Thin active cells : %d" % region.active_size()

    for ai in region.get_active_list():
        c = grid.cell(active_index=ai)
        print('dz(%2d, %2d, %2d) = %.3f' % (c.i, c.j, c.k, c.dz))
예제 #12
0
파일: grid_info.py 프로젝트: mycarta/libecl

def volum_min_max(grid):
    vmin = 10000000
    vmax = 0
    for a in range(grid.getNumActive()):
        v = grid.cell_volume(active_index=a)
        vmin = min(vmin, v)
        vmax = max(vmax, v)

    return vmin, vmax


if __name__ == "__main__":
    case = sys.argv[1]
    grid = EclGrid(case)

    vmin, vmax = volum_min_max(grid)

    dz_limit = 0.1
    region = EclRegion(grid, False)
    region.select_thin(dz_limit)

    print "Smallest cell     : %g" % vmin
    print "Largest cell      : %g" % vmax
    print "Thin active cells : %d" % region.active_size()

    for ai in region.get_active_list():
        ijk = grid.get_ijk(active_index=ai)
        print ijk
예제 #13
0
    pv = grid.compressed_kw_copy( init_file["PORV"][0] )

    # Extract an integer region keyword from the init file
    region_kw = init_file["EQLNUM"][0]


    sim_days = []
    result = {}
    for header in rst_file.headers():
        line = {}
        rst_block = rst_file.restart_view( report_step = header.get_report_step( ) )
        p = rst_block["PRESSURE"][0]
        sw = rst_block["SWAT"][0]


        for region_id in range(region_kw.get_max( ) + 1):
            region = EclRegion( grid, False )
            region.select_equal( region_kw, region_id )
            avg_pressure( p, sw, pv , region, region_id, result)

        avg_pressure( p, sw, pv , EclRegion( grid, True ), "field", result)
        sim_days.append( header.get_sim_days( ) )


    for key in result.keys():
        plt.figure(1)
        for index,p in enumerate(result[key]):
            plt.plot( sim_days, p , label="Region:%s  P%d" % (key, index + 1))
        plt.legend()
        plt.show()
예제 #14
0
 def test_EclRegion_properties(self):
     grid = EclGridGenerator.createRectangular((10, 10, 10), (1, 1, 1))
     region = EclRegion(grid, False)
예제 #15
0
파일: case.py 프로젝트: pgdr/recl
 def _region(self, preselect=False):
     return EclRegion(self.grid, preselect=preselect)
예제 #16
0
    init_file = EclFile("%s.INIT" % case)

    # Create PORV keyword where all the inactive cells have been removed.
    pv = grid.compressed_kw_copy(init_file["PORV"][0])

    # Extract an integer region keyword from the init file
    region_kw = init_file["EQLNUM"][0]

    sim_days = []
    result = {}
    for header in rst_file.headers():
        line = {}
        rst_block = rst_file.restart_view(report_step=header.get_report_step())
        p = rst_block["PRESSURE"][0]
        sw = rst_block["SWAT"][0]

        for region_id in range(region_kw.get_max() + 1):
            region = EclRegion(grid, False)
            region.select_equal(region_kw, region_id)
            avg_pressure(p, sw, pv, region, region_id, result)

        avg_pressure(p, sw, pv, EclRegion(grid, True), "field", result)
        sim_days.append(header.get_sim_days())

    for key in result.keys():
        plt.figure(1)
        for index, p in enumerate(result[key]):
            plt.plot(sim_days, p, label="Region:%s  P%d" % (key, index + 1))
        plt.legend()
        plt.show()
예제 #17
0
    def test_slice(self):
        reg = EclRegion(self.grid, False)
        reg.select_islice(0, 5)
        OK = True

        global_list = reg.getGlobalList()
        self.assertEqual(global_list.parent(), reg)

        for gi in global_list:
            (i, j, k) = self.grid.get_ijk(global_index=gi)
            if i > 5:
                OK = False
        self.assertTrue(OK)
        self.assertTrue(self.grid.getNY() * self.grid.getNZ() *
                        6 == len(reg.getGlobalList()))

        reg.select_jslice(7, 8, intersect=True)
        OK = True
        for gi in reg.getGlobalList():
            (i, j, k) = self.grid.get_ijk(global_index=gi)
            if i > 5:
                OK = False

            if j < 7 or j > 8:
                OK = False

        self.assertTrue(OK)
        self.assertTrue(2 * self.grid.getNZ() * 6 == len(reg.getGlobalList()))

        reg2 = EclRegion(self.grid, False)
        reg2.select_kslice(3, 5)
        reg &= reg2
        OK = True
        for gi in reg.getGlobalList():
            (i, j, k) = self.grid.get_ijk(global_index=gi)
            if i > 5:
                OK = False

            if j < 7 or j > 8:
                OK = False

            if k < 3 or k > 5:
                OK = False

        self.assertTrue(OK)
        self.assertTrue(2 * 3 * 6 == len(reg.getGlobalList()))
예제 #18
0
 def test_index_list(self):
     reg = EclRegion(self.grid, False)
     reg.select_islice(0, 5)
     active_list = reg.getActiveList()
     global_list = reg.getGlobalList()
예제 #19
0
    def test_layer(self):
        region = EclRegion(self.grid, False)
        layer = Layer(self.grid.getNX(), self.grid.getNY() + 1)
        with self.assertRaises(ValueError):
            region.selectFromLayer(layer, 0, 1)

        layer = Layer(self.grid.getNX(), self.grid.getNY())
        layer[0, 0] = 1
        layer[1, 1] = 1
        layer[2, 2] = 1

        with self.assertRaises(ValueError):
            region.selectFromLayer(layer, -1, 1)

        with self.assertRaises(ValueError):
            region.selectFromLayer(layer, self.grid.getNZ(), 1)

        region.selectFromLayer(layer, 0, 2)
        glist = region.getGlobalList()
        self.assertEqual(0, len(glist))

        region.selectFromLayer(layer, 0, 1)
        glist = region.getGlobalList()
        self.assertEqual(3, len(glist))