예제 #1
0
    def completeFIELD(self, text, line, begidx, endidx):
        arguments = splitArguments(line)

        if len(arguments) > 2 or len(arguments) == 2 and not text:
            return []

        return autoCompleteList(text, self.supportedFIELDKeys())
예제 #2
0
파일: export.py 프로젝트: agchitu/ert
    def completeFIELD(self, text, line, begidx, endidx):
        arguments = splitArguments(line)

        if len(arguments) > 2 or len(arguments) == 2 and not text:
            return []

        return autoCompleteList(text, self.supportedFIELDKeys())
예제 #3
0
파일: export.py 프로젝트: agchitu/ert
    def exportFIELD(self, line):
        arguments = splitArguments(line)

        if len(arguments) >= 1:
            ens_config = self.ert().ensembleConfig()
            key = arguments[0]
            if key in self.supportedFIELDKeys():
                config_node = ens_config[key]
                if len(arguments) >= 2:
                    path_fmt = arguments[1]
                else:
                    path_fmt = Export.DEFAULT_EXPORT_PATH % (key, key) + ".grdecl"

                if len(arguments) >= 3:
                    range_string = "".join(arguments[2:])
                    iens_list = IntVector.active_list(range_string)
                else:
                    ens_size = self.ert().getEnsembleSize()
                    iens_list = IntVector.createRange(0, ens_size, 1)

                fs_manager = self.ert().getEnkfFsManager()
                fs = fs_manager.getCurrentFileSystem()
                init_file = self.ert().fieldInitFile(config_node)
                if init_file:
                    print('Using init file: %s' % init_file)

                EnkfNode.exportMany(config_node, path_fmt, fs, iens_list, arg=init_file)
            else:
                self.lastCommandFailed("No such FIELD node: %s" % key)
        else:
            self.lastCommandFailed("Expected at least one argument: <keyword> received: '%s'" % line)
예제 #4
0
파일: plugins.py 프로젝트: Ensembles/ert
    def run(self, line):
        arguments = splitArguments(line)

        if len(arguments) < 1:
            print("Error: This keyword requires a name of a plugin to run.")
        else:
            plugin_name = arguments[0]
            plugin_job = self.getWorkflowJob(plugin_name)

            if plugin_job is not None:
                try:
                    script = self.getScript(plugin_job)
                    if len(arguments) > 1:
                        arguments = arguments[1:]
                    else:
                        arguments = script.getArguments(None)

                    now = time.time()
                    result = plugin_job.run(self.ert(), arguments)

                    self.shellContext()["debug"].setLastPluginResult(result)

                    diff = time.time() - now
                    print("Plugin running time: %d seconds" % int(diff))

                    print(result)
                except CancelPluginException:
                    print("Plugin cancelled before execution!")
            else:
                self.lastCommandFailed("Unknown plugin: '%s'" % plugin_name)
예제 #5
0
파일: export.py 프로젝트: pgdr/ert
    def exportFIELD(self, line):
        arguments = splitArguments(line)

        if len(arguments) >= 1:
            ens_config = self.ert().ensembleConfig()
            key = arguments[0]
            if key in self.supportedFIELDKeys():
                config_node = ens_config[key]
                if len(arguments) >= 2:
                    path_fmt = arguments[1]
                else:
                    path_fmt = Export.DEFAULT_EXPORT_PATH % (key, key) + ".grdecl"

                if len(arguments) >= 3:
                    range_string = "".join(arguments[2:])
                    iens_list = IntVector.active_list(range_string)
                else:
                    ens_size = self.ert().getEnsembleSize()
                    iens_list = IntVector.createRange(0, ens_size, 1)

                fs_manager = self.ert().getEnkfFsManager()
                fs = fs_manager.getCurrentFileSystem()
                mc = self.ert().getModelConfig()
                init_file = config_node.getInitFile(mc.getRunpathFormat())
                if init_file:
                    print('Using init file: %s' % init_file)

                EnkfNode.exportMany(config_node, path_fmt, fs, iens_list, arg=init_file)
            else:
                self.lastCommandFailed("No such FIELD node: %s" % key)
        else:
            self.lastCommandFailed("Expected at least one argument: <keyword> received: '%s'" % line)
