def create_context(self, arguments, itr, prior_context=None, rerun=False):
        model_config = self.ert().getModelConfig()
        runpath_fmt = model_config.getRunpathFormat()
        jobname_fmt = model_config.getJobnameFormat()
        subst_list = self.ert().getDataKW()
        fs_manager = self.ert().getEnkfFsManager()
        target_case_format = arguments["target_case"]

        if prior_context is None:
            mask = arguments["active_realizations"]
        else:
            mask = prior_context.get_mask()

        sim_fs = self.createTargetCaseFileSystem(itr, target_case_format)
        if rerun:
            target_fs = None
        else:
            target_fs = self.createTargetCaseFileSystem(
                itr + 1, target_case_format)

        run_context = ErtRunContext.ensemble_smoother(sim_fs, target_fs, mask,
                                                      runpath_fmt, jobname_fmt,
                                                      subst_list, itr)
        self._run_context = run_context
        self._last_run_iteration = run_context.get_iter()
        return run_context
    def create_context(
        self,
        itr: int,
        prior_context: Optional[ErtRunContext] = None,
        rerun: bool = False,
    ) -> ErtRunContext:
        model_config = self.ert().getModelConfig()
        runpath_fmt = model_config.getRunpathFormat()
        jobname_fmt = model_config.getJobnameFormat()
        subst_list = self.ert().getDataKW()
        target_case_format = self._simulation_arguments["target_case"]

        sim_fs = self.createTargetCaseFileSystem(itr, target_case_format)

        if prior_context is None:
            mask = self._simulation_arguments["active_realizations"]
        else:
            state: RealizationStateEnum = (
                RealizationStateEnum.STATE_HAS_DATA  # type: ignore
                | RealizationStateEnum.STATE_INITIALIZED
            )
            mask = sim_fs.getStateMap().createMask(state)

        if rerun:
            target_fs = None
        else:
            target_fs = self.createTargetCaseFileSystem(itr + 1, target_case_format)

        run_context = ErtRunContext.ensemble_smoother(
            sim_fs, target_fs, mask, runpath_fmt, jobname_fmt, subst_list, itr
        )
        self._run_context = run_context
        self._last_run_iteration = run_context.get_iter()
        self.ert().getEnkfFsManager().switchFileSystem(sim_fs)
        return run_context
Beispiel #3
0
    def test_update(self):
        config = self.createTestPath("local/snake_oil/snake_oil.ert")
        with ErtTestContext("update_test", config) as context:
            ert = context.getErt()
            es_update = ESUpdate(ert)
            fsm = ert.getEnkfFsManager()

            sim_fs = fsm.getFileSystem("default_0")
            target_fs = fsm.getFileSystem("target")
            mask = BoolVector(initial_size=ert.getEnsembleSize(),
                              default_value=True)
            model_config = ert.getModelConfig()
            path_fmt = model_config.getRunpathFormat()
            jobname_fmt = model_config.getJobnameFormat()
            subst_list = None
            run_context = ErtRunContext.ensemble_smoother(
                sim_fs, target_fs, mask, path_fmt, jobname_fmt, subst_list, 0)
            es_update.smootherUpdate(run_context)

            conf = ert.ensembleConfig()["SNAKE_OIL_PARAM"]
            sim_node = EnkfNode(conf)
            target_node = EnkfNode(conf)

            node_id = NodeId(0, 0)
            sim_node.load(sim_fs, node_id)
            target_node.load(target_fs, node_id)

            sim_gen_kw = sim_node.asGenKw()
            target_gen_kw = target_node.asGenKw()

            # Test that an update has actually taken place
            for index in range(len(sim_gen_kw)):
                self.assertNotEqual(sim_gen_kw[index], target_gen_kw[index])
