예제 #1
0
    def __getitem__(self, index):
        return_arg = super(Ecl3DFile, self).__getitem__(index)
        if isinstance(return_arg,list):
            kw_list = return_arg
        else:
            kw_list = [return_arg]

        # Go through all the keywords and try inplace promotion to Ecl3DKW
        for kw in kw_list:
            try:
                Ecl3DKW.castFromKW(kw, self.grid)
            except ValueError:
                pass

        return return_arg
예제 #2
0
    def __getitem__(self, index):
        return_arg = super(Ecl3DFile, self).__getitem__(index)
        if isinstance(return_arg, list):
            kw_list = return_arg
        else:
            kw_list = [return_arg]

        # Go through all the keywords and try inplace promotion to Ecl3DKW
        for kw in kw_list:
            try:
                Ecl3DKW.castFromKW(kw, self.grid)
            except ValueError:
                pass

        return return_arg
예제 #3
0
    def test_region_filter(self):
        nx = 10
        ny = 10
        nz = 1
        actnum = IntVector( initial_size = nx*ny*nz , default_value = 1 )
        actnum[nx*ny - 1] = 0

        grid = EclGrid.createRectangular( (nx,ny,nz) , (1,1,1) , actnum = actnum)
        self.assertEqual( grid.getNumActive() , nx*ny*nz - 1 )

        kw = Ecl3DKW.create( "REGIONS" , grid , EclDataType.ECL_INT , global_active = True )
        kw.assign( 0 )
        kw[0:int(nx*ny/2)] = 1
        kw[5,2,0] = 0
        kw[0,9,0] = 2

        kw.fixUninitialized( grid )

        # Not assigned because they are in contact with a '2'; these
        # two are problem cells.
        self.assertEqual( kw[0,ny - 2,0] , 0)
        self.assertEqual( kw[1,ny - 1,0] , 0)

        # Not assigned because it is inactive
        self.assertEqual( kw[nx - 1,ny - 1,0] , 0)

        self.assertEqual( kw[5,2,0] , 1 )
        for j in range(5,10):
            self.assertEqual( kw[5,j,0] , 1 )

        for i in range(10):
            self.assertEqual( kw[i,7,0] , 1 )
예제 #4
0
    def test_Load( self ):
        kw = EclKW.read_grdecl(copen(self.src_file, "r"), "PERMX")
        self.assertTrue(kw)

        grid = EclGrid( self.createTestPath("Statoil/ECLIPSE/Gurbat/ECLIPSE" ))
        kw = Ecl3DKW.read_grdecl(grid , copen(self.src_file, "r"), "PERMX")
        self.assertTrue( isinstance( kw , Ecl3DKW ))
예제 #5
0
    def test_setitem(self):
        actnum = IntVector(default_value=1, initial_size=1000)
        for i in range(100):
            actnum[i] = 0

        grid = EclGrid.createRectangular((10, 10, 10), (1, 1, 1),
                                         actnum=actnum)
        kw = Ecl3DKW("KW", grid, EclDataType.ECL_FLOAT, default_value=77)

        with self.assertRaises(IndexError):
            kw[1000]

        with self.assertRaises(IndexError):
            kw[0, 10, 100]

        with self.assertRaises(ValueError):
            kw[1, 1]

        with self.assertRaises(ValueError):
            kw[1, 1, 1, 1]

        kw.assign(99)
        self.assertEqual(kw[0, 0, 0], 77)
        self.assertEqual(kw[0, 0, 1], 99)

        with self.assertRaises(ValueError):
            kw[0, 0, 0] = 88

        kw[0, 0, 1] = 100
        self.assertEqual(kw[0, 0, 1], 100)
예제 #6
0
    def test_Load(self):
        kw = EclKW.read_grdecl(copen(self.src_file, "r"), "PERMX")
        self.assertTrue(kw)

        grid = EclGrid(self.createTestPath("Statoil/ECLIPSE/Gurbat/ECLIPSE"))
        kw = Ecl3DKW.read_grdecl(grid, copen(self.src_file, "r"), "PERMX")
        self.assertTrue(isinstance(kw, Ecl3DKW))
예제 #7
0
    def test_create(self):
        actnum = IntVector(default_value=1, initial_size=1000)
        for i in range(100):
            actnum[i] = 0

        grid = EclGrid.createRectangular((10, 10, 10), (1, 1, 1),
                                         actnum=actnum)
        kw = Ecl3DKW("KW", grid, EclDataType.ECL_FLOAT)
        self.assertEqual(len(kw), grid.getNumActive())

        self.assertEqual((10, 10, 10), kw.dims())
예제 #8
0
    def test_cast(self):
        actnum = IntVector(default_value=1, initial_size=1000)
        for i in range(100):
            actnum[i] = 0

        grid = EclGrid.createRectangular((10, 10, 10), (1, 1, 1),
                                         actnum=actnum)
        kw_wrong_size = EclKW("KW", 27, EclDataType.ECL_FLOAT)
        kw_global_size = EclKW("KW", grid.getGlobalSize(),
                               EclDataType.ECL_FLOAT)
        kw_active_size = EclKW("KW", grid.getNumActive(),
                               EclDataType.ECL_FLOAT)

        with self.assertRaises(ValueError):
            Ecl3DKW.castFromKW(kw_wrong_size, grid)

        Ecl3DKW.castFromKW(kw_global_size, grid)
        self.assertTrue(isinstance(kw_global_size, Ecl3DKW))

        Ecl3DKW.castFromKW(kw_active_size, grid, default_value=66)
        self.assertTrue(isinstance(kw_active_size, Ecl3DKW))

        self.assertEqual(kw_active_size[0, 0, 0], 66)
        with self.assertRaises(ValueError):
            kw_active_size[0, 0, 0] = 88