예제 #6
0
파일: smoother.py 프로젝트: pgdr/ert
    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)
예제 #7
0
    def ls(self, line):
        arguments = splitArguments(line)

        if len(arguments) == 0:
            self.lastCommandFailed("A 'block file' is required.")
        else:
            block_file = arguments[0]
            pattern = None if len(arguments) == 1 else arguments[1]

            if not os.path.isfile(block_file):
                self.lastCommandFailed("The path: '%s' is not a file." % block_file)
            else:
                if not UTIL_LIB.block_fs_is_mount(block_file):
                    _, filename = os.path.split(block_file)
                    self.lastCommandFailed("The file: '%s' is not a block mount file." % filename)
                else:
                    block_fs = UTIL_LIB.block_fs_mount(block_file, 1, 0, 1, 0, False, True, False)
                    files = UTIL_LIB.block_fs_alloc_filelist(block_fs, pattern, OFFSET_SORT, False)

                    file_count = UTIL_LIB.vector_get_size(files)

                    if file_count > 0:
                        fmt = " %-40s %10d %10d"
                        print(" %-40s %10s %10s" % ("Keyword", "Size", "Offset"))

                        for index in range(file_count):
                            node = UTIL_LIB.vector_iget_const(files, index)
                            node_filename = UTIL_LIB.user_file_node_get_filename(node)
                            node_size = UTIL_LIB.user_file_node_get_data_size(node)
                            node_offset = UTIL_LIB.user_file_node_get_node_offset(node)
                            print(fmt % (node_filename, node_size, node_offset))

                    UTIL_LIB.vector_free(files)
                    UTIL_LIB.block_fs_close(block_fs)
예제 #8
0
    def run(self, line):
        arguments = splitArguments(line)

        if len(arguments) < 1:
            print("Error: This keyword requires a name of a plugin to run.")
        else:
            plugin_name = arguments[0]
            plugin_job = self.getWorkflowJob(plugin_name)

            if plugin_job is not None:
                try:
                    script = self.getScript(plugin_job)
                    if len(arguments) > 1:
                        arguments = arguments[1:]
                    else:
                        arguments = script.getArguments(None)

                    now = time.time()
                    result = plugin_job.run(self.ert(), arguments)

                    self.shellContext()["debug"].setLastPluginResult(result)

                    diff = time.time() - now
                    print("Plugin running time: %d seconds" % int(diff))

                    print(result)
                except CancelPluginException:
                    print("Plugin cancelled before execution!")
            else:
                self.lastCommandFailed("Unknown plugin: '%s'" % plugin_name)
예제 #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)
예제 #10
0
    def add_matcher(self, line):
        args = splitArguments(line)

        if len(args) < 1:
            self.lastCommandFailed("A Summary key is required.")
            return False

        self.ert().ensembleConfig().getSummaryKeyMatcher().addSummaryKey(args[0].strip())
예제 #11
0
def plotPathValidator(model, line):
    arguments = splitArguments(line)

    if len(arguments) == 1:
        return arguments[0]  # todo: check if exists and is file or directory for example
    else:
        raise ValueError("Can only set one path. If you require spaces in your path, "
                         "surround it with quotes: \"path with space\".")
예제 #12
0
def plotPathValidator(model, line):
    arguments = splitArguments(line)

    if len(arguments) == 1:
        return arguments[0]  # todo: check if exists and is file or directory for example
    else:
        raise ValueError("Can only set one path. If you require spaces in your path, "
                         "surround it with quotes: \"path with space\".")
예제 #13
0
    def add_matcher(self, line):
        args = splitArguments(line)

        if len(args) < 1:
            self.lastCommandFailed("A Summary key is required.")
            return False

        self.ert().ensembleConfig().getSummaryKeyMatcher().addSummaryKey(
            args[0].strip())
예제 #14
0
    def completeSet(self, text, line, begidx, endidx):
        arguments = splitArguments(line)

        if len(arguments) > 2 or len(arguments) == 2 and not text:
            return []

        active_module = self.ert().analysisConfig().getActiveModule()
        variables = active_module.getVariableNames()
        return autoCompleteListWithSeparator(text, variables)
예제 #15
0
파일: results.py 프로젝트: Ensembles/ert
    def completeLoad(self, text, line, begidx, endidx):
        arguments = splitArguments(line)

        if len(arguments) > 2 or len(arguments) == 2 and not text:
            return []

        if not text:
            return ["0-%d" % self.ert().getEnsembleSize()] # todo should generate based on realization directories.

        return []
예제 #16
0
    def completeLoad(self, text, line, begidx, endidx):
        arguments = splitArguments(line)

        if len(arguments) > 2 or len(arguments) == 2 and not text:
            return []

        if not text:
            return ["0-%d" % self.ert().getEnsembleSize()] # todo should generate based on realization directories.

        return []
예제 #17
0
파일: cases.py 프로젝트: berland/ert
    def create(self, line):
        arguments = splitArguments(line)

        if len(arguments) == 1:
            case_name = arguments[0]
            if case_name not in self.getFileSystemNames():
                fs = self.ert().getEnkfFsManager().getFileSystem(case_name)
                self.ert().getEnkfFsManager().switchFileSystem(fs)
            else:
                self.lastCommandFailed("Case '%s' already exists!" % case_name)
        else:
            self.lastCommandFailed("Expected one argument: <case_name> received: '%s'" % line)
예제 #18
0
파일: cases.py 프로젝트: bramirex/ert
    def create(self, line):
        arguments = splitArguments(line)

        if len(arguments) == 1:
            case_name = arguments[0]
            if case_name not in self.getFileSystemNames():
                fs = self.ert().getEnkfFsManager().getFileSystem(case_name)
                self.ert().getEnkfFsManager().switchFileSystem(fs)
            else:
                self.lastCommandFailed("Case '%s' already exists!" % case_name)
        else:
            self.lastCommandFailed(
                "Expected one argument: <case_name> received: '%s'" % line)
예제 #19
0
파일: smoother.py 프로젝트: bramirex/ert
    def update(self, line):
        arguments = splitArguments(line)

        if len(arguments) == 1:
            case_name = arguments[0]
            target_fs = self.ert().getEnkfFsManager().getFileSystem(case_name)
            simulation_runner = EnkfSimulationRunner(self.ert())
            success = simulation_runner.smootherUpdate(target_fs)

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

        else:
            self.lastCommandFailed("Expected one argument: <target_fs> received: '%s'" % line)
예제 #20
0
파일: smoother.py 프로젝트: jonerduarte/ert
    def update(self, line):
        arguments = splitArguments(line)

        if len(arguments) == 1:
            case_name = arguments[0]
            target_fs = self.ert().getEnkfFsManager().getFileSystem(case_name)
            simulation_runner = EnkfSimulationRunner(self.ert())
            success = simulation_runner.smootherUpdate(target_fs)

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

        else:
            self.lastCommandFailed("Expected one argument: <target_fs> received: '%s'" % line)
예제 #21
0
파일: plugins.py 프로젝트: Ensembles/ert
    def help(self, line):
        arguments = splitArguments(line)

        if len(arguments) < 1:
            self.lastCommandFailed("This keyword requires a name of a plugin to run.")
        else:
            plugin_name = arguments[0]
            plugin_job = self.getWorkflowJob(plugin_name)

            if plugin_job is not None:
                script  = self.getScript(plugin_job)

                print(script.__doc__)
            else:
                self.lastCommandFailed("Unknown plugin: '%s'" % plugin_name)
예제 #22
0
    def completeLs(self, text, line, begidx, endidx):
        arguments = splitArguments(line)
        last_argument = extractFullArgument(line, endidx)

        if len(arguments) == 1 and len(text) == 0:
            ert = self.ert()
            if ert is not None:
                return [ert.getModelConfig().getEnspath() + os.path.sep]
            else:
                return getPossibleFilenameCompletions("")
        elif len(arguments) == 2 and len(last_argument) > 0:
            return getPossibleFilenameCompletions(last_argument)
        elif len(arguments) == 3 and len(text) > 0:
            return [] # pattern completion...
        else:
            return []
예제 #23
0
    def help(self, line):
        arguments = splitArguments(line)

        if len(arguments) < 1:
            self.lastCommandFailed(
                "This keyword requires a name of a plugin to run.")
        else:
            plugin_name = arguments[0]
            plugin_job = self.getWorkflowJob(plugin_name)

            if plugin_job is not None:
                script = self.getScript(plugin_job)

                print(script.__doc__)
            else:
                self.lastCommandFailed("Unknown plugin: '%s'" % plugin_name)
예제 #24
0
    def update(self, line):
        arguments = splitArguments(line)

        if len(arguments) == 1:
            case_name = arguments[0]
            ert = self.ert()
            fs_manager = ert.getEnkfFsManager() 
            es_update = ESUpdate( ert )
            
            target_fs = fs_manager.getFileSystem(case_name)
            source_fs = fs_manager.getCurrentFileSystem( )
            success = es_update.smootherUpdate( source_fs , target_fs )

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

        else:
            self.lastCommandFailed("Expected one argument: <target_fs> received: '%s'" % line)
예제 #25
0
파일: results.py 프로젝트: Ensembles/ert
    def load(self, args):
        arguments = splitArguments(args)

        if len(arguments) < 1:
            self.lastCommandFailed("Loading requires a realization mask.")
            return False

        realization_count = self.ert().getEnsembleSize()

        mask = BoolVector(False, realization_count)
        mask_success = mask.updateActiveMask(arguments[0])

        if not mask_success:
            self.lastCommandFailed("The realization mask: '%s' is not valid." % arguments[0])
            return False

        fs = self.ert().getEnkfFsManager().getCurrentFileSystem()
        self.ert().loadFromForwardModel(mask, 0, fs)
예제 #26
0
    def load(self, args):
        arguments = splitArguments(args)

        if len(arguments) < 1:
            self.lastCommandFailed("Loading requires a realization mask.")
            return False

        realization_count = self.ert().getEnsembleSize()

        mask = BoolVector(False, realization_count)
        mask_success = mask.updateActiveMask(arguments[0])

        if not mask_success:
            self.lastCommandFailed("The realization mask: '%s' is not valid." % arguments[0])
            return False

        fs = self.ert().getEnkfFsManager().getCurrentFileSystem()
        self.ert().loadFromForwardModel(mask, 0, fs)
예제 #27
0
    def set(self, line):
        arguments = splitArguments(line)

        if len(arguments) > 1:
            active_module = self.ert().analysisConfig().getActiveModule()
            variables = active_module.getVariableNames()
            variable, argument = line.split(" ", 1)

            if not variable in variables:
                self.lastCommandFailed("Variable with name: %s, not available in analysis module!" % variable)
            else:
                variable_type = active_module.getVariableType(variable)
                try:
                    value = variable_type(argument)
                    active_module.setVar(variable, argument)
                except ValueError:
                    self.lastCommandFailed("Unable to convert '%s' into to a: %s" % (argument, variable_type.__name__))

        else:
            self.lastCommandFailed("This keyword requires a variable name and a value.")
예제 #28
0
    def completeRun(self, text, line, begidx, endidx):
        arguments = splitArguments(line)

        if len(arguments) > 2 or len(arguments) == 2 and not text:
            return []
        return autoCompleteList(text, self.getPluginNames())
예제 #29
0
파일: plugins.py 프로젝트: Ensembles/ert
    def completeRun(self, text, line, begidx, endidx):
        arguments = splitArguments(line)

        if len(arguments) > 2 or len(arguments) == 2 and not text:
            return []
        return autoCompleteList(text, self.getPluginNames())