Beispiel #4
0
    def update(self, line):
        arguments = splitArguments(line)

        if len(arguments) == 1:
            case_name = arguments[0]
            ert = self.ert()
            fs_manager = ert.getEnkfFsManager()

            ert.getEnkfSimulationRunner().runWorkflows(HookRuntime.PRE_UPDATE)

            es_update = ESUpdate(ert)
            target_fs = fs_manager.getFileSystem(case_name)
            source_fs = fs_manager.getCurrentFileSystem()
            model_config = ert.getModelConfig()
            runpath_fmt = model_config.getRunpathFormat()
            subst_list = ert.getDataKW()
            mask = BoolVector(default_value=True,
                              initial_size=ert.getEnsembleSize())

            run_context = ErtRunContext.ensemble_smoother(
                source_fs, target_fs, mask, runpath_fmt, subst_list, 0)
            success = es_update.smootherUpdate(run_context)

            if not success:
                self.lastCommandFailed("Unable to perform update")

            ert.getEnkfSimulationRunner().runWorkflows(HookRuntime.POST_UPDATE)

        else:
            self.lastCommandFailed(
                "Expected one argument: <target_fs> received: '%s'" % line)
    def create_context(self, arguments, itr, prior_context = None, update = True):
        target_case_format = arguments["target_case"]
        model_config = self.ert().getModelConfig( )
        runpath_fmt = model_config.getRunpathFormat( )
        jobname_fmt = model_config.getJobnameFormat( )
        subst_list = self.ert().getDataKW( )
        fs_manager = self.ert().getEnkfFsManager()

        sim_fs = fs_manager.getFileSystem(target_case_format % itr)
        if update:
            target_fs = fs_manager.getFileSystem(target_case_format % (itr + 1))
        else:
            target_fs = None

        if prior_context is None:
            mask = arguments["active_realizations"]
        else:
            state = RealizationStateEnum.STATE_HAS_DATA | RealizationStateEnum.STATE_INITIALIZED
            mask = sim_fs.getStateMap().createMask(state)
            # Make sure to only run the realizations which was passed in as argument
            for index, run_realization in enumerate(self.initial_realizations_mask):
                mask[index] = mask[index] and run_realization

        run_context = ErtRunContext.ensemble_smoother( sim_fs, target_fs, mask, runpath_fmt, jobname_fmt, subst_list, itr)
        self._run_context = run_context
        self._last_run_iteration = run_context.get_iter()
        return run_context
    def create_context(self, arguments, itr, prior_context=None, rerun=False):
        model_config = self.ert().getModelConfig()
        runpath_fmt = model_config.getRunpathFormat()
        jobname_fmt = model_config.getJobnameFormat()
        subst_list = self.ert().getDataKW()
        target_case_format = arguments["target_case"]

        sim_fs = self.createTargetCaseFileSystem(itr, target_case_format)

        if prior_context is None:
            mask = arguments["active_realizations"]
        else:
            state = (RealizationStateEnum.STATE_HAS_DATA
                     | RealizationStateEnum.STATE_INITIALIZED)
            mask = sim_fs.getStateMap().createMask(state)

        if rerun:
            target_fs = None
        else:
            target_fs = self.createTargetCaseFileSystem(
                itr + 1, target_case_format)

        # Deleting a run_context removes the possibility to retrospectively
        # determine detailed progress. Thus, before deletion, the detailed
        # progress is stored.
        self.updateDetailedProgress()

        run_context = ErtRunContext.ensemble_smoother(sim_fs, target_fs, mask,
                                                      runpath_fmt, jobname_fmt,
                                                      subst_list, itr)
        self._run_context = run_context
        self._last_run_iteration = run_context.get_iter()
        self.ert().getEnkfFsManager().switchFileSystem(sim_fs)
        return run_context
