本文整理汇总了Python中ert.ecl.EclFile类的典型用法代码示例。如果您正苦于以下问题:Python EclFile类的具体用法?Python EclFile怎么用?Python EclFile使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了EclFile类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_geertsma_kernel_2_source_points_2_vintages
def test_geertsma_kernel_2_source_points_2_vintages():
grid = EclGrid.createRectangular(dims=(2, 1, 1), dV=(100, 100, 100))
with TestAreaContext("Subsidence"):
p1 = [1, 10]
p2 = [10, 20]
create_restart(grid, "TEST", p1, p2)
create_init(grid, "TEST")
init = EclFile("TEST.INIT")
restart_file = EclFile("TEST.UNRST")
restart_view1 = restart_file.restartView(sim_time=datetime.date(2000, 1, 1))
restart_view2 = restart_file.restartView(sim_time=datetime.date(2010, 1, 1))
subsidence = EclSubsidence(grid, init)
subsidence.add_survey_PRESSURE("S1", restart_view1)
subsidence.add_survey_PRESSURE("S2", restart_view2)
youngs_modulus = 5E8
poisson_ratio = 0.3
seabed = 0
receiver = (1000, 1000, 0)
dz1 = subsidence.evalGeertsma("S1", None, receiver, youngs_modulus, poisson_ratio, seabed)
np.testing.assert_almost_equal(dz1, -5.538064265738908e-05)
dz2 = subsidence.evalGeertsma("S2", None, receiver, youngs_modulus, poisson_ratio, seabed)
np.testing.assert_almost_equal(dz2, -1.456356233609781e-04)
np.testing.assert_almost_equal(dz2-dz1, -9.025498070358901e-05)
dz = subsidence.evalGeertsma("S1", "S2", receiver, youngs_modulus, poisson_ratio, seabed)
np.testing.assert_almost_equal(dz, -9.025498070358901e-05)
示例2: test_geertsma_kernel
def test_geertsma_kernel():
grid = EclGrid.createRectangular(dims=(1, 1, 1), dV=(50, 50, 50))
with TestAreaContext("Subsidence"):
p1 = [1]
create_restart(grid, "TEST", p1)
create_init(grid, "TEST")
init = EclFile("TEST.INIT")
restart_file = EclFile("TEST.UNRST")
restart_view1 = restart_file.restartView(sim_time=datetime.date(2000, 1, 1))
subsidence = EclSubsidence(grid, init)
subsidence.add_survey_PRESSURE("S1", restart_view1)
youngs_modulus = 5E8
poisson_ratio = 0.3
seabed = 0
above = 100
topres = 2000
receiver = (1000, 1000, 0)
dz = subsidence.evalGeertsma("S1", None, receiver, youngs_modulus, poisson_ratio, seabed)
np.testing.assert_almost_equal(dz, -1.256514072122196e-07)
receiver = (1000, 1000, topres - seabed - above)
dz = subsidence.evalGeertsma("S1", None, receiver, youngs_modulus, poisson_ratio, seabed)
np.testing.assert_almost_equal(dz, 6.530473913611929e-05)
示例3: test_fwrite
def test_fwrite( self ):
#work_area = TestArea("python/ecl_file/fwrite")
with TestAreaContext("python/ecl_file/fwrite"):
rst_file = EclFile(self.test_file)
fortio = FortIO("ECLIPSE.UNRST", FortIO.WRITE_MODE)
rst_file.fwrite(fortio)
fortio.close()
rst_file.close()
self.assertFilesAreEqual("ECLIPSE.UNRST", self.test_file)
示例4: test_report_list
def test_report_list(self):
rlist0 = range(63)
self.report_list_file_test(self.u_file, rlist0)
rlist0 = [0]
self.report_list_file_test(self.xfile0, rlist0)
f = EclFile(self.grid_file)
with self.assertRaises(ArgumentError): #argumentError wraps the expected TypeError
EclFile.file_report_list(f)
示例5: test_kw
def test_kw( self ):
f = EclFile(self.u_file)
kw1 = f["SWAT"][40]
kw2 = f.restart_get_kw("SWAT", datetime.datetime(2003, 3, 1))
kw3 = f.restart_get_kw("SWAT", datetime.datetime(2003, 3, 1), copy=True)
self.assertTrue(kw1.equal(kw2))
self.assertTrue(kw1.equal(kw3))
kw4 = f.restart_get_kw("SWAT", datetime.datetime(2009, 3, 1))
self.assertIsNone(kw4)
示例6: test_kw
def test_kw( self ):
f = EclFile(self.u_file)
kw1 = f["SWAT"][40]
kw2 = f.restart_get_kw("SWAT", datetime.datetime(2003, 3, 1))
kw3 = f.restart_get_kw("SWAT", datetime.datetime(2003, 3, 1), copy=True)
self.assertTrue(kw1.equal(kw2))
self.assertTrue(kw1.equal(kw3))
with self.assertRaises(IndexError):
kw4 = f.restart_get_kw("SWAT", datetime.datetime(2009, 3, 17))
示例7: report_file_test
def report_file_test(self, fname):
self.assertTrue(EclFile.contains_report_step(fname, 4))
self.assertTrue(EclFile.contains_report_step(fname, 0))
self.assertTrue(EclFile.contains_report_step(fname, 62))
self.assertFalse(EclFile.contains_report_step(fname, -1))
self.assertFalse(EclFile.contains_report_step(fname, 100))
f = EclFile(fname)
self.assertTrue(f.has_report_step(4))
self.assertTrue(f.has_report_step(0))
self.assertTrue(f.has_report_step(62))
self.assertFalse(f.has_report_step(-1))
self.assertFalse(f.has_report_step(100))
示例8: test_block_view
def test_block_view(self):
with TestAreaContext("python/ecl_file/view"):
with openFortIO("TEST" , mode = FortIO.WRITE_MODE) as f:
for i in range(5):
header = EclKW("HEADER" , 1 , EclTypeEnum.ECL_INT_TYPE )
header[0] = i
data1 = EclKW("DATA1" , 100 , EclTypeEnum.ECL_INT_TYPE )
data1.assign( i )
data2 = EclKW("DATA2" , 100 , EclTypeEnum.ECL_INT_TYPE )
data2.assign( i*10 )
header.fwrite( f )
data1.fwrite( f )
data2.fwrite( f )
ecl_file = EclFile("TEST")
with self.assertRaises(KeyError):
ecl_file.blockView("NO" , 1)
with self.assertRaises(IndexError):
ecl_file.blockView("HEADER" , 100)
for i in range(5):
view = ecl_file.blockView("HEADER" , i)
self.assertEqual( len(view) , 3)
header = view["HEADER"][0]
data1 = view["DATA1"][0]
data2 = view["DATA2"][0]
self.assertEqual( header[0] , i )
self.assertEqual( data1[99] , i )
self.assertEqual( data2[99] , i*10 )
for i in range(5):
view = ecl_file.blockView2("HEADER" , "DATA2", i )
self.assertEqual( len(view) , 2)
header = view["HEADER"][0]
data1 = view["DATA1"][0]
self.assertEqual( header[0] , i )
self.assertEqual( data1[99] , i )
self.assertFalse( "DATA2" in view )
view = ecl_file.blockView2("HEADER" , None, 0 )
self.assertEqual( len(view) , len(ecl_file))
view = ecl_file.blockView2(None , "DATA2", 0 )
示例9: report_list_file_test
def report_list_file_test(self, fname, rlist0):
rlist = EclFile.file_report_list(fname)
self.assertAlmostEqualList(rlist, rlist0)
f = EclFile(fname)
rlist = f.report_list
self.assertAlmostEqualList(rlist, rlist0)
示例10: __init__
def __init__(self , grid , filename , flags = 0):
"""Will open an Eclipse restart file.
The EclRestartFile class will open an eclipse restart file, in
unified or non unified format. The constructor will infer the
file type based on the filename, and will raise a ValueError
exception if the file type is not ECL_RESTART_FILE or
ECL_UNIFIED_RESTART_FILE.
The EclRestartFile will use a grid reference to create Ecl3DKw
instances for all the keyword elements which have either
'nactive' or 'nx*ny*nz' elements.
"""
file_type , report_step , fmt_file = EclFile.getFileType( filename )
if not file_type in [EclFileEnum.ECL_RESTART_FILE, EclFileEnum.ECL_UNIFIED_RESTART_FILE]:
raise ValueError("The input filename:%s does not correspond to a restart file - please follow the Eclipse naming conventions" % filename)
super(EclRestartFile , self).__init__( grid, filename , flags)
self.rst_headers = None
if file_type == EclFileEnum.ECL_RESTART_FILE:
self.is_unified = False
self.report_step = report_step
else:
self.is_unified = True
示例11: test_date
def test_date(self):
f = EclFile(self.u_file)
self.assertTrue(f.has_sim_time(datetime.datetime(2001, 6, 1)))
self.assertFalse(f.has_sim_time(datetime.datetime(2005, 6, 1)))
self.assertFalse(f.has_sim_time(datetime.datetime(1999, 6, 1)))
self.assertFalse(f.has_sim_time(datetime.datetime(2001, 6, 11)))
self.assertTrue(EclFile.contains_sim_time(self.u_file, datetime.datetime(2001, 6, 1)))
self.assertFalse(EclFile.contains_sim_time(self.u_file, datetime.datetime(2005, 6, 1)))
self.assertFalse(EclFile.contains_sim_time(self.u_file, datetime.datetime(1999, 6, 1)))
self.assertFalse(EclFile.contains_sim_time(self.u_file, datetime.datetime(2001, 6, 11)))
示例12: test_restart_days
def test_restart_days(self):
rst_file = EclFile( self.test_file )
self.assertAlmostEqual( 0.0 , rst_file.iget_restart_sim_days(0) )
self.assertAlmostEqual( 31.0 , rst_file.iget_restart_sim_days(1) )
self.assertAlmostEqual( 274.0 , rst_file.iget_restart_sim_days(10) )
with self.assertRaises(KeyError):
rst_file.restart_get_kw("Missing" , dtime = datetime.date( 2004,1,1))
with self.assertRaises(IndexError):
rst_file.restart_get_kw("SWAT" , dtime = datetime.date( 1985 , 1 , 1))
示例13: test_restart_view
def test_restart_view(self):
f = EclFile( self.test_file )
with self.assertRaises(ValueError):
v = f.restartView( )
v = f.restartView( sim_days = 274 )
v = f.restartView( sim_time = datetime.date( 2004,1,1) )
v = f.restartView( report_step = 30 )
v = f.restartView( seqnum_index = 30 )
示例14: test_kw_write
def test_kw_write(self):
with TestAreaContext("python/ecl_kw/writing"):
data = [random.random() for i in range(10000)]
kw = EclKW("TEST", len(data), EclTypeEnum.ECL_DOUBLE_TYPE)
i = 0
for d in data:
kw[i] = d
i += 1
fortio = FortIO("ECL_KW_TEST", FortIO.WRITE_MODE)
kw.fwrite(fortio)
fortio.close()
fortio = FortIO("ECL_KW_TEST")
kw2 = EclKW.fread(fortio)
self.assertTrue(kw.equal(kw2))
ecl_file = EclFile("ECL_KW_TEST", flags=EclFileFlagEnum.ECL_FILE_WRITABLE)
kw3 = ecl_file["TEST"][0]
self.assertTrue(kw.equal(kw3))
ecl_file.save_kw(kw3)
ecl_file.close()
fortio = FortIO("ECL_KW_TEST", FortIO.READ_AND_WRITE_MODE)
kw4 = EclKW.fread(fortio)
self.assertTrue(kw.equal(kw4))
fortio.seek(0)
kw4.fwrite(fortio)
fortio.close()
ecl_file = EclFile("ECL_KW_TEST")
kw5 = ecl_file["TEST"][0]
self.assertTrue(kw.equal(kw5))
示例15: test_ecl_file_block
def test_ecl_file_block(self):
with TestAreaContext("name") as t:
kw = EclKW("TEST", 3, EclTypeEnum.ECL_INT_TYPE)
with openFortIO("TEST" , mode = FortIO.WRITE_MODE) as f:
kw.fwrite( f )
t.sync()
f = EclFile( "TEST" )
with self.assertRaises(NotImplementedError):
f.select_block( "KW" , 100 )
with self.assertRaises(NotImplementedError):
f.select_global( )
with self.assertRaises(NotImplementedError):
f.select_restart_section( index = None , report_step = None , sim_time = None)
with self.assertRaises(NotImplementedError):
f.select_restart_section( )
with self.assertRaises(NotImplementedError):
EclFile.restart_block( "TEST" )