def test_gen_data_collector(self):
        config = self.createTestPath("local/custom_kw/mini_config")
        with ErtTestContext("python/enkf/export/gen_data_observation_collector", config) as context:
            ert = context.getErt()

            obs_key = GenDataObservationCollector.getObservationKeyForDataKey(ert, "PERLIN", 1)
            self.assertEqual(obs_key, "GEN_PERLIN_1")

            obs_key = GenDataObservationCollector.getObservationKeyForDataKey(ert, "PERLIN", 2)
            self.assertEqual(obs_key, "GEN_PERLIN_2")

            obs_key = GenDataObservationCollector.getObservationKeyForDataKey(ert, "PERLIN", 3)
            self.assertEqual(obs_key, "GEN_PERLIN_3")

            obs_key = GenDataObservationCollector.getObservationKeyForDataKey(ert, "PERLIN", 4)
            self.assertIsNone(obs_key)

            obs_key = GenDataObservationCollector.getObservationKeyForDataKey(ert, "PERLINk", 1)
            self.assertIsNone(obs_key)

            data = GenDataObservationCollector.loadGenDataObservations(ert, "default", "GEN_PERLIN_1")

            self.assertFloatEqual(data["GEN_PERLIN_1"][0], -0.616789)
            self.assertFloatEqual(data["STD_GEN_PERLIN_1"][0], 0.2)

            with self.assertRaises(KeyError):
                GenDataObservationCollector.loadGenDataObservations(ert, "default", "GEN_PERLIN_4")
예제 #2
0
    def gatherGenDataObservationData(ert, case, key_with_report_step):
        """ :rtype: pandas.DataFrame """
        key, report_step = key_with_report_step.split("@", 1)
        report_step = int(report_step)

        obs_key = GenDataObservationCollector.getObservationKeyForDataKey(ert, key, report_step)

        if obs_key is not None:
            obs_data = GenDataObservationCollector.loadGenDataObservations(ert, case, [obs_key])
            columns = {obs_key: key_with_report_step, "STD_%s" % obs_key: "STD_%s" % key_with_report_step}
            obs_data = obs_data.rename(columns=columns)
        else:
            obs_data = DataFrame()

        return obs_data.dropna()
    def test_gen_data_collector(self):
        config = self.createTestPath("local/custom_kw/mini_config")
        with ErtTestContext(
                "python/enkf/export/gen_data_observation_collector",
                config) as context:
            ert = context.getErt()

            obs_key = GenDataObservationCollector.getObservationKeyForDataKey(
                ert, "PERLIN", 1)
            self.assertEqual(obs_key, "GEN_PERLIN_1")

            obs_key = GenDataObservationCollector.getObservationKeyForDataKey(
                ert, "PERLIN", 2)
            self.assertEqual(obs_key, "GEN_PERLIN_2")

            obs_key = GenDataObservationCollector.getObservationKeyForDataKey(
                ert, "PERLIN", 3)
            self.assertEqual(obs_key, "GEN_PERLIN_3")

            obs_key = GenDataObservationCollector.getObservationKeyForDataKey(
                ert, "PERLIN", 4)
            self.assertIsNone(obs_key)

            obs_key = GenDataObservationCollector.getObservationKeyForDataKey(
                ert, "PERLINk", 1)
            self.assertIsNone(obs_key)

            data = GenDataObservationCollector.loadGenDataObservations(
                ert, "default", ["GEN_PERLIN_1", "GEN_PERLIN_3"])

            self.assertFloatEqual(data["GEN_PERLIN_1"][0], -0.616789)
            self.assertFloatEqual(data["STD_GEN_PERLIN_1"][0], 0.2)

            with self.assertRaises(KeyError):
                data["GEN_PERLIN_2"]
예제 #4
0
        key, report_step = key.split("@", 1)
        report_step = int(report_step)
        try:
            data = GenDataCollector.loadGenData(ert, case, key, report_step)
        except ValueError:
            data = DataFrame()

        return data.dropna()  # removes all rows that has a NaN

    @staticmethod
    def gatherGenDataObservationData(ert, case, key_with_report_step):
        """ :rtype: pandas.DataFrame """
        key, report_step = key_with_report_step.split("@", 1)
        report_step = int(report_step)

        obs_key = GenDataObservationCollector.getObservationKeyForDataKey(
            ert, key, report_step)

        if obs_key is not None:
            obs_data = GenDataObservationCollector.loadGenDataObservations(
                ert, case, obs_key)
            columns = {
                obs_key: key_with_report_step,
                "STD_%s" % obs_key: "STD_%s" % key_with_report_step
            }
            obs_data = obs_data.rename(columns=columns)
        else:
            obs_data = DataFrame()

        return obs_data.dropna()

    @staticmethod