Beispiel #7
0
def _create_runpath(ert: LibresFacade, iteration: int = 0) -> ErtRunContext:
    """
    Instantiate an ERT runpath. This will create the parameter coefficients.
    """
    enkf_main = ert._enkf_main
    result_fs = ert.get_current_fs()
    target_fs = ert._enkf_main.getEnkfFsManager().getFileSystem("iter")

    model_config = enkf_main.getModelConfig()
    runpath_fmt = model_config.getRunpathFormat()
    jobname_fmt = model_config.getJobnameFormat()
    subst_list = enkf_main.getDataKW()

    run_context = ErtRunContext.ensemble_smoother(
        result_fs,
        target_fs,
        BoolVector(default_value=True, initial_size=ert.get_ensemble_size()),
        runpath_fmt,
        jobname_fmt,
        subst_list,
        iteration,
    )

    enkf_main.getEnkfSimulationRunner().createRunPath(run_context)
    return run_context
Beispiel #8
0
    def create_context(self, arguments, itr, prior_context=None, update=True):
        target_case_format = arguments["target_case"]
        model_config = self.ert().getModelConfig()
        runpath_fmt = model_config.getRunpathFormat()
        jobname_fmt = model_config.getJobnameFormat()
        subst_list = self.ert().getDataKW()
        fs_manager = self.ert().getEnkfFsManager()

        sim_fs = fs_manager.getFileSystem(target_case_format % itr)
        if update:
            target_fs = fs_manager.getFileSystem(target_case_format %
                                                 (itr + 1))
        else:
            target_fs = None

        if prior_context is None:
            mask = arguments["active_realizations"]
        else:
            state = RealizationStateEnum.STATE_HAS_DATA | RealizationStateEnum.STATE_INITIALIZED
            mask = sim_fs.getStateMap().createMask(state)
            # Make sure to only run the realizations which was passed in as argument
            for index, run_realization in enumerate(
                    self.initial_realizations_mask):
                mask[index] = mask[index] and run_realization

        run_context = ErtRunContext.ensemble_smoother(sim_fs, target_fs, mask,
                                                      runpath_fmt, jobname_fmt,
                                                      subst_list, itr)
        self._run_context = run_context
        self._last_run_iteration = run_context.get_iter()
        return run_context
Beispiel #9
0
    def update(self, line):
        arguments = splitArguments(line)

        if len(arguments) == 1:
            case_name = arguments[0]
            ert = self.ert()
            fs_manager = ert.getEnkfFsManager() 

            ert.getEnkfSimulationRunner().runWorkflows(HookRuntime.PRE_UPDATE)

            es_update = ESUpdate( ert )
            target_fs = fs_manager.getFileSystem(case_name)
            source_fs = fs_manager.getCurrentFileSystem( )
            model_config = ert.getModelConfig( )
            runpath_fmt = model_config.getRunpathFormat( )
            subst_list = ert.getDataKW( )
            mask = BoolVector( default_value = True, initial_size = ert.getEnsembleSize( ) )
            
            run_context = ErtRunContext.ensemble_smoother( source_fs , target_fs , mask, runpath_fmt, subst_list, 0 )
            success = es_update.smootherUpdate( run_context  )

            if not success:
                self.lastCommandFailed("Unable to perform update")

            ert.getEnkfSimulationRunner().runWorkflows(HookRuntime.POST_UPDATE)

        else:
            self.lastCommandFailed("Expected one argument: <target_fs> received: '%s'" % line)
Beispiel #10
0
    def create_context(
            self,
            prior_context: Optional[ErtRunContext] = None) -> ErtRunContext:

        model_config = self.ert().getModelConfig()
        runpath_fmt = model_config.getRunpathFormat()
        jobname_fmt = model_config.getJobnameFormat()
        subst_list = self.ert().getDataKW()
        fs_manager = self.ert().getEnkfFsManager()
        if prior_context is None:
            sim_fs = fs_manager.getCurrentFileSystem()
            target_fs = fs_manager.getFileSystem(
                self._simulation_arguments["target_case"])
            itr = 0
            mask = self._simulation_arguments["active_realizations"]
        else:
            itr = 1
            sim_fs = prior_context.get_target_fs()
            target_fs = None
            mask = sim_fs.getStateMap().createMask(
                RealizationStateEnum.STATE_HAS_DATA
                | RealizationStateEnum.STATE_INITIALIZED)

        run_context = ErtRunContext.ensemble_smoother(sim_fs, target_fs, mask,
                                                      runpath_fmt, jobname_fmt,
                                                      subst_list, itr)
        self._run_context = run_context
        self._last_run_iteration = run_context.get_iter()
        return run_context
