def addNodeAndRange(self, key, step_1, step_2): assert isinstance(key, str) assert isinstance(step_1, int) assert isinstance(step_2, int) node = LocalObsdataNode(key) self.addNode( node ) node.addRange(step_1, step_2)
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 = LocalObsdataNode( "WWCT:OP_1" ) node1.addRange( 50 , 50 ) node2 = LocalObsdataNode( "WWCT:OP_1_50" ) node2.addRange( 50 , 50 ) local_obsdata.addNode( node1 ) local_obsdata.addNode( node2 ) 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 , EnkfStateType.FORECAST , 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 , EnkfStateType.FORECAST , 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 , EnkfStateType.FORECAST , 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)
def addNodeAndRange(self, key, step_1, step_2): """ @rtype: bool """ assert isinstance(key, str) assert isinstance(step_1, int) assert isinstance(step_2, int) node = LocalObsdataNode(key) node.addRange(step_1, step_2) return self.addNode( node )
def addNodeAndRange(self, key, step_1, step_2): """ @rtype: bool """ assert isinstance(key, str) assert isinstance(step_1, int) assert isinstance(step_2, int) node = LocalObsdataNode(key) node.addRange(step_1, step_2) node.convertToCReference(self) already_exists_node_for_key = LocalObsdata.cNamespace().add_node(self, node) return already_exists_node_for_key
def fetchData(self, obs_keys, case=None): data = {"x": None, "y": None, "obs_y": None, "min_y": None, "max_y": None, "min_x": None, "max_x": None} fs = self.ert().getEnkfFsManager().getFileSystem(case) obs_keys = self.filterObsKeys(obs_keys, fs) step_1 = 0 step_2 = self.ert().getHistoryLength() local_obsdata = LocalObsdata("PCA Observations %s" % case) for obs_key in obs_keys: if not obs_key in local_obsdata: obs_node = LocalObsdataNode(obs_key) obs_node.addRange(step_1, step_2) local_obsdata.addNode(obs_node) if len(local_obsdata) > 0: pca_data = self.calculatePrincipalComponent(fs, local_obsdata) if pca_data is not None: data["x"] = [] data["y"] = [] data["obs_y"] = [] data["min_x"] = 1 data["max_x"] = len(pca_data) component_number = 0 for pca_vector in pca_data: component_number += 1 data["x"].append(component_number) obs_y = pca_vector.getObservation() if data["min_y"] is None or data["min_y"] > obs_y: data["min_y"] = obs_y if data["max_y"] is None or data["max_y"] < obs_y: data["max_y"] = obs_y data["obs_y"].append(obs_y) for index, value in enumerate(pca_vector): if len(data["y"]) == index: data["y"].append([]) y = data["y"][index] y.append(value) if data["min_y"] is None or data["min_y"] > value: data["min_y"] = value if data["max_y"] is None or data["max_y"] < value: data["max_y"] = value return data