Ejemplo n.º 1
0
    def test_it(self):
        state_size = 10
        with ErtTestContext("update", self.config_file) as tc:
            analysis = self.createAnalysisModule()
            ert = tc.getErt()
            obs = ert.getObservations()
            local_obsdata = obs.getAllActiveLocalObsdata()

            fs = ert.getEnkfFsManager().getCurrentFileSystem()

            mask = BoolVector(initial_size=ert.getEnsembleSize(), default_value=True)
            meas_data = MeasData(mask)
            obs_data = ObsData()
            obs.getObservationAndMeasureData(
                fs, local_obsdata, mask.createActiveList(), meas_data, obs_data
            )
            update(self.rng, mask, analysis, ert, meas_data, obs_data, state_size)

            mask[0] = False
            mask[4] = False
            meas_data = MeasData(mask)
            obs_data = ObsData()
            obs.getObservationAndMeasureData(
                fs, local_obsdata, mask.createActiveList(), meas_data, obs_data
            )
            update(self.rng, mask, analysis, ert, meas_data, obs_data, state_size)
Ejemplo n.º 2
0
    def createActiveList(self, fs):
        state_map = fs.getStateMap()
        ens_mask = BoolVector(False, self.ert().getEnsembleSize())
        state_map.selectMatching(ens_mask, RealizationStateEnum.STATE_HAS_DATA)
        active_list = BoolVector.createActiveList(ens_mask)

        return active_list
Ejemplo n.º 3
0
    def createActiveList(ert, fs):
        state_map = fs.getStateMap()
        ens_mask = BoolVector(False, ert.getEnsembleSize())
        state_map.selectMatching(ens_mask, RealizationStateEnum.STATE_HAS_DATA)
        active_list = BoolVector.createActiveList(ens_mask)

        return [iens for iens in active_list]
Ejemplo n.º 4
0
    def realizationList(self, state_value):
        """
        Will create a list of all realisations with state equal to state_value.

        @type state_value: RealizationStateEnum
        @rtype: ecl.util.IntVector
        """
        mask = self.createMask(state_value)
        return BoolVector.createActiveList(mask)
Ejemplo n.º 5
0
    def realizationList(self, state_value):
        """
        Will create a list of all realisations with state equal to state_value.

        @type state_value: RealizationStateEnum
        @rtype: ecl.util.IntVector
        """
        mask = BoolVector(False, len(self))
        self.selectMatching(mask, state_value)
        return BoolVector.createActiveList(mask)
Ejemplo n.º 6
0
    def test_create_active_list(self):
        vec = BoolVector(False, 10)
        vec[0] = True
        vec[3] = True
        vec[7] = True

        idxs = vec.createActiveList()
        self.assertTrue(len(idxs) == 3, "Should get 3 indices")
        self.assertEqual(idxs[0], 0)
        self.assertEqual(idxs[1], 3)
        self.assertEqual(idxs[2], 7)
Ejemplo n.º 7
0
    def calculatePrincipalComponent(self,
                                    fs,
                                    local_obsdata,
                                    truncation_or_ncomp=3):
        pc = Matrix(1, 1)
        pc_obs = Matrix(1, 1)
        singular_values = DoubleVector()

        state_map = fs.getStateMap()
        ens_mask = BoolVector(False, self.ert().getEnsembleSize())
        state_map.selectMatching(ens_mask, RealizationStateEnum.STATE_HAS_DATA)
        active_list = ens_mask.createActiveList()

        if len(ens_mask) > 0:
            meas_data = MeasData(ens_mask)
            obs_data = ObsData()

            self.ert().getObservations().getObservationAndMeasureData(
                fs, local_obsdata, active_list, meas_data, obs_data)

            meas_data.deactivateZeroStdSamples(obs_data)

            active_size = len(obs_data)

            if active_size > 0:
                S = meas_data.createS()
                D_obs = obs_data.createDObs()

                truncation, ncomp = self.truncationOrNumberOfComponents(
                    truncation_or_ncomp)

                obs_data.scale(S, D_obs=D_obs)
                EnkfLinalg.calculatePrincipalComponents(
                    S, D_obs, truncation, ncomp, pc, pc_obs, singular_values)
                if self.__prior_singular_values is None:
                    self.__prior_singular_values = singular_values
                else:
                    for row in range(pc.rows()):
                        factor = singular_values[
                            row] / self.__prior_singular_values[row]
                        pc.scaleRow(row, factor)
                        pc_obs.scaleRow(row, factor)

                return PcaPlotData(local_obsdata.getName(), pc, pc_obs,
                                   singular_values)
        return None