Beispiel #11
0
    def create_context(self, arguments, prior_context=None):

        model_config = self.ert().getModelConfig()
        runpath_fmt = model_config.getRunpathFormat()
        jobname_fmt = model_config.getJobnameFormat()
        subst_list = self.ert().getDataKW()
        fs_manager = self.ert().getEnkfFsManager()
        if prior_context is None:
            sim_fs = fs_manager.getCurrentFileSystem()
            target_fs = fs_manager.getFileSystem(arguments["target_case"])
            itr = 0
            mask = arguments["active_realizations"]
        else:
            itr = 1
            sim_fs = prior_context.get_target_fs()
            target_fs = None
            state = RealizationStateEnum.STATE_HAS_DATA | RealizationStateEnum.STATE_INITIALIZED
            mask = sim_fs.getStateMap().createMask(state)

        # Deleting a run_context removes the possibility to retrospectively
        # determine detailed progress. Thus, before deletion, the detailed
        # progress is stored.
        self.updateDetailedProgress()

        run_context = ErtRunContext.ensemble_smoother(sim_fs, target_fs, mask,
                                                      runpath_fmt, jobname_fmt,
                                                      subst_list, itr)
        self._run_context = run_context
        self._last_run_iteration = run_context.get_iter()
        return run_context
Beispiel #12
0
    def test_localization(self):
        config = self.createTestPath("local/snake_oil/snake_oil.ert")
        with ErtTestContext("localization_test", config) as context:
            ert = context.getErt()
            es_update = ESUpdate(ert)
            fsm = ert.getEnkfFsManager()
            sim_fs = fsm.getFileSystem("default_0")
            target_fs = fsm.getFileSystem("target")

            # perform localization
            localized_idxs = (1, 2)
            local_config = ert.getLocalConfig()
            local_config.clear()
            dataset = local_config.createDataset("DATASET_SCALAR_LOCA")
            dataset.addNode("SNAKE_OIL_PARAM")
            active_list = dataset.getActiveList("SNAKE_OIL_PARAM")
            for i in localized_idxs:
                active_list.addActiveIndex(i)
            obs = local_config.createObsdata("OBSSET_LOCA")
            obs.addNode("WOPR_OP1_72")
            ministep = local_config.createMinistep("MINISTEP_LOCA")
            ministep.attachDataset(dataset)
            ministep.attachObsset(obs)
            updatestep = local_config.getUpdatestep()
            updatestep.attachMinistep(ministep)

            # Run enseble smoother
            mask = BoolVector(initial_size=ert.getEnsembleSize(), default_value=True)
            model_config = ert.getModelConfig()
            path_fmt = model_config.getRunpathFormat()
            jobname_fmt = model_config.getJobnameFormat()
            subst_list = None
            run_context = ErtRunContext.ensemble_smoother(
                sim_fs, target_fs, mask, path_fmt, jobname_fmt, subst_list, 0
            )
            es_update.smootherUpdate(run_context)

            conf = ert.ensembleConfig()["SNAKE_OIL_PARAM"]
            sim_node = EnkfNode(conf)
            target_node = EnkfNode(conf)

            node_id = NodeId(0, 0)
            sim_node.load(sim_fs, node_id)
            target_node.load(target_fs, node_id)

            sim_gen_kw = sim_node.asGenKw()
            target_gen_kw = target_node.asGenKw()

            # Test that the localized values has been updated
            for i in localized_idxs:
                self.assertNotEqual(sim_gen_kw[i], target_gen_kw[i])

            # test that all the other values are left unchanged
            non_localized_idxs = (
                x for x in range(len(sim_gen_kw)) if x not in localized_idxs
            )
            for i in non_localized_idxs:
                self.assertEqual(sim_gen_kw[i], target_gen_kw[i])
