Пример #1
0
 def test_without_gen_kw(self):
     case_directory = self.createTestPath('local/snake_oil_no_data/')
     with TestAreaContext('test_enkf_runpath',
                          store_area=True) as work_area:
         work_area.copy_directory(case_directory)
         res_config = ResConfig('snake_oil_no_data/snake_oil_no_gen_kw.ert')
         main = EnKFMain(res_config)
         iactive = BoolVector(initial_size=main.getEnsembleSize(),
                              default_value=False)
         iactive[0] = True
         fs = main.getEnkfFsManager().getCurrentFileSystem()
         run_context = main.getRunContextENSEMPLE_EXPERIMENT(fs, iactive)
         main.createRunpath(run_context)
         self.assertDirectoryExists(
             'storage/snake_oil_no_gen_kw/runpath/realisation-0/iter-0')
         self.assertFileDoesNotExist(
             'storage/snake_oil_no_gen_kw/runpath/realisation-0/iter-0/parameters.txt'
         )
         self.assertEqual(
             len(os.listdir('storage/snake_oil_no_gen_kw/runpath')), 1)
         self.assertEqual(
             len(
                 os.listdir(
                     'storage/snake_oil_no_gen_kw/runpath/realisation-0')),
             1)
Пример #2
0
    def test_with_gen_kw(self):
        case_directory = self.createTestPath("local/snake_oil_no_data/")
        with TestAreaContext("test_enkf_runpath",
                             store_area=True) as work_area:
            work_area.copy_directory(case_directory)
            res_config = ResConfig("snake_oil_no_data/snake_oil.ert")
            main = EnKFMain(res_config)
            iactive = BoolVector(initial_size=main.getEnsembleSize(),
                                 default_value=False)
            iactive[0] = True
            fs = main.getEnkfFsManager().getCurrentFileSystem()
            run_context = main.getRunContextENSEMPLE_EXPERIMENT(fs, iactive)
            main.createRunpath(run_context)
            self.assertFileExists(
                "snake_oil_no_data/storage/snake_oil/runpath/realisation-0/iter-0/parameters.txt"
            )
            self.assertEqual(
                len(os.listdir("snake_oil_no_data/storage/snake_oil/runpath")),
                1)
            self.assertEqual(
                len(
                    os.listdir(
                        "snake_oil_no_data/storage/snake_oil/runpath/realisation-0"
                    )),
                1,
            )

            rp = main.create_runpath_list()
            self.assertEqual(len(rp), 0)
            rp.load()
            self.assertEqual(len(rp), 1)
Пример #3
0
def test_with_gen_kw(copy_case):
    copy_case("local/snake_oil")
    shutil.rmtree("storage")
    res_config = ResConfig("snake_oil.ert")
    main = EnKFMain(res_config)
    fs = main.getEnkfFsManager().getCurrentFileSystem()
    run_context = main.getRunContextENSEMPLE_EXPERIMENT(fs, [True])
    main.createRunpath(run_context)
    assert os.path.exists("storage/snake_oil/"
                          "runpath/realization-0/iter-0/parameters.txt")
    assert len(os.listdir("storage/snake_oil/runpath")) == 1
    assert len(os.listdir("storage/snake_oil/runpath/realization-0")) == 1

    rp = main.create_runpath_list()
    assert len(rp) == 0
    rp.load()
    assert len(rp), 1
Пример #4
0
def test_without_gen_kw(copy_case):
    copy_case("local/snake_oil")

    with fileinput.input("snake_oil.ert", inplace=True) as fin:
        for line in fin:
            if line.startswith("GEN_KW"):
                continue
            print(line, end="")
    shutil.rmtree("storage")
    assert "GEN_KW" not in Path("snake_oil.ert").read_text("utf-8")
    res_config = ResConfig("snake_oil.ert")
    main = EnKFMain(res_config)
    fs = main.getEnkfFsManager().getCurrentFileSystem()
    run_context = main.getRunContextENSEMPLE_EXPERIMENT(fs, [True])
    main.createRunpath(run_context)
    assert os.path.exists("storage/snake_oil/runpath/realization-0/iter-0")
    assert not os.path.exists(
        "storage/snake_oil/runpath/realization-0/iter-0/parameters.txt")
    assert len(os.listdir("storage/snake_oil/runpath")) == 1
    assert len(os.listdir("storage/snake_oil/runpath/realization-0")) == 1