本文整理汇总了Python中ecl.eclfile.EclKW类的典型用法代码示例。如果您正苦于以下问题:Python EclKW类的具体用法?Python EclKW怎么用?Python EclKW使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了EclKW类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_broken_file
def test_broken_file(self):
with TestAreaContext("test_broken_file"):
with open("CASE.FINIT", "w") as f:
f.write("This - is not a ECLISPE file\nsdlcblhcdbjlwhc\naschscbasjhcasc\nascasck c s s aiasic asc")
f = EclFile("CASE.FINIT")
self.assertEqual(len(f), 0)
kw = EclKW("HEADER", 100, EclDataType.ECL_INT)
with openFortIO("FILE",mode=FortIO.WRITE_MODE) as f:
kw.fwrite(f)
kw.fwrite(f)
with open("FILE", "a+") as f:
f.write("Seom random gibberish")
f = EclFile("FILE")
self.assertEqual(len(f), 2)
with openFortIO("FILE",mode=FortIO.WRITE_MODE) as f:
kw.fwrite(f)
kw.fwrite(f)
file_size = os.path.getsize("FILE")
with open("FILE", "a+") as f:
f.truncate(file_size * 0.75)
f = EclFile("FILE")
self.assertEqual(len(f), 1)
示例2: test_sliced_set
def test_sliced_set(self):
kw = EclKW("REGIONS", 10, EclDataType.ECL_INT)
kw.assign(99)
kw[0:5] = 66
self.assertEqual(kw[0], 66)
self.assertEqual(kw[4], 66)
self.assertEqual(kw[5], 99)
示例3: test_scatter_copy
def test_scatter_copy(self):
source = EclKW("SOURCE", 4 , EclDataType.ECL_INT)
with self.assertRaises(TypeError):
copy = source.scatter_copy([1,1,1,1])
actnum = EclKW("ACTNUM", 6 , EclDataType.ECL_FLOAT)
with self.assertRaises(ValueError):
copy = source.scatter_copy(actnum)
actnum = EclKW("ACTNUM", 8, EclDataType.ECL_INT)
actnum[0] = 1
actnum[1] = 1
with self.assertRaises(ValueError):
copy = source.scatter_copy(actnum)
actnum.assign(1)
with self.assertRaises(ValueError):
copy = source.scatter_copy(actnum)
for i in range(4):
source[i] = i+1
actnum[2*i] = 0
# src = [1,2,3,4]
# actnum = [0,1,0,1,0,1,0,1]
# copy = [0,1,0,2,0,3,0,4]
copy = source.scatter_copy(actnum)
for i in range(4):
self.assertEqual(copy[2*i + 1], i+1)
示例4: test_long_name
def test_long_name(self):
with self.assertRaises(ValueError):
EclKW("LONGLONGNAME", 10, EclDataType.ECL_INT)
kw = EclKW("REGIONS", 10, EclDataType.ECL_INT)
with self.assertRaises(ValueError):
kw.name = "LONGLONGNAME"
示例5: test_name
def test_name(self):
kw = EclKW('TEST', 3, EclDataType.ECL_INT)
self.assertEqual(kw.name, 'TEST')
self.assertIn('TEST', repr(kw))
kw.name = 'SCHMEST'
self.assertEqual(kw.name, 'SCHMEST')
self.assertIn('SCHMEST', repr(kw))
示例6: test_EclFile_name_property
def test_EclFile_name_property(self):
with TestAreaContext("name") as t:
kw = EclKW("TEST", 3, EclDataType.ECL_INT)
with openFortIO("TEST" , mode = FortIO.WRITE_MODE) as f:
kw.fwrite( f )
t.sync()
f = EclFile( "TEST" )
示例7: test_min_max
def test_min_max(self):
kw = EclKW("TEST", 3, EclDataType.ECL_INT)
kw[0] = 10
kw[1] = 5
kw[2] = 0
self.assertEqual(10, kw.getMax())
self.assertEqual(0 , kw.getMin())
self.assertEqual((0,10) , kw.getMinMax())
示例8: loadGrid
def loadGrid(self):
grid_file = self.createTestPath("Statoil/ECLIPSE/Faults/grid.grdecl")
fileH = copen(grid_file, "r")
specgrid = EclKW.read_grdecl(fileH, "SPECGRID", ecl_type=EclDataType.ECL_INT, strict=False)
zcorn = EclKW.read_grdecl(fileH, "ZCORN")
coord = EclKW.read_grdecl(fileH, "COORD")
actnum = EclKW.read_grdecl(fileH, "ACTNUM", ecl_type=EclDataType.ECL_INT)
return EclGrid.create(specgrid, zcorn, coord, actnum)
示例9: test_fault_block_edge
def test_fault_block_edge(self):
grid = EclGrid.createRectangular( (5,5,1) , (1,1,1) )
kw = EclKW( "FAULTBLK" , grid.getGlobalSize() , EclDataType.ECL_INT )
kw.assign( 0 )
for j in range(1,4):
for i in range(1,4):
g = i + j*grid.getNX()
kw[g] = 1
layer = FaultBlockLayer( grid , 0 )
示例10: test_create
def test_create(self):
# The init file created here only contains a PORO field. More
# properties must be added to this before it can be used for
# any usefull gravity calculations.
poro = EclKW( "PORO" , self.grid.getGlobalSize() , EclDataType.ECL_FLOAT )
with TestAreaContext("grav_init"):
with openFortIO( "TEST.INIT" , mode = FortIO.WRITE_MODE ) as f:
poro.fwrite( f )
self.init = EclFile( "TEST.INIT")
grav = EclGrav( self.grid , self.init )
示例11: test_is_fortran_file
def test_is_fortran_file(self):
with TestAreaContext("python/fortio/guess"):
kw1 = EclKW("KW" , 12345 , EclDataType.ECL_FLOAT)
with openFortIO("fortran_file" , mode = FortIO.WRITE_MODE) as f:
kw1.fwrite( f )
with cwrap.open("text_file" , "w") as f:
kw1.write_grdecl( f )
self.assertTrue( FortIO.isFortranFile( "fortran_file" ))
self.assertFalse( FortIO.isFortranFile( "text_file" ))
示例12: test_fseek
def test_fseek( self ):
file = copen(self.src_file, "r")
self.assertTrue(EclKW.fseek_grdecl(file, "PERMX"))
self.assertFalse(EclKW.fseek_grdecl(file, "PERMY"))
file.close()
file = copen(self.src_file, "r")
kw1 = EclKW.read_grdecl(file, "PERMX")
self.assertFalse(EclKW.fseek_grdecl(file, "PERMX"))
self.assertTrue(EclKW.fseek_grdecl(file, "PERMX", rewind=True))
file.close()
示例13: create
def create(self, filename, load_actnum=True):
fileH = copen(filename, "r")
specgrid = EclKW.read_grdecl(fileH, "SPECGRID", ecl_type=EclDataType.ECL_INT, strict=False)
zcorn = EclKW.read_grdecl(fileH, "ZCORN")
coord = EclKW.read_grdecl(fileH, "COORD")
if load_actnum:
actnum = EclKW.read_grdecl(fileH, "ACTNUM", ecl_type=EclDataType.ECL_INT)
else:
actnum = None
mapaxes = EclKW.read_grdecl(fileH, "MAPAXES")
grid = EclGrid.create(specgrid, zcorn, coord, actnum, mapaxes=mapaxes)
return grid
示例14: test_ecl_kw_indexed_read
def test_ecl_kw_indexed_read(self):
with TestAreaContext("ecl_kw_indexed_read") as area:
fortio = FortIO("index_test", mode=FortIO.WRITE_MODE)
element_count = 100000
ecl_kw = EclKW("TEST", element_count, EclDataType.ECL_INT)
for index in range(element_count):
ecl_kw[index] = index
ecl_kw.fwrite(fortio)
fortio.close()
fortio = FortIO("index_test", mode=FortIO.READ_MODE)
new_ecl_kw = EclKW.fread(fortio)
for index in range(element_count):
self.assertEqual(new_ecl_kw[index], index)
index_map = IntVector()
index_map.append(2)
index_map.append(3)
index_map.append(5)
index_map.append(7)
index_map.append(11)
index_map.append(13)
index_map.append(313)
index_map.append(1867)
index_map.append(5227)
index_map.append(7159)
index_map.append(12689)
index_map.append(18719)
index_map.append(32321)
index_map.append(37879)
index_map.append(54167)
index_map.append(77213)
index_map.append(88843)
index_map.append(99991)
char_buffer = ctypes.create_string_buffer(len(index_map) * ctypes.sizeof(ctypes.c_int))
self._freadIndexedData(fortio, 24, EclDataType.ECL_INT, element_count, index_map, char_buffer)
int_buffer = ctypes.cast(char_buffer, ctypes.POINTER(ctypes.c_int))
for index, index_map_value in enumerate(index_map):
self.assertEqual(index_map_value, int_buffer[index])
示例15: make_field
def make_field(rng , grid , iens):
permx = EclKW.create( "PERMX" , grid.getGlobalSize( ) , EclTypeEnum.ECL_FLOAT_TYPE)
permx.assign( rng.getDouble( ) )
poro = EclKW.create( "PORO" , grid.getGlobalSize( ) , EclTypeEnum.ECL_FLOAT_TYPE)
poro.assign( rng.getDouble( ) )
if not os.path.isdir("fields"):
os.makedirs("fields")
with open("fields/permx%d.grdecl" % iens,"w") as f:
permx.write_grdecl( f )
with open("fields/poro%d.grdecl" % iens ,"w") as f:
poro.write_grdecl( f )