Beispiel #13
0
def test_localization(setup_case, expected_target_gen_kw):
    """
    Note that this is now a snapshot test, so there is no guarantee that the
    snapshots are correct, they are just documenting the current behavior.
    """
    res_config = setup_case("local/snake_oil", "snake_oil.ert")
    ert = EnKFMain(res_config)
    es_update = ESUpdate(ert)
    fsm = ert.getEnkfFsManager()
    sim_fs = fsm.getFileSystem("default_0")
    target_fs = fsm.getFileSystem("target")

    # perform localization
    localized_idxs = (1, 2)
    local_config = ert.getLocalConfig()
    local_config.clear()
    obs = local_config.createObsdata("OBSSET_LOCA")
    obs.addNode("WOPR_OP1_72")
    ministep = local_config.createMinistep("MINISTEP_LOCA")
    ministep.addActiveData("SNAKE_OIL_PARAM")  # replace dataset.addNode()
    active_list = ministep.getActiveList("SNAKE_OIL_PARAM")
    for i in localized_idxs:
        active_list.addActiveIndex(i)
    ministep.attachObsset(obs)
    updatestep = local_config.getUpdatestep()
    updatestep.attachMinistep(ministep)

    # Run ensemble smoother
    mask = [True] * ert.getEnsembleSize()
    model_config = ert.getModelConfig()
    path_fmt = model_config.getRunpathFormat()
    jobname_fmt = model_config.getJobnameFormat()
    subst_list = None
    run_context = ErtRunContext.ensemble_smoother(
        sim_fs, target_fs, mask, path_fmt, jobname_fmt, subst_list, 0
    )
    es_update.smootherUpdate(run_context)

    conf = ert.ensembleConfig()["SNAKE_OIL_PARAM"]
    sim_node = EnkfNode(conf)
    target_node = EnkfNode(conf)

    node_id = NodeId(0, 0)
    sim_node.load(sim_fs, node_id)
    target_node.load(target_fs, node_id)

    sim_gen_kw = list(sim_node.asGenKw())
    target_gen_kw = list(target_node.asGenKw())

    # Test that the localized values has been updated
    assert sim_gen_kw[1:3] != target_gen_kw[1:3]

    # test that all the other values are left unchanged
    assert sim_gen_kw[3:] == target_gen_kw[3:]
    assert sim_gen_kw[0] == target_gen_kw[0]

    assert target_gen_kw == pytest.approx(expected_target_gen_kw)
Beispiel #14
0
def _ensemble_smoother_run(ert, target_case):
    source_fs, target_fs = setup_fs(ert, target_case)

    model_config = ert.getModelConfig()
    subst_list = ert.getDataKW()

    mask = BoolVector(default_value=True, initial_size=ert.getEnsembleSize())

    prior_context = ErtRunContext.ensemble_smoother(
        sim_fs=source_fs,
        target_fs=target_fs,
        mask=mask,
        path_fmt=model_config.getRunpathFormat(),
        jobname_fmt=model_config.getJobnameFormat(),
        subst_list=subst_list,
        itr=0)

    sim_runner = ert.getEnkfSimulationRunner()
    _run_ensemble_experiment(ert, prior_context, sim_runner)
    sim_runner.runWorkflows(HookRuntime.PRE_UPDATE)

    es_update = ESUpdate(ert)
    success = es_update.smootherUpdate(prior_context)
    if not success:
        raise AssertionError("Analysis of simulation failed!")

    sim_runner.runWorkflows(HookRuntime.POST_UPDATE)

    ert.getEnkfFsManager().switchFileSystem(prior_context.get_target_fs())

    sim_fs = prior_context.get_target_fs()
    state = RealizationStateEnum.STATE_HAS_DATA | RealizationStateEnum.STATE_INITIALIZED
    mask = sim_fs.getStateMap().createMask(state)

    rerun_context = ErtRunContext.ensemble_smoother(
        sim_fs=sim_fs,
        target_fs=None,
        mask=mask,
        path_fmt=model_config.getRunpathFormat(),
        jobname_fmt=model_config.getJobnameFormat(),
        subst_list=subst_list,
        itr=1)

    _run_ensemble_experiment(ert, rerun_context, sim_runner)
