Пример #1
0
    def test_load(self):
        with TestAreaContext("runpath_list"):
            with self.assertRaises(IOError):
                rp = RunpathList("")

            node0 = RunpathNode(0, 0, "path0", "base0")
            node1 = RunpathNode(1, 1, "path1", "base1")

            runpath_list = RunpathList("filex.list")
            with self.assertRaises(IOError):
                runpath_list.load()

            with open("invalid_file", "w") as f:
                f.write("X X X X\n")

            rp = RunpathList("invalid_file")
            with self.assertRaises(IOError):
                rp.load()

            rp = RunpathList("list.txt")
            rp.add(node0.realization, node0.iteration, node0.runpath,
                   node0.basename)
            rp.add(node1.realization, node1.iteration, node1.runpath,
                   node1.basename)
            rp.export()
            self.assertTrue(os.path.isfile("list.txt"))

            rp2 = RunpathList("list.txt")
            rp2.load()
            self.assertEqual(len(rp2), 2)
            self.assertEqual(rp2[0], node0)
            self.assertEqual(rp2[1], node1)
Пример #2
0
#!/usr/bin/env python
import sys
import os

from ecl.eclfile import EclFile

from res.enkf import RunpathList


def calc_volume(basename):
    init = EclFile("{}.INIT".format(basename))
    porv_kw = init["PORV"][0]
    return porv_kw.sum()


runpath_list = RunpathList(sys.argv[1])
runpath_list.load()

volume_list = []
for node in runpath_list:
    volume = calc_volume(os.path.join(node.runpath, node.basename))
    volume_list.append((node.realization, volume))

print("Realization :     Volume")
print("------------------------")
for iens, volume in volume_list:
    print("        {:3d} : {:10}".format(iens, volume))
print("------------------------")