def test_obs_block_scale_std(self): with ErtTestContext("obs_test_scale", self.config_file) as test_context: ert = test_context.getErt() fs = ert.getEnkfFsManager().getCurrentFileSystem() active_list = IntVector() active_list.initRange(0, ert.getEnsembleSize(), 1) obs = ert.getObservations() obs_data = LocalObsdata("OBSxx", obs) obs_vector = obs["WWCT:OP_1"] obs_data.addObsVector(obs_vector) scale_factor = obs.scaleCorrelatedStd(fs, obs_data, active_list) for obs_node in obs_vector: for index in range(len(obs_node)): self.assertEqual(scale_factor, obs_node.getStdScaling(index))
def create_active_lists(enkf_observations, events): """ Will add observation vectors to observation data. Returns a list of tuples mirroring the user config but also containing the active list where the scaling factor will be applied. """ new_events = [] observation_data = LocalObsdata("some_name", enkf_observations) for event in events: observation_data.addObsVector(enkf_observations[event.key]) obs_index = _data_index_to_obs_index(enkf_observations, event.key, event.index) new_active_list = _get_active_list(observation_data, event.key, obs_index) new_events.append(_make_tuple(event.key, event.index, new_active_list)) return new_events
def test_scale_obs(self): with ErtTestContext("obs_test", self.config_file) as test_context: ert = test_context.getErt() obs = ert.getObservations() obs1 = obs["WWCT:OP_1"].getNode(50) obs2 = obs["WWCT:OP_1_50"].getNode(50) self.assertEqual(obs1.getStandardDeviation(), obs2.getStandardDeviation()) std0 = obs1.getStandardDeviation() local_obsdata = LocalObsdata("obs", obs) node1 = local_obsdata.addNode("WWCT:OP_1") node2 = local_obsdata.addNode("WWCT:OP_1_50") node1.addTimeStep(50) node2.addTimeStep(50) mask = BoolVector(default_value=True) mask[2] = True meas_data = MeasData(mask) obs_data = ObsData() fs = ert.getEnkfFsManager().getCurrentFileSystem() active_list = IntVector() active_list.initRange(0, 2, 1) obs.getObservationAndMeasureData(fs, local_obsdata, active_list, meas_data, obs_data) self.assertEqual(2, len(obs_data)) v1 = obs_data[0] v2 = obs_data[1] self.assertEqual(v1[1], std0) self.assertEqual(v2[1], std0) meas_data = MeasData(mask) obs_data = ObsData(10) obs.getObservationAndMeasureData(fs, local_obsdata, active_list, meas_data, obs_data) self.assertEqual(2, len(obs_data)) v1 = obs_data[0] v2 = obs_data[1] self.assertEqual(v1[1], std0 * 10) self.assertEqual(v2[1], std0 * 10) actl = ActiveList() obs1.updateStdScaling(10, actl) obs2.updateStdScaling(20, actl) meas_data = MeasData(mask) obs_data = ObsData() obs.getObservationAndMeasureData(fs, local_obsdata, active_list, meas_data, obs_data) self.assertEqual(2, len(obs_data)) v1 = obs_data[0] v2 = obs_data[1] self.assertEqual(v1[1], std0 * 10) self.assertEqual(v2[1], std0 * 20)