Beispiel #15
0
    def create_context(self,
                       arguments,
                       itr,
                       initialize_mask_from_arguments=True,
                       update=True):
        target_case_format = arguments["target_case"]
        model_config = self.ert().getModelConfig()
        runpath_fmt = model_config.getRunpathFormat()
        jobname_fmt = model_config.getJobnameFormat()
        subst_list = self.ert().getDataKW()
        fs_manager = self.ert().getEnkfFsManager()

        source_case_name = target_case_format % itr
        if itr > 0 and not fs_manager.caseExists(source_case_name):
            raise ErtRunError(
                "Source case {} for iteration {} does not exists. "
                "If you are attempting to restart ESMDA from a iteration other than 0, "
                "make sure the target case format is the same as for the original run! "
                "(Current target case format: {})".format(
                    source_case_name, itr, target_case_format))

        sim_fs = fs_manager.getFileSystem(source_case_name)
        if update:
            target_fs = fs_manager.getFileSystem(target_case_format %
                                                 (itr + 1))
        else:
            target_fs = None

        if initialize_mask_from_arguments:
            mask = arguments["active_realizations"]
        else:
            state = (RealizationStateEnum.STATE_HAS_DATA
                     | RealizationStateEnum.STATE_INITIALIZED)
            mask = sim_fs.getStateMap().createMask(state)
            # Make sure to only run the realizations which was passed in as argument
            for index, run_realization in enumerate(
                    self.initial_realizations_mask):
                mask[index] = mask[index] and run_realization

        # Deleting a run_context removes the possibility to retrospectively
        # determine detailed progress. Thus, before deletion, the detailed
        # progress is stored.
        self.updateDetailedProgress()

        run_context = ErtRunContext.ensemble_smoother(sim_fs, target_fs, mask,
                                                      runpath_fmt, jobname_fmt,
                                                      subst_list, itr)
        self._run_context = run_context
        self._last_run_iteration = run_context.get_iter()
        self.ert().getEnkfFsManager().switchFileSystem(sim_fs)
        return run_context
    def create_context(
        self,
        itr: int,
        initialize_mask_from_arguments: bool = True,
        update: bool = True,
    ) -> ErtRunContext:
        target_case_format = self._simulation_arguments["target_case"]
        model_config = self.ert().getModelConfig()
        runpath_fmt = model_config.getRunpathFormat()
        jobname_fmt = model_config.getJobnameFormat()
        subst_list = self.ert().getDataKW()
        fs_manager = self.ert().getEnkfFsManager()

        source_case_name = target_case_format % itr
        if itr > 0 and not fs_manager.caseExists(source_case_name):
            raise ErtRunError(
                "Source case {} for iteration {} does not exists. "
                "If you are attempting to restart ESMDA from a iteration other than 0, "
                "make sure the target case format is the same as for the original run! "
                "(Current target case format: {})".format(
                    source_case_name, itr, target_case_format))

        sim_fs = fs_manager.getFileSystem(source_case_name)
        if update:
            target_fs = fs_manager.getFileSystem(target_case_format %
                                                 (itr + 1))
        else:
            target_fs = None

        if initialize_mask_from_arguments:
            mask = self._simulation_arguments["active_realizations"]
        else:
            mask = sim_fs.getStateMap().createMask(
                RealizationStateEnum.STATE_HAS_DATA
                | RealizationStateEnum.STATE_INITIALIZED)
            # Make sure to only run the realizations which was passed in as argument
            for idx, (valid_state, run_realization) in enumerate(
                    zip(mask, self._initial_realizations_mask)):
                mask[idx] = valid_state and run_realization

        run_context = ErtRunContext.ensemble_smoother(sim_fs, target_fs, mask,
                                                      runpath_fmt, jobname_fmt,
                                                      subst_list, itr)
        self._run_context = run_context
        self._last_run_iteration = run_context.get_iter()
        self.ert().getEnkfFsManager().switchFileSystem(sim_fs)
        return run_context