예제 #9
0
파일: ots.py 프로젝트: oddvarlia/semeio
    def dpv(self, vintage_pairs):
        """
        Calulates change in pressure multiplied by cell volume
        and sum for all cells in column

        dPV must have equal sign as TS, but opposite from mathematics

        monitor-base

        :param vintage_pairs: list of pairs of vintages
        :return:
        """

        if len(vintage_pairs) < 1:
            return 0, []

        vintages = self._vintages_name_date(vintage_pairs)

        surf = self._surface
        points_to_calculate = self._get_non_nan_points()

        shift_surfaces = []
        pressure_volume = {}

        for vintage in vintages:
            logging.info("{:%x %X} DPV: Calculating vintage"
                         " {:%Y.%m.%d}".format(dt.now(), vintage.date))
            self.add_survey(vintage.name, vintage.date)
            pressure = Ecl3DKW.castFromKW(
                self._restart_views[vintage.name]["PRESSURE"][0], self._grid)
            pressure_volume[vintage.date] = np.zeros(len(surf))

            for point in points_to_calculate:
                r = surf.x[point], surf.y[point], 0
                try:
                    i, j = self._grid.findCellXY(*r)
                    sum_pv = 0
                    for k in range(self._grid.getNZ()):
                        v = self._grid.cell_volume(ijk=(i, j, k))
                        sum_pv += pressure[i, j, k] * v

                    pressure_volume[vintage.date][point] = sum_pv
                except ValueError:
                    pressure_volume[vintage.date][point] = 0

        for base, monitor in vintage_pairs:
            self._report("DPV", base, monitor, len(points_to_calculate))
            dpv = ((pressure_volume[monitor] - pressure_volume[base]) / 1e9 *
                   self._convention)
            shift_surfaces.append(self._create_surface(dpv))

        return shift_surfaces
예제 #10
0
    def test_create_global_size(self):
        actnum = IntVector(default_value=1, initial_size=1000)
        for i in range(100):
            actnum[i] = 0

        grid = EclGrid.createRectangular((10, 10, 10), (1, 1, 1),
                                         actnum=actnum)
        kw = Ecl3DKW("KW", grid, EclDataType.ECL_FLOAT, global_active=True)
        self.assertEqual(len(kw), grid.getGlobalSize())

        kw.assign(50)
        self.assertEqual(kw[0, 0, 0], 50)

        kw[0, 0, 0] = 45
        self.assertEqual(kw[0, 0, 0], 45)
예제 #11
0
    def test_fix_uninitialized(self):
        nx = 10
        ny = 11
        nz = 12
        grid = EclGrid.createRectangular((nx, ny, nz), (1, 1, 1))
        kw = Ecl3DKW("REGIONS", grid, EclDataType.ECL_INT, global_active=True)
        kw.assign(3)
        self.assertEqual(3 * nx * ny * nz, sum(kw))

        kw[1, 1, 1] = 0
        kw[3, 3, 3] = 0
        kw[6, 6, 6] = 0

        self.assertEqual(3 * nx * ny * nz - 9, sum(kw))
        kw.fixUninitialized(grid)
        self.assertEqual(3 * nx * ny * nz, sum(kw))
예제 #12
0
    def test_compressed_copy(self):
        actnum = IntVector(default_value=1, initial_size=1000)
        for i in range(500):
            actnum[2 * i + 1] = 0

        grid = EclGrid.createRectangular((10, 10, 10), (1, 1, 1),
                                         actnum=actnum)
        kw = Ecl3DKW("KW", grid, EclDataType.ECL_INT, global_active=True)
        for i in range(len(kw)):
            kw[i] = i

        kw_copy = kw.compressedCopy()
        self.assertTrue(isinstance(kw_copy, EclKW))

        self.assertEqual(len(kw_copy), 500)
        for i in range(len(kw_copy)):
            self.assertEqual(kw_copy[i], 2 * i)
예제 #13
0
    def test_cast(self):
        actnum = IntVector(default_value = 1 , initial_size = 1000)
        for i in range(100):
            actnum[i] = 0

        grid = EclGrid.createRectangular( (10,10,10) , (1,1,1) , actnum = actnum)
        kw_wrong_size  = EclKW( "KW" , 27 , EclDataType.ECL_FLOAT )
        kw_global_size = EclKW( "KW" , grid.getGlobalSize() , EclDataType.ECL_FLOAT )
        kw_active_size = EclKW( "KW" , grid.getNumActive()  , EclDataType.ECL_FLOAT )
        
        with self.assertRaises(ValueError):
            Ecl3DKW.castFromKW(kw_wrong_size , grid)

        Ecl3DKW.castFromKW(kw_global_size , grid)
        self.assertTrue( isinstance( kw_global_size , Ecl3DKW))

        Ecl3DKW.castFromKW(kw_active_size , grid , default_value = 66)
        self.assertTrue( isinstance( kw_active_size , Ecl3DKW))

        self.assertEqual( kw_active_size[0,0,0] , 66)
        with self.assertRaises(ValueError):
            kw_active_size[0,0,0] = 88
예제 #14
0
 def test_default(self):
     grid = EclGrid.createRectangular((10, 10, 10), (1, 1, 1))
     kw = Ecl3DKW("KW", grid, EclDataType.ECL_FLOAT)
     kw.setDefault(55)
     self.assertTrue(55, kw.getDefault())