コード例 #1
0
ファイル: obs_vector.py プロジェクト: oyvindeide/ert
    def getNode(self, index):
        """@rtype: SummaryObservation or BlockObservation or GenObservation"""

        pointer = self._iget_node(index)

        node_type = self.getImplementationType()
        if node_type == EnkfObservationImplementationType.SUMMARY_OBS:
            return SummaryObservation.createCReference(pointer, self)
        elif node_type == EnkfObservationImplementationType.BLOCK_OBS:
            return BlockObservation.createCReference(pointer, self)
        elif node_type == EnkfObservationImplementationType.GEN_OBS:
            return GenObservation.createCReference(pointer, self)
        else:
            raise AssertionError("Node type '%s' currently not supported!" % node_type)
コード例 #2
0
ファイル: test_enkf.py プロジェクト: oysteoh/ert
    def test_observations(self):
        with TestAreaContext("enkf_test") as work_area:
            work_area.copy_directory(self.case_directory)

            res_config = ResConfig("simple_config/minimum_config")
            main = EnKFMain(res_config)

            count = 10
            summary_key = "test_key"
            observation_key = "test_obs_key"
            summary_observation_node = EnkfConfigNode.createSummaryConfigNode(
                summary_key, LoadFailTypeEnum.LOAD_FAIL_EXIT)
            observation_vector = ObsVector(
                EnkfObservationImplementationType.SUMMARY_OBS,
                observation_key,
                summary_observation_node,
                count,
            )

            main.getObservations().addObservationVector(observation_vector)

            values = []
            for index in range(0, count):
                value = index * 10.5
                std = index / 10.0
                summary_observation_node = SummaryObservation(
                    summary_key, observation_key, value, std)
                observation_vector.installNode(index, summary_observation_node)
                self.assertEqual(observation_vector.getNode(index),
                                 summary_observation_node)
                self.assertEqual(value, summary_observation_node.getValue())
                values.append((index, value, std))

            observations = main.getObservations()
            test_vector = observations[observation_key]
            index = 0
            for node in test_vector:
                self.assertTrue(isinstance(node, SummaryObservation))
                self.assertEqual(node.getValue(), index * 10.5)
                index += 1

            self.assertEqual(observation_vector, test_vector)
            for index, value, std in values:
                self.assertTrue(test_vector.isActive(index))

                summary_observation_node = test_vector.getNode(index)
                """@type: SummaryObservation"""

                self.assertEqual(value, summary_observation_node.getValue())
                self.assertEqual(
                    std, summary_observation_node.getStandardDeviation())
                self.assertEqual(summary_key,
                                 summary_observation_node.getSummaryKey())