Beispiel #1
0
    def test_summary_observation_collector(self):

        with ErtTestContext("python/enkf/export/summary_observation_collector", self.config) as context:

            ert = context.getErt()

            self.assertTrue(SummaryObservationCollector.summaryKeyHasObservations(ert, "FOPR"))
            self.assertFalse(SummaryObservationCollector.summaryKeyHasObservations(ert, "FOPT"))

            keys = SummaryObservationCollector.getAllObservationKeys(ert)
            self.assertTrue("FOPR" in keys)
            self.assertTrue("WOPR:OP1" in keys)
            self.assertFalse("WOPR:OP2" in keys)

            data = SummaryObservationCollector.loadObservationData(ert, "default_0")

            self.assertFloatEqual(data["FOPR"]["2010-01-10"],  0.001696887)
            self.assertFloatEqual(data["STD_FOPR"]["2010-01-10"], 0.1)

            self.assertFloatEqual(data["WOPR:OP1"]["2010-03-31"], 0.1)
            self.assertFloatEqual(data["STD_WOPR:OP1"]["2010-03-31"], 0.05)


            with self.assertRaises(KeyError):
                fgir = data["FGIR"]


            data = SummaryObservationCollector.loadObservationData(ert, "default_0", ["WOPR:OP1"])

            self.assertFloatEqual(data["WOPR:OP1"]["2010-03-31"], 0.1)
            self.assertFloatEqual(data["STD_WOPR:OP1"]["2010-03-31"], 0.05)

            with self.assertRaises(KeyError):
                data["FOPR"]
Beispiel #2
0
def test_summary_collector():
    res_config = ResConfig("snake_oil.ert")
    ert = EnKFMain(res_config)
    summary = EclSum("refcase/SNAKE_OIL_FIELD.UNSMRY")
    data = SummaryObservationCollector.loadObservationData(ert, "default_0")

    assert (data["FOPR"].values.tolist() == summary.numpy_vector(
        "FOPRH", report_only=True).tolist())
Beispiel #3
0
def test_ahmanalysis_run_field(test_data_root, grid_prop):
    """test data_set with scalar and Field parameters"""
    test_data_dir = os.path.join(test_data_root, "snake_oil")

    shutil.copytree(test_data_dir, "test_data")
    os.chdir(os.path.join("test_data"))
    os.makedirs("fields")
    grid = EclGridGenerator.createRectangular((10, 12, 5), (1, 1, 1))
    for iens in range(10):
        grid_prop("PERMX", 10, grid.getGlobalSize(), "fields/permx%d.grdecl" % iens)
        grid_prop("PORO", 0.2, grid.getGlobalSize(), "fields/poro%d.grdecl" % iens)

    res_config = ResConfig("snake_oil_field.ert")
    res_config.convertToCReference(None)
    ert = EnKFMain(res_config)

    ahmanalysis.AhmAnalysisJob(ert).run(prior_name="default")

    # assert that this returns/generates the delta field parameter
    gen_obs_list = GenDataObservationCollector.getAllObservationKeys(ert)
    summary_obs_list = SummaryObservationCollector.getAllObservationKeys(ert)
    obs_keys = gen_obs_list + summary_obs_list
    output_deltafield = os.path.join(
        "storage",
        "snake_oil_field",
        "reports",
        "default",
        "AhmAnalysisJob",
        "delta_fieldPERMX.csv",
    )
    assert os.path.isfile(output_deltafield)
    delta_df = pd.read_csv(output_deltafield, index_col=0)
    assert len(delta_df.columns) == 8 + (len(obs_keys) * 2) + 1
    # check field parameter is present and not empty in the final KS matrix
    output_ks = output_deltafield.replace("delta_fieldPERMX.csv", "ks.csv")
    ks_df = pd.read_csv(output_ks, index_col=0)
    assert not ks_df.empty
    assert "FIELD_PERMX" in ks_df.index.tolist()
    check_empty = ks_df.loc[["FIELD_PERMX"], :].isnull().all(axis=1)
    assert not check_empty["FIELD_PERMX"]
Beispiel #4
0
 def load_observation_data(self, case_name, keys=None):
     return SummaryObservationCollector.loadObservationData(
         self._enkf_main, case_name, keys)
Beispiel #5
0
 def gatherSummaryObservationData(ert, case, key):
     if ert.getKeyManager().isKeyWithObservations(key):
         return SummaryObservationCollector.loadObservationData(ert, case, [key]).dropna()
     else:
         return DataFrame()