Beispiel #17
0
 def create_context(self, arguments, prior_context = None):
     model_config = self.ert().getModelConfig( )
     runpath_fmt = model_config.getRunpathFormat( )
     subst_list = self.ert().getDataKW( )
     fs_manager = self.ert().getEnkfFsManager()
     if prior_context is None:
         sim_fs = fs_manager.getCurrentFileSystem( )
         target_fs = fs_manager.getFileSystem("smoother-update")
         itr = 0
         mask = arguments["active_realizations"]
     else:
         itr = 1
         mask = prior_context.get_mask( )
         sim_fs = prior_context.get_target_fs( )
         target_fs = None
         
     run_context = ErtRunContext.ensemble_smoother( sim_fs, target_fs, mask, runpath_fmt, subst_list, itr)
     return run_context
Beispiel #18
0
    def create_context(self, arguments, prior_context=None):
        model_config = self.ert().getModelConfig()
        runpath_fmt = model_config.getRunpathFormat()
        subst_list = self.ert().getDataKW()
        fs_manager = self.ert().getEnkfFsManager()
        if prior_context is None:
            sim_fs = fs_manager.getCurrentFileSystem()
            target_fs = fs_manager.getFileSystem("smoother-update")
            itr = 0
            mask = arguments["active_realizations"]
        else:
            itr = 1
            mask = prior_context.get_mask()
            sim_fs = prior_context.get_target_fs()
            target_fs = None

        run_context = ErtRunContext.ensemble_smoother(sim_fs, target_fs, mask,
                                                      runpath_fmt, subst_list,
                                                      itr)
        return run_context
    def create_context(self, arguments, itr, prior_context = None, rerun = False):
        model_config = self.ert().getModelConfig( )
        runpath_fmt = model_config.getRunpathFormat( )
        subst_list = self.ert().getDataKW( )
        fs_manager = self.ert().getEnkfFsManager()
        target_case_format = arguments["target_case"]

        if prior_context is None:
            mask = arguments["active_realizations"]
        else:
            mask = prior_context.get_mask( )
        
        sim_fs = self.createTargetCaseFileSystem(itr, target_case_format)
        if rerun:
            target_fs = None
        else:
            target_fs = self.createTargetCaseFileSystem(itr + 1 , target_case_format)

        run_context = ErtRunContext.ensemble_smoother( sim_fs, target_fs, mask, runpath_fmt, subst_list, itr)
        return run_context
    def create_context(self, arguments, itr, prior_context = None, update = True):
        target_case_format = arguments["target_case"]
        model_config = self.ert().getModelConfig( )
        runpath_fmt = model_config.getRunpathFormat( )
        jobname_fmt = model_config.getJobnameFormat( )
        subst_list = self.ert().getDataKW( )
        fs_manager = self.ert().getEnkfFsManager()

        sim_fs = fs_manager.getFileSystem(target_case_format % itr)
        if update:
            target_fs = fs_manager.getFileSystem(target_case_format % (itr + 1))
        else:
            target_fs = None

        if prior_context is None:
            mask = arguments["active_realizations"]
        else:
            mask = prior_context.get_mask( )

        run_context = ErtRunContext.ensemble_smoother( sim_fs, target_fs, mask, runpath_fmt, jobname_fmt, subst_list, itr)
        return run_context
Beispiel #21
0
    def create_context(self, arguments, itr, prior_context = None, update = True):
        target_case_format = arguments["target_case"]
        model_config = self.ert().getModelConfig( )
        runpath_fmt = model_config.getRunpathFormat( )
        jobname_fmt = model_config.getJobnameFormat( )
        subst_list = self.ert().getDataKW( )
        fs_manager = self.ert().getEnkfFsManager()

        sim_fs = fs_manager.getFileSystem(target_case_format % itr)
        if update:
            target_fs = fs_manager.getFileSystem(target_case_format % (itr + 1))
        else:
            target_fs = None

        if prior_context is None:
            mask = arguments["active_realizations"]
        else:
            state = RealizationStateEnum.STATE_HAS_DATA | RealizationStateEnum.STATE_INITIALIZED
            mask = sim_fs.getStateMap().createMask(state)

        run_context = ErtRunContext.ensemble_smoother( sim_fs, target_fs, mask, runpath_fmt, jobname_fmt, subst_list, itr)
        return run_context
Beispiel #22
0
    def create_context(self, arguments, prior_context = None):

        model_config = self.ert().getModelConfig( )
        runpath_fmt = model_config.getRunpathFormat( )
        jobname_fmt = model_config.getJobnameFormat( )
        subst_list = self.ert().getDataKW( )
        fs_manager = self.ert().getEnkfFsManager()
        if prior_context is None:
            sim_fs = fs_manager.getCurrentFileSystem( )
            target_fs = fs_manager.getFileSystem(arguments["target_case"])
            itr = 0
            mask = arguments["active_realizations"]
        else:
            itr = 1
            sim_fs = prior_context.get_target_fs( )
            target_fs = None
            state = RealizationStateEnum.STATE_HAS_DATA | RealizationStateEnum.STATE_INITIALIZED
            mask = sim_fs.getStateMap().createMask(state)

        run_context = ErtRunContext.ensemble_smoother( sim_fs, target_fs, mask, runpath_fmt, jobname_fmt, subst_list, itr)
        self._run_context = run_context
        self._last_run_iteration = run_context.get_iter()
        return run_context
Beispiel #23
0
    def create_context(self, arguments, itr, prior_context=None, update=True):
        target_case_format = arguments["target_case"]
        model_config = self.ert().getModelConfig()
        runpath_fmt = model_config.getRunpathFormat()
        subst_list = self.ert().getDataKW()
        fs_manager = self.ert().getEnkfFsManager()

        sim_fs = fs_manager.getFileSystem(target_case_format % itr)
        if update:
            target_fs = fs_manager.getFileSystem(target_case_format %
                                                 (itr + 1))
        else:
            target_fs = None

        if prior_context is None:
            mask = arguments["active_realizations"]
        else:
            mask = prior_context.get_mask()

        run_context = ErtRunContext.ensemble_smoother(sim_fs, target_fs, mask,
                                                      runpath_fmt, subst_list,
                                                      itr)
        return run_context
Beispiel #24
0
def _create_runpath(enkf_main: EnKFMain) -> ErtRunContext:
    """
    Instantiate an ERT runpath. This will create the parameter coefficients.
    """
    result_fs = enkf_main.getEnkfFsManager().getCurrentFileSystem()

    model_config = enkf_main.getModelConfig()
    runpath_fmt = model_config.getRunpathFormat()
    jobname_fmt = model_config.getJobnameFormat()
    subst_list = enkf_main.getDataKW()

    run_context = ErtRunContext.ensemble_smoother(
        result_fs,
        None,
        BoolVector(default_value=True, initial_size=1),
        runpath_fmt,
        jobname_fmt,
        subst_list,
        0,
    )

    enkf_main.getEnkfSimulationRunner().createRunPath(run_context)
    return run_context