Esempio n. 1
0
    def exportGenData(self, keyword, path, iactive, file_type, report_step,
                      selected_case):
        """
        @type keyword: str
        @type path: str
        @type iactive: BoolVector
        @type file_type: EnkfFieldFileFormatEnum
        @type report_step: int
        @type selected_case: str
        """
        fs = ERT.ert.getEnkfFsManager().getFileSystem(selected_case)
        config_node = ERT.ert.ensembleConfig().getNode(keyword)
        gen_data_config_node = config_node.getDataModelConfig()

        export_type = gen_data_config_node.getOutputFormat()
        if export_type == GenDataFileType.GEN_DATA_UNDEFINED:
            export_type = gen_data_config_node.getInputFormat()

        node = EnkfNode(config_node)

        for index, active in enumerate(iactive):
            if active:
                node_id = NodeId(int(report_step), index)

                if node.tryLoad(fs, node_id):
                    gen_data = node.asGenData()

                    filename = str(path + "/" + keyword +
                                   "_{0}").format(index) + ".txt"
                    gen_data.export(filename, export_type, None)
Esempio n. 2
0
    def exportField(self, keyword, path, iactive, file_type, report_step,
                    selected_case):
        """
        @type keyword: str
        @type path: str
        @type iactive: BoolVector
        @type file_type: EnkfFieldFileFormatEnum
        @type report_step: int
        @type selected_case: str
        """

        fs = ERT.ert.getEnkfFsManager().getFileSystem(selected_case)
        if file_type == EnkfFieldFileFormatEnum.ECL_GRDECL_FILE:
            extension = ".grdecl"
        elif file_type == EnkfFieldFileFormatEnum.RMS_ROFF_FILE:
            extension = ".roff"

        iens_list = iactive.createActiveList()
        path_fmt = os.path.join(path, keyword + "_%d" + extension)
        config_node = ERT.ert.ensembleConfig()[keyword]
        init_file = ERT.ert.fieldInitFile(config_node)
        if init_file:
            print('Using init file:%s' % init_file)
        EnkfNode.exportMany(config_node,
                            path_fmt,
                            fs,
                            iens_list,
                            file_type=file_type,
                            arg=init_file)
        return True
Esempio n. 3
0
    def exportGenKw(self, keyword, path, iactive, file_type, report_step,
                    selected_case):
        """
        @type keyword: str
        @type path: str
        @type iactive: BoolVector
        @type file_type: EnkfFieldFileFormatEnum
        @type report_step: int
        @type selected_case: str
        """
        enkf_config_node = ERT.ert.ensembleConfig().getNode(keyword)
        assert isinstance(enkf_config_node, EnkfConfigNode)
        node = EnkfNode(enkf_config_node)
        fs = ERT.ert.getEnkfFsManager().getFileSystem(selected_case)

        for index, value in enumerate(iactive):
            if value:
                if node.tryLoad(fs, NodeId(report_step, index)):
                    gen_kw = GenKw.createCReference(node.valuePointer())
                    filename = str(path + "/" + keyword + "_{0}").format(index)
                    if file_type == "Parameter list":
                        filename += ".txt"
                        gen_kw.exportParameters(filename)
                    else:
                        filename += ".inc"
                        gen_kw.exportTemplate(filename)
Esempio n. 4
0
    def exportGenData(self, keyword, path, iactive, file_type, report_step, state, selected_case):
        """
        @type keyword: str
        @type path: str
        @type iactive: BoolVector
        @type file_type: EnkfFieldFileFormatEnum
        @type report_step: int
        @type state: EnkfStateType
        @type selected_case: str
        """
        fs = self.ert().getEnkfFsManager().getFileSystem(selected_case)
        config_node = self.ert().ensembleConfig().getNode(keyword)
        gen_data_config_node = config_node.getDataModelConfig()

        export_type = gen_data_config_node.getOutputFormat()
        if export_type == GenDataFileType.GEN_DATA_UNDEFINED:
            export_type = gen_data_config_node.getInputFormat()

        node = EnkfNode(config_node)

        for index, active in enumerate(iactive):
            if active:
                node_id = NodeId(int(report_step), index, state)

                if node.tryLoad(fs, node_id):
                    gen_data = node.asGenData()

                    filename  =  str(path + "/" + keyword + "_{0}").format(index) + ".txt"
                    gen_data.export(filename,export_type ,None)
Esempio n. 5
0
    def exportGenKw(self, keyword, path, iactive, file_type, report_step, state, selected_case):
        """
        @type keyword: str
        @type path: str
        @type iactive: BoolVector
        @type file_type: EnkfFieldFileFormatEnum
        @type report_step: int
        @type state: EnkfStateType
        @type selected_case: str
        """
        enkf_config_node = self.ert().ensembleConfig().getNode(keyword)
        assert isinstance(enkf_config_node, EnkfConfigNode)
        node = EnkfNode(enkf_config_node)
        fs = self.ert().getEnkfFsManager().getFileSystem(selected_case)

        for index, value in enumerate(iactive):
            if value:
                if node.tryLoad(fs, NodeId(report_step, index, state)):
                    gen_kw = GenKw.createCReference(node.valuePointer())
                    filename  =  str(path + "/" + keyword + "_{0}").format(index)
                    if file_type == "Parameter list":
                        filename += ".txt"
                        gen_kw.exportParameters(filename)
                    else:
                        filename += ".inc"
                        gen_kw.exportTemplate(filename)
