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
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
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
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
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