def test_save_fmt(self): self.addFile("/tmp/ECLIPSE.FUNRST") shutil.copyfile(fmt_file, "/tmp/ECLIPSE.FUNRST") rst_file = ecl.EclFile("/tmp/ECLIPSE.FUNRST", flags=ecl.ECL_FILE_WRITABLE) swat0 = rst_file["SWAT"][0] swat0.assign(0.75) rst_file.save_kw(swat0) rst_file.close() self.assertFalse(file_equal("/tmp/ECLIPSE.FUNRST", fmt_file)) rst_file1 = ecl.EclFile(fmt_file) rst_file2 = ecl.EclFile("/tmp/ECLIPSE.FUNRST", flags=ecl.ECL_FILE_WRITABLE) swat1 = rst_file1["SWAT"][0] swat2 = rst_file2["SWAT"][0] swat2.assign(swat1) rst_file2.save_kw(swat2) self.assertTrue(swat1.equal(swat2)) rst_file1.close() rst_file2.close() # Random failure .... self.assertTrue(file_equal("/tmp/ECLIPSE.FUNRST", fmt_file))
def test_fwrite(self): self.addFile("/tmp/ECLIPSE.UNRST") rst_file = ecl.EclFile(file) fortio = ecl.FortIO.writer("/tmp/ECLIPSE.UNRST") rst_file.fwrite(fortio) fortio.close() rst_file.close() self.assertTrue(file_equal("/tmp/ECLIPSE.UNRST", file))
def test_fwrite( self ): work_area = TestArea("python/ecl_file/fwrite") rst_file = ecl.EclFile( test_path(file) ) fortio = ecl.FortIO.writer("ECLIPSE.UNRST") rst_file.fwrite( fortio ) fortio.close() rst_file.close() self.assertTrue( file_equal( "ECLIPSE.UNRST" , test_path(file)) )
def test_write_loop(self): self.sched_file.write( "/tmp/schedule1" , 62) sched_file2 = sched.SchedFile( "/tmp/schedule1" , start_time) sched_file2.write( "/tmp/schedule2" , 62) self.assertTrue( file_equal( "/tmp/schedule1" , "/tmp/schedule2") ) self.addFile( "/tmp/schedule1" ) self.addFile( "/tmp/schedule2" )
def test_fwrite( self ): self.addFile( "/tmp/ECLIPSE.UNRST" ) rst_file = ecl.EclFile( file ) fortio = ecl.FortIO.writer("/tmp/ECLIPSE.UNRST") rst_file.fwrite( fortio ) fortio.close() rst_file.close() self.assertTrue( file_equal( "/tmp/ECLIPSE.UNRST" , file ) )
def test_save_fmt(self): work_area = TestArea("python/ecl_file/save_fmt") work_area.copy_file( test_path( test_path(fmt_file ))) rst_file = ecl.EclFile( "ECLIPSE.FUNRST" , flags = ecl.ECL_FILE_WRITABLE) swat0 = rst_file["SWAT"][0] swat0.assign( 0.75 ) rst_file.save_kw( swat0 ) rst_file.close( ) self.assertFalse( file_equal( "ECLIPSE.FUNRST" , test_path(fmt_file)) ) rst_file1 = ecl.EclFile( test_path(fmt_file) ) rst_file2 = ecl.EclFile( "ECLIPSE.FUNRST" , flags = ecl.ECL_FILE_WRITABLE) swat1 = rst_file1["SWAT"][0] swat2 = rst_file2["SWAT"][0] swat2.assign( swat1 ) rst_file2.save_kw( swat2 ) self.assertTrue( swat1.equal( swat2 )) rst_file1.close() rst_file2.close() # Random failure .... self.assertTrue( file_equal( "ECLIPSE.FUNRST" , test_path(fmt_file)) )
def test_save_fmt(self): self.addFile( "/tmp/ECLIPSE.FUNRST" ) shutil.copyfile( fmt_file , "/tmp/ECLIPSE.FUNRST" ) rst_file = ecl.EclFile( "/tmp/ECLIPSE.FUNRST" , flags = ecl.ECL_FILE_WRITABLE) swat0 = rst_file["SWAT"][0] swat0.assign( 0.75 ) rst_file.save_kw( swat0 ) rst_file.close( ) self.assertFalse( file_equal( "/tmp/ECLIPSE.FUNRST" , fmt_file ) ) rst_file1 = ecl.EclFile( fmt_file ) rst_file2 = ecl.EclFile( "/tmp/ECLIPSE.FUNRST" , flags = ecl.ECL_FILE_WRITABLE) swat1 = rst_file1["SWAT"][0] swat2 = rst_file2["SWAT"][0] swat2.assign( swat1 ) rst_file2.save_kw( swat2 ) self.assertTrue( swat1.equal( swat2 )) rst_file1.close() rst_file2.close() # Random failure .... self.assertTrue( file_equal( "/tmp/ECLIPSE.FUNRST" , fmt_file ) )
def testReLoad(self): kw = ecl.EclKW.read_grdecl(open(src_file, "r"), "PERMX") tmp_file1 = "/tmp/permx1.grdecl" tmp_file2 = "/tmp/permx2.grdecl" self.addFile(tmp_file1) self.addFile(tmp_file2) fileH = open(tmp_file1, "w") kw.write_grdecl(fileH) fileH.close() kw1 = ecl.EclKW.read_grdecl(open(tmp_file1, "r"), "PERMX") fileH = open(tmp_file2, "w") kw1.write_grdecl(fileH) fileH.close() self.assertTrue(file_equal(tmp_file1, tmp_file2))
def testReLoad( self ): kw = ecl.EclKW.read_grdecl( open( src_file , "r") , "PERMX") tmp_file1 = "/tmp/permx1.grdecl" tmp_file2 = "/tmp/permx2.grdecl" self.addFile( tmp_file1 ) self.addFile( tmp_file2 ) fileH = open( tmp_file1 , "w") kw.write_grdecl( fileH ) fileH.close() kw1 = ecl.EclKW.read_grdecl( open( tmp_file1 , "r") , "PERMX") fileH = open( tmp_file2 , "w") kw1.write_grdecl( fileH ) fileH.close() self.assertTrue( file_equal( tmp_file1 , tmp_file2 ))