Esempio n. 6
0
    def exportField(self, keyword, path, iactive, file_type, report_step, state, selected_case):
        """
        @type keyword: str
        @type path: str
        @type iactive: BoolVector
        @type file_type: EnkfFieldFileFormatEnum
        @type report_step: int
        @type state: EnkfStateType
        @type selected_case: str
        """

        fs = self.ert().getEnkfFsManager().getFileSystem(selected_case)
        if file_type == EnkfFieldFileFormatEnum.ECL_GRDECL_FILE:
            extension = ".grdecl"
        elif file_type == EnkfFieldFileFormatEnum.RMS_ROFF_FILE:
            extension = ".roff"

        iens_list = iactive.createActiveList( ) 
        path_fmt = os.path.join( path , keyword + "_%d" + extension)
        config_node = self.ert().ensembleConfig()[keyword]
        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 , file_type = file_type , arg = init_file)
        return True
Esempio n. 7
0
    def loadVector(self, plot_block_data, fs, report_step, realization_number):
        """
        @type plot_block_data: PlotBlockData
        @type fs: EnkfFs
        @type report_step: int
        @type realization_number: int
        @rtype PlotBlockVector
        """
        config_node = self.__obs_vector.getConfigNode()

        is_private_container = config_node.getImplementationType() == ErtImplType.CONTAINER
        data_node = EnkfNode(config_node, private=is_private_container)

        node_id = NodeId(report_step, realization_number)

        if data_node.tryLoad(fs, node_id):
            block_obs = self.getBlockObservation(report_step)

            data = DoubleVector()
            for index in range(len(block_obs)):
                value = block_obs.getData(data_node.valuePointer(), index, node_id)
                data.append(value)
            data.permute(self.__permutation_vector)

            plot_block_vector = PlotBlockVector(realization_number, data)
            plot_block_data.addPlotBlockVector(plot_block_vector)
Esempio n. 8
0
    def loadVector(self, plot_block_data, fs, report_step, realization_number):
        """
        @type plot_block_data: PlotBlockData
        @type fs: EnkfFs
        @type report_step: int
        @type realization_number: int
        @rtype PlotBlockVector
        """
        config_node = self.__obs_vector.getConfigNode()

        is_private_container = config_node.getImplementationType() == ErtImplType.CONTAINER
        data_node = EnkfNode(config_node, private=is_private_container)

        node_id = NodeId(report_step, realization_number)

        if data_node.tryLoad(fs, node_id):
            block_obs = self.getBlockObservation(report_step)

            data = DoubleVector()
            for index in range(len(block_obs)):
                value = block_obs.getData(data_node.valuePointer(), index, node_id)
                data.append(value)
            data.permute(self.__permutation_vector)

            plot_block_vector = PlotBlockVector(realization_number, data)
            plot_block_data.addPlotBlockVector(plot_block_vector)
Esempio n. 9
0
    def loadAllCustomKWData(ert, case_name, keys=None):
        """
        @type ert: EnKFMain
        @type case_name: str
        @type keys: list of str
        @rtype: DataFrame
        """
        fs = ert.getEnkfFsManager().getFileSystem(case_name)

        realizations = fs.realizationList(RealizationStateEnum.STATE_HAS_DATA)

        custom_kw_keys = CustomKWCollector.getAllCustomKWKeys(ert)

        if keys is not None:
            custom_kw_keys = [key for key in keys if key in custom_kw_keys
                              ]  # ignore keys that doesn't exist

        custom_kw_data = DataFrame(index=realizations, columns=custom_kw_keys)
        custom_kw_data.index.name = "Realization"

        custom_kw_keys = CustomKWCollector.groupKeys(custom_kw_keys)

        for name in custom_kw_keys:
            ensemble_config_node = ert.ensembleConfig().getNode(name)
            enkf_node = EnkfNode(ensemble_config_node)

            keys = custom_kw_keys[name]

            for realization_number in realizations:
                node_id = NodeId(0, realization_number, EnkfStateType.FORECAST)
                if enkf_node.tryLoad(fs, node_id):
                    custom_kw = enkf_node.asCustomKW()

                    for key in keys:
                        value = custom_kw[key]
                        custom_kw_data["%s:%s" %
                                       (name, key)][realization_number] = value

        return custom_kw_data
Esempio n. 10
0
    def loadAllCustomKWData(ert, case_name, keys=None):
        """
        @type ert: EnKFMain
        @type case_name: str
        @type keys: list of str
        @rtype: DataFrame
        """
        fs = ert.getEnkfFsManager().getFileSystem(case_name)

        realizations = fs.realizationList(RealizationStateEnum.STATE_HAS_DATA)

        custom_kw_keys = CustomKWCollector.getAllCustomKWKeys(ert)

        if keys is not None:
            custom_kw_keys = [key for key in keys if key in custom_kw_keys] # ignore keys that doesn't exist

        custom_kw_data = DataFrame(index=realizations, columns=custom_kw_keys)
        custom_kw_data.index.name = "Realization"

        custom_kw_keys = CustomKWCollector.groupKeys(custom_kw_keys)

        for name in custom_kw_keys:
            ensemble_config_node = ert.ensembleConfig().getNode(name)
            enkf_node = EnkfNode(ensemble_config_node)

            keys = custom_kw_keys[name]

            for realization_number in realizations:
                node_id = NodeId(0, realization_number, EnkfStateType.FORECAST)
                if enkf_node.tryLoad(fs, node_id):
                    custom_kw = enkf_node.asCustomKW()

                    for key in keys:
                        value = custom_kw[key]
                        custom_kw_data["%s:%s" % (name, key)][realization_number] = value

        return custom_kw_data