コード例 #1
0
import sys
from types import IntType, SliceType

from ert.cwrap import CWrapper, CFILE, BaseCClass
from ert.util import UTIL_LIB


class PermutationVector(BaseCClass):
    def __init__(self):
        raise NotImplementedError("Class can not be instantiated directly!")

    def free(self):
        PermutationVector.cNamespace().free(self)


CWrapper.registerObjectType("permutation_vector", PermutationVector)

cwrapper = CWrapper(UTIL_LIB)
PermutationVector.cNamespace().free = cwrapper.prototype(
    "void util_safe_free(permutation_vector)")


# TVector takes advantage of the fact that self.cNamespace belongs to the inheriting class
class VectorTemplate(BaseCClass):
    @classmethod
    def strided_copy(cls, obj, slice_range):
        """
        Will create a new copy according to @slice.

        Mainly a support function to support slice based lookup like
コード例 #2
0
    def load(self, config_file):
        if not os.path.isfile(config_file):
            raise IOError("The observation config file:%s does not exist" %
                          config_file)
        return EnkfObs.cNamespace().load(self, config_file)

    def clear(self):
        EnkfObs.cNamespace().clear(self)

    def free(self):
        EnkfObs.cNamespace().free(self)


cwrapper = CWrapper(ENKF_LIB)
cwrapper.registerObjectType("enkf_obs", EnkfObs)

EnkfObs.cNamespace().alloc = cwrapper.prototype(
    "c_void_p enkf_obs_alloc( history , time_map , ecl_grid , ecl_sum , ens_config )"
)
EnkfObs.cNamespace().free = cwrapper.prototype(
    "void enkf_obs_free( enkf_obs )")
EnkfObs.cNamespace().get_size = cwrapper.prototype(
    "int enkf_obs_get_size( enkf_obs )")
EnkfObs.cNamespace().load = cwrapper.prototype(
    "bool enkf_obs_load( enkf_obs , char*)")
EnkfObs.cNamespace().clear = cwrapper.prototype(
    "void enkf_obs_clear( enkf_obs )")
EnkfObs.cNamespace().alloc_typed_keylist = cwrapper.prototype(
    "stringlist_obj enkf_obs_alloc_typed_keylist(enkf_obs, enkf_obs_impl_type)"
)
コード例 #3
0
        @type iteration_number: int
        @type runpath: int
        @type basename: int
        """
        RunpathList.cNamespace().add(self, realization_number,
                                     iteration_number, runpath, basename)

    def clear(self):
        RunpathList.cNamespace().clear(self)

    def free(self):
        RunpathList.cNamespace().free(self)


cwrapper = CWrapper(ENKF_LIB)
cwrapper.registerObjectType("runpath_list", RunpathList)

RunpathList.cNamespace().free = cwrapper.prototype(
    "void runpath_list_free(runpath_list)")

RunpathList.cNamespace().add = cwrapper.prototype(
    "void runpath_list_add(runpath_list, int, int, char*, char*)")
RunpathList.cNamespace().clear = cwrapper.prototype(
    "void runpath_list_clear(runpath_list)")

RunpathList.cNamespace().size = cwrapper.prototype(
    "int runpath_list_size(runpath_list)")
RunpathList.cNamespace().iens = cwrapper.prototype(
    "int runpath_list_iget_iens(runpath_list, int)")
RunpathList.cNamespace().iteration = cwrapper.prototype(
    "int runpath_list_iget_iter(runpath_list, int)")
コード例 #4
0
ファイル: field_config.py プロジェクト: imclab/ResInsight
    def get_ny(self):
        return FieldConfig.cNamespace().get_ny(self)

    def get_nz(self):
        return FieldConfig.cNamespace().get_nz(self)

    def ijk_active(self, i, j, k):
        return FieldConfig.cNamespace().ijk_active(self, i, j, k)

    def free(self):
        FieldConfig.cNamespace().free(self)


cwrapper = CWrapper(ENKF_LIB)
cwrapper.registerObjectType("field_config", FieldConfig)

FieldConfig.cNamespace().alloc = cwrapper.prototype("c_void_p field_config_alloc_empty(char* , ecl_grid , c_void_p , bool)")  
FieldConfig.cNamespace().free = cwrapper.prototype("void field_config_free( field_config )")
FieldConfig.cNamespace().get_type = cwrapper.prototype("int field_config_get_type(field_config)")
FieldConfig.cNamespace().get_truncation_mode = cwrapper.prototype("int field_config_get_truncation_mode(field_config)")
FieldConfig.cNamespace().get_truncation_min = cwrapper.prototype("double field_config_get_truncation_min(field_config)")
FieldConfig.cNamespace().get_truncation_max = cwrapper.prototype("double field_config_get_truncation_max(field_config)")
FieldConfig.cNamespace().get_init_transform_name = cwrapper.prototype("char* field_config_get_init_transform_name(field_config)")
FieldConfig.cNamespace().get_output_transform_name = cwrapper.prototype("char* field_config_get_output_transform_name(field_config)")
FieldConfig.cNamespace().ijk_active = cwrapper.prototype("bool field_config_ijk_active(field_config, int, int, int)")
FieldConfig.cNamespace().get_nx = cwrapper.prototype("int field_config_get_nx(field_config)")
FieldConfig.cNamespace().get_ny = cwrapper.prototype("int field_config_get_ny(field_config)")
FieldConfig.cNamespace().get_nz = cwrapper.prototype("int field_config_get_nz(field_config)")
FieldConfig.cNamespace().get_grid = cwrapper.prototype("c_void_p field_config_get_grid(field_config)")  #todo: fix return type
コード例 #5
0
ファイル: hash.py プロジェクト: jonerduarte/ert
        if isinstance(value, float):
            DoubleHash.cNamespace().insert_double(self, key, value)
        else:
            raise ValueError("DoubleHash does not support type: %s" % value.__class__)


    def __getitem__(self, key):
        if key in self:
            return DoubleHash.cNamespace().get_double(self, key)
        else:
            raise KeyError("Hash does not have key: %s" % key)


cwrapper = CWrapper(UTIL_LIB)
CWrapper.registerObjectType("hash", Hash) # c_void_p type
CWrapper.registerObjectType("integer_hash", IntegerHash)
CWrapper.registerObjectType("string_hash", StringHash)
CWrapper.registerObjectType("double_hash", DoubleHash)

Hash.cNamespace().alloc = cwrapper.prototype("long hash_alloc()")
Hash.cNamespace().free = cwrapper.prototype("void hash_free(hash)")
Hash.cNamespace().size = cwrapper.prototype("int hash_get_size(hash)")
Hash.cNamespace().keys = cwrapper.prototype("stringlist_obj hash_alloc_stringlist(hash)")
Hash.cNamespace().has_key = cwrapper.prototype("bool hash_has_key(hash, char*)")

Hash.cNamespace().get = cwrapper.prototype("c_void_p hash_get(hash, char*)")
IntegerHash.cNamespace().get_int = cwrapper.prototype("int hash_get_int(hash, char*)")
DoubleHash.cNamespace().get_double = cwrapper.prototype("double hash_get_double(hash, char*)")
StringHash.cNamespace().get_string = cwrapper.prototype("char* hash_get_string(hash, char*)")
コード例 #6
0
ファイル: enkf_config_node.py プロジェクト: chflo/ert
        elif implementation_type == ErtImplType.GEN_KW:
            return self.getKeywordModelConfig()
        elif implementation_type == ErtImplType.CUSTOM_KW:
            return self.getCustomKeywordModelConfig()
        elif implementation_type == ErtImplType.SUMMARY:
            return SummaryConfig.createCReference(self.getPointerReference(), parent=self)
        else:
            print("[EnkfConfigNode::getModelConfig()] Unhandled implementation model type: %i" % implementation_type)
            # raise NotImplementedError("Unknown model type: %i" % type)

    def getKey(self):
        return EnkfConfigNode.cNamespace().get_key( self )


cwrapper = CWrapper(ENKF_LIB)
cwrapper.registerObjectType("enkf_config_node", EnkfConfigNode)

EnkfConfigNode.cNamespace().free = cwrapper.prototype("void enkf_config_node_free(enkf_config_node)")
EnkfConfigNode.cNamespace().get_ref = cwrapper.prototype("c_void_p enkf_config_node_get_ref(enkf_config_node)") #todo: fix return type
EnkfConfigNode.cNamespace().get_impl_type = cwrapper.prototype("ert_impl_type_enum enkf_config_node_get_impl_type(enkf_config_node)")

EnkfConfigNode.cNamespace().get_enkf_outfile = cwrapper.prototype("char* enkf_config_node_get_enkf_outfile(enkf_config_node)")
EnkfConfigNode.cNamespace().get_min_std_file = cwrapper.prototype("char* enkf_config_node_get_min_std_file(enkf_config_node)")
EnkfConfigNode.cNamespace().get_enkf_infile = cwrapper.prototype("char* enkf_config_node_get_enkf_infile(enkf_config_node)")
EnkfConfigNode.cNamespace().get_init_file_fmt = cwrapper.prototype("char* enkf_config_node_get_init_file_fmt(enkf_config_node)")
EnkfConfigNode.cNamespace().get_var_type = cwrapper.prototype("enkf_var_type_enum enkf_config_node_get_var_type(enkf_config_node)") #todo: fix return type as enum
EnkfConfigNode.cNamespace().get_key = cwrapper.prototype("char* enkf_config_node_get_key(enkf_config_node)") 
EnkfConfigNode.cNamespace().get_obs_keys = cwrapper.prototype("stringlist_ref enkf_config_node_get_obs_keys(enkf_config_node)")
EnkfConfigNode.cNamespace().alloc_summary_node = cwrapper.prototype("enkf_config_node_obj enkf_config_node_alloc_summary(char*, load_fail_type)")
EnkfConfigNode.cNamespace().alloc_field_node = cwrapper.prototype("enkf_config_node_obj enkf_config_node_alloc_field(char*, ecl_grid, c_void_p, bool)")
EnkfConfigNode.cNamespace().update_state_field = cwrapper.prototype("void enkf_config_node_update_state_field(enkf_config_node, enkf_truncation_type_enum, double, double)")
コード例 #7
0
ファイル: enkf_config_node.py プロジェクト: imclab/ResInsight
        elif implementation_type == ErtImplType.GEN_KW:
            return self.getKeywordModelConfig()
        elif implementation_type == ErtImplType.CUSTOM_KW:
            return self.getCustomKeywordModelConfig()
        elif implementation_type == ErtImplType.SUMMARY:
            return SummaryConfig.createCReference(self.getPointerReference(),
                                                  parent=self)
        else:
            print(
                "[EnkfConfigNode::getModelConfig()] Unhandled implementation model type: %i"
                % implementation_type)
            # raise NotImplementedError("Unknown model type: %i" % type)


cwrapper = CWrapper(ENKF_LIB)
cwrapper.registerObjectType("enkf_config_node", EnkfConfigNode)

EnkfConfigNode.cNamespace().free = cwrapper.prototype(
    "void enkf_config_node_free(enkf_config_node)")
EnkfConfigNode.cNamespace().get_ref = cwrapper.prototype(
    "c_void_p enkf_config_node_get_ref(enkf_config_node)"
)  #todo: fix return type
EnkfConfigNode.cNamespace().get_impl_type = cwrapper.prototype(
    "ert_impl_type_enum enkf_config_node_get_impl_type(enkf_config_node)")

EnkfConfigNode.cNamespace().get_enkf_outfile = cwrapper.prototype(
    "char* enkf_config_node_get_enkf_outfile(enkf_config_node)")
EnkfConfigNode.cNamespace().get_min_std_file = cwrapper.prototype(
    "char* enkf_config_node_get_min_std_file(enkf_config_node)")
EnkfConfigNode.cNamespace().get_enkf_infile = cwrapper.prototype(
    "char* enkf_config_node_get_enkf_infile(enkf_config_node)")
コード例 #8
0
        raise NotImplementedError("Class can not be instantiated directly!")

    def hasWorkflow(self):
        """ @rtype: bool """
        return PostSimulationHook.cNamespace().has_workflow(self)

    def getWorkflow(self):
        """ @rtype: Workflow """
        return PostSimulationHook.cNamespace().get_workflow(self)

    def checkRunpathListFile(self):
        """ @rtype: bool """
        runpath_list_file = PostSimulationHook.cNamespace().get_runpath_list_file(self)

        if not os.path.exists(runpath_list_file):
            sys.stderr.write("** Warning: the file: %s with a list of runpath directories was not found - QC workflow wil probably fail.\n" % runpath_list_file)

    def getRunpathList(self):
        """ @rtype: RunpathList """
        return PostSimulationHook.cNamespace().get_runpath_list(self)

cwrapper = CWrapper(ENKF_LIB)

cwrapper.registerObjectType("qc_module", PostSimulationHook)

PostSimulationHook.cNamespace().has_workflow = cwrapper.prototype("bool qc_module_has_workflow(qc_module)")
PostSimulationHook.cNamespace().get_workflow = cwrapper.prototype("workflow_ref qc_module_get_workflow(qc_module)")
PostSimulationHook.cNamespace().get_runpath_list_file = cwrapper.prototype("char* qc_module_get_runpath_list_file(qc_module)")
PostSimulationHook.cNamespace().get_runpath_list = cwrapper.prototype("runpath_list_ref qc_module_get_runpath_list(qc_module)")

コード例 #9
0
ファイル: post_simulation_hook.py プロジェクト: bramirex/ert
        """ @rtype: Workflow """
        return PostSimulationHook.cNamespace().get_workflow(self)

    def checkRunpathListFile(self):
        """ @rtype: bool """
        runpath_list_file = PostSimulationHook.cNamespace(
        ).get_runpath_list_file(self)

        if not os.path.exists(runpath_list_file):
            sys.stderr.write(
                "** Warning: the file: %s with a list of runpath directories was not found - QC workflow wil probably fail.\n"
                % runpath_list_file)

    def getRunpathList(self):
        """ @rtype: RunpathList """
        return PostSimulationHook.cNamespace().get_runpath_list(self)


cwrapper = CWrapper(ENKF_LIB)

cwrapper.registerObjectType("hook_manager", PostSimulationHook)

PostSimulationHook.cNamespace().has_workflow = cwrapper.prototype(
    "bool hook_manager_has_workflow(hook_manager)")
PostSimulationHook.cNamespace().get_workflow = cwrapper.prototype(
    "workflow_ref hook_manager_get_workflow(hook_manager)")
PostSimulationHook.cNamespace().get_runpath_list_file = cwrapper.prototype(
    "char* hook_manager_get_runpath_list_file(hook_manager)")
PostSimulationHook.cNamespace().get_runpath_list = cwrapper.prototype(
    "runpath_list_ref hook_manager_get_runpath_list(hook_manager)")
コード例 #10
0
ファイル: test_cwrap.py プロジェクト: imclab/ResInsight
test_lib = clib.ert_load(
    "libert_util"
)  # create a local namespace (so we don't overwrite StringList)
cwrapper = CWrapper(test_lib)


class StringListTest(BaseCClass):
    def __init__(self):
        c_pointer = self.cNamespace().alloc()
        super(StringListTest, self).__init__(c_pointer)

    def free(self):
        StringListTest.cNamespace().free(self)


CWrapper.registerObjectType("stringlisttest", StringListTest)

StringListTest.cNamespace().alloc = cwrapper.prototype(
    "c_void_p stringlist_alloc_new( )")
StringListTest.cNamespace().free = cwrapper.prototype(
    "void stringlist_free(stringlisttest )")


class CWrapTest(ExtendedTestCase):
    def test_return_type(self):
        stringlist_alloc = cwrapper.prototype(
            "c_void_p stringlist_alloc_new( )")
        string_list1 = StringListTest()

        stringlist_alloc = cwrapper.prototype(
            "stringlisttest_obj stringlist_alloc_new( )")
コード例 #11
0
ファイル: time_vector.py プロジェクト: danielfmva/ert
            ct = CTime(currentTime)
            timeVector.append(ct)
            currentTime = timeVector.nextTime(num, timeUnit)

        return timeVector

    def getDataPtr(self):
        raise NotImplementedError(
            "The getDataPtr() function is not implemented for time_t vectors")


#################################################################

cwrapper = CWrapper(UTIL_LIB)

CWrapper.registerObjectType("time_t_vector", TimeVector)

TimeVector.cNamespace().alloc = cwrapper.prototype(
    "c_void_p time_t_vector_alloc(int, time_t )")
TimeVector.cNamespace().alloc_copy = cwrapper.prototype(
    "time_t_vector_obj time_t_vector_alloc_copy(time_t_vector )")
TimeVector.cNamespace().strided_copy = cwrapper.prototype(
    "time_t_vector_obj time_t_vector_alloc_strided_copy(time_t_vector , time_t , time_t , time_t)"
)
TimeVector.cNamespace().free = cwrapper.prototype(
    "void   time_t_vector_free( time_t_vector )")
TimeVector.cNamespace().iget = cwrapper.prototype(
    "time_t   time_t_vector_iget( time_t_vector , int )")
TimeVector.cNamespace().safe_iget = cwrapper.prototype(
    "time_t   time_t_vector_safe_iget( time_t_vector , int )")
TimeVector.cNamespace().iset = cwrapper.prototype(
コード例 #12
0
    def scale(self, S, E=None, D=None, R=None, D_obs=None):
        assert isinstance(S, Matrix)
        assert isinstance(E, (Matrix, NoneType))
        assert isinstance(D, (Matrix, NoneType))
        assert isinstance(R, (Matrix, NoneType))
        assert isinstance(D_obs, (Matrix, NoneType))
        ObsData.cNamespace().scale(self, S, E, D, R, D_obs)


    def free(self):
        ObsData.cNamespace().free(self)



cwrapper = CWrapper(ENKF_LIB)
cwrapper.registerObjectType("obs_data", ObsData)

ObsData.cNamespace().alloc       = cwrapper.prototype("c_void_p obs_data_alloc(double)")
ObsData.cNamespace().free        = cwrapper.prototype("void obs_data_free(obs_data)")
ObsData.cNamespace().total_size  = cwrapper.prototype("int obs_data_get_total_size(obs_data)")
ObsData.cNamespace().iget_value  = cwrapper.prototype("double obs_data_iget_value(obs_data)")
ObsData.cNamespace().iget_std  = cwrapper.prototype("double obs_data_iget_std(obs_data)")
ObsData.cNamespace().add_block   = cwrapper.prototype("obs_block_ref obs_data_add_block(obs_data , char* , int , matrix , bool)")

ObsData.cNamespace().allocdObs   = cwrapper.prototype("matrix_obj obs_data_allocdObs(obs_data)")
ObsData.cNamespace().allocR      = cwrapper.prototype("matrix_obj obs_data_allocR(obs_data)")
ObsData.cNamespace().allocD      = cwrapper.prototype("matrix_obj obs_data_allocD(obs_data , matrix , matrix)")
ObsData.cNamespace().allocE      = cwrapper.prototype("matrix_obj obs_data_allocE(obs_data , rng , int)")
ObsData.cNamespace().scale       = cwrapper.prototype("void obs_data_scale(obs_data, matrix, matrix, matrix, matrix, matrix)")
ObsData.cNamespace().scale_matrix = cwrapper.prototype("void obs_data_scale_matrix(obs_data, matrix)")
ObsData.cNamespace().scale_Rmatrix = cwrapper.prototype("void obs_data_scale_Rmatrix(obs_data, matrix)")
コード例 #13
0
            sys.stderr.write(
                "** Warning: the file: %s with a list of runpath directories was not found - hook workflow will probably fail.\n"
                % runpath_list_file)

    def getRunpathList(self):
        """ @rtype: RunpathList """
        return HookManager.cNamespace().get_runpath_list(self)

    def runWorkflows(self, run_time, ert_self):

        workflow_list = ert_self.getWorkflowList()
        for hook_workflow in self:

            if (hook_workflow.getRunMode() is not run_time):
                continue

            workflow = hook_workflow.getWorkflow()
            workflow.run(ert_self, context=workflow_list.getContext())


cwrapper = CWrapper(ENKF_LIB)

cwrapper.registerObjectType("hook_manager", HookManager)

HookManager.cNamespace().get_runpath_list_file = cwrapper.prototype(
    "char* hook_manager_get_runpath_list_file(hook_manager)")
HookManager.cNamespace().iget_hook_workflow = cwrapper.prototype(
    "hook_workflow_ref hook_manager_iget_hook_workflow(hook_manager, int)")
HookManager.cNamespace().size = cwrapper.prototype(
    "int hook_manager_get_size(hook_manager)")
コード例 #14
0
    def free(self):
        GenData.cNamespace().free(self)

    def export(self, file_name, file_format_type, fortio):
        """
        @type: str
        @type: GenDataFileType
        @type: FortIO
        """
        GenData.cNamespace().export(self, file_name, file_format_type, fortio)

    def getData(self):
        data = DoubleVector()
        GenData.cNamespace().export_data(self, data)
        return data


cwrapper = CWrapper(ENKF_LIB)
cwrapper.registerObjectType("gen_data", GenData)

GenData.cNamespace().alloc = cwrapper.prototype("c_void_p gen_data_alloc()")
GenData.cNamespace().free = cwrapper.prototype("void gen_data_free(gen_data)")
GenData.cNamespace().size = cwrapper.prototype(
    "int gen_data_get_size(gen_data)")

GenData.cNamespace().export = cwrapper.prototype(
    "void gen_data_export(gen_data , char*, gen_data_file_format_type, fortio)"
)
GenData.cNamespace().export_data = cwrapper.prototype(
    "void gen_data_export_data(gen_data , double_vector)")
コード例 #15
0
ファイル: hook_manager.py プロジェクト: Thif/ert-1
    def checkRunpathListFile(self):
        """ @rtype: bool """
        runpath_list_file = HookManager.cNamespace().get_runpath_list_file(self)

        if not os.path.exists(runpath_list_file):
            sys.stderr.write("** Warning: the file: %s with a list of runpath directories was not found - hook workflow will probably fail.\n" % runpath_list_file)
    
    def getRunpathList(self):
        """ @rtype: RunpathList """
        return HookManager.cNamespace().get_runpath_list(self)
    
    def hasPostHookWorkflow(self):
        """ @rtype: bool """
        return HookManager.cNamespace().has_post_hook_workflow(self)

    def getPostHookWorkflow(self):
        """ @rtype: HookWorkflow """
        return HookManager.cNamespace().get_post_hook_workflow(self)
    
    
cwrapper = CWrapper(ENKF_LIB)

cwrapper.registerObjectType("hook_manager", HookManager)

HookManager.cNamespace().get_runpath_list_file = cwrapper.prototype("char* hook_manager_get_runpath_list_file(hook_manager)")
HookManager.cNamespace().has_hook_workflow = cwrapper.prototype("bool hook_manager_has_hook_workflow(hook_manager)")
HookManager.cNamespace().get_hook_workflow = cwrapper.prototype("hook_workflow_ref hook_manager_get_hook_workflow(hook_manager)")

HookManager.cNamespace().has_post_hook_workflow = cwrapper.prototype("bool hook_manager_has_post_hook_workflow(hook_manager)")
HookManager.cNamespace().get_post_hook_workflow = cwrapper.prototype("hook_workflow_ref hook_manager_get_post_hook_workflow(hook_manager)")
コード例 #16
0
#  See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
#  for more details.

from ert.cwrap import CWrapper
from ert.util import UTIL_LIB, VectorTemplate


class DoubleVector(VectorTemplate):
    default_format = "%8.4f"

    def __init__(self, default_value=0, initial_size=0):
        super(DoubleVector, self).__init__(default_value, initial_size)


cwrapper = CWrapper(UTIL_LIB)
CWrapper.registerObjectType("double_vector", DoubleVector)

DoubleVector.cNamespace().alloc = cwrapper.prototype(
    "c_void_p   double_vector_alloc( int , double )")
DoubleVector.cNamespace().alloc_copy = cwrapper.prototype(
    "double_vector_obj   double_vector_alloc_copy( double_vector )")
DoubleVector.cNamespace().strided_copy = cwrapper.prototype(
    "double_vector_obj   double_vector_alloc_strided_copy( double_vector , int , int , int)"
)
DoubleVector.cNamespace().free = cwrapper.prototype(
    "void   double_vector_free( double_vector )")
DoubleVector.cNamespace().iget = cwrapper.prototype(
    "double double_vector_iget( double_vector , int )")
DoubleVector.cNamespace().safe_iget = cwrapper.prototype(
    "double double_vector_safe_iget(double_vector , int )")
DoubleVector.cNamespace().iset = cwrapper.prototype(
コード例 #17
0
        raise NotImplementedError("Class can not be instantiated directly!")

    def hasWorkflow(self):
        """ @rtype: bool """
        return PostSimulationHook.cNamespace().has_workflow(self)

    def getWorkflow(self):
        """ @rtype: Workflow """
        return PostSimulationHook.cNamespace().get_workflow(self)

    def checkRunpathListFile(self):
        """ @rtype: bool """
        runpath_list_file = PostSimulationHook.cNamespace().get_runpath_list_file(self)

        if not os.path.exists(runpath_list_file):
            sys.stderr.write("** Warning: the file: %s with a list of runpath directories was not found - QC workflow wil probably fail.\n" % runpath_list_file)

    def getRunpathList(self):
        """ @rtype: RunpathList """
        return PostSimulationHook.cNamespace().get_runpath_list(self)

cwrapper = CWrapper(ENKF_LIB)

cwrapper.registerObjectType("hook_manager", PostSimulationHook)

PostSimulationHook.cNamespace().has_workflow = cwrapper.prototype("bool hook_manager_has_workflow(hook_manager)")
PostSimulationHook.cNamespace().get_workflow = cwrapper.prototype("workflow_ref hook_manager_get_workflow(hook_manager)")
PostSimulationHook.cNamespace().get_runpath_list_file = cwrapper.prototype("char* hook_manager_get_runpath_list_file(hook_manager)")
PostSimulationHook.cNamespace().get_runpath_list = cwrapper.prototype("runpath_list_ref hook_manager_get_runpath_list(hook_manager)")

コード例 #18
0
ファイル: local_ministep.py プロジェクト: statoil-travis/ert
    def attachObsset(self, obs_set):
        assert isinstance(obs_set, LocalObsdata)
        LocalMinistep.cNamespace().attach_obsset(self,obs_set)
        
    def attachDataset(self, dataset):
        assert isinstance(dataset, LocalDataset)
        LocalMinistep.cNamespace().attach_dataset(self,dataset)  
        
    def getLocalObsData(self):
        """ @rtype: LocalObsdata """
        return LocalMinistep.cNamespace().get_local_obs_data(self)
    
    def getName(self):
        """ @rtype: str """
        return LocalMinistep.cNamespace().name(self)         
        
    def free(self):
        LocalMinistep.cNamespace().free(self) 

cwrapper = CWrapper(ENKF_LIB)
cwrapper.registerObjectType("local_ministep", LocalMinistep)

LocalMinistep.cNamespace().alloc               = cwrapper.prototype("c_void_p local_ministep_alloc(char*)")
LocalMinistep.cNamespace().add_node            = cwrapper.prototype("void local_ministep_add_obsdata_node(local_ministep,local_obsdata_node)")
LocalMinistep.cNamespace().get_local_obs_data  = cwrapper.prototype("local_obsdata_ref local_ministep_get_obsdata(local_ministep)")
LocalMinistep.cNamespace().free                = cwrapper.prototype("void local_ministep_free(local_ministep)")
LocalMinistep.cNamespace().attach_obsset       = cwrapper.prototype("void local_ministep_add_obsdata(local_ministep,local_obsdata)")
LocalMinistep.cNamespace().attach_dataset      = cwrapper.prototype("void local_ministep_add_dataset(local_ministep,local_dataset)")
LocalMinistep.cNamespace().name                = cwrapper.prototype("char* local_ministep_get_name(local_ministep)")

コード例 #19
0
ファイル: enkf_main.py プロジェクト: bramirex/ert
            self,
            fs,
            iactive,
            init_mode=EnkfInitModeEnum.INIT_CONDITIONAL,
            iteration=0):
        return EnKFMain.cNamespace().alloc_run_context_ENSEMBLE_EXPERIMENT(
            self, fs, iactive, init_mode, iteration)

    def getRunpathList(self):
        return EnKFMain.cNamespace().get_runpath_list(self)


##################################################################

cwrapper = CWrapper(ENKF_LIB)
cwrapper.registerObjectType("enkf_main", EnKFMain)

EnKFMain.cNamespace().bootstrap = cwrapper.prototype(
    "c_void_p enkf_main_bootstrap(char*, bool, bool)")
EnKFMain.cNamespace().free = cwrapper.prototype(
    "void enkf_main_free(enkf_main)")

EnKFMain.cNamespace().get_ensemble_size = cwrapper.prototype(
    "int enkf_main_get_ensemble_size( enkf_main )")
EnKFMain.cNamespace().get_ens_config = cwrapper.prototype(
    "ens_config_ref enkf_main_get_ensemble_config( enkf_main )")
EnKFMain.cNamespace().get_model_config = cwrapper.prototype(
    "model_config_ref enkf_main_get_model_config( enkf_main )")
EnKFMain.cNamespace().get_local_config = cwrapper.prototype(
    "local_config_ref enkf_main_get_local_config( enkf_main )")
EnKFMain.cNamespace().get_analysis_config = cwrapper.prototype(
コード例 #20
0
ファイル: cpolyline.py プロジェクト: akva2/ert
        p2 = GeometryTools.nearestPointOnPolyline( end2 , target )
            
        d1 = GeometryTools.distance( p1 , end1 )
        d2 = GeometryTools.distance( p2 , end2 )

        if d1 < d2:
            return [end1 , p1]
        else:
            return [end2 , p2]




#################################################################

cwrapper = CWrapper(ERT_GEOMETRY_LIB)
cwrapper.registerObjectType("geo_polygon", CPolyline)

CPolyline.cNamespace().alloc_new          = cwrapper.prototype("c_void_p        geo_polygon_alloc( char* )")
CPolyline.cNamespace().fread_alloc_irap   = cwrapper.prototype("geo_polygon_obj geo_polygon_fload_alloc_irap( char* )")
CPolyline.cNamespace().add_point          = cwrapper.prototype("void     geo_polygon_add_point( geo_polygon , double , double )")
CPolyline.cNamespace().add_point_front    = cwrapper.prototype("void     geo_polygon_add_point_front( geo_polygon , double , double )")
CPolyline.cNamespace().free               = cwrapper.prototype("void     geo_polygon_free( geo_polygon )")
CPolyline.cNamespace().size               = cwrapper.prototype("int      geo_polygon_get_size( geo_polygon )")
CPolyline.cNamespace().iget_xy            = cwrapper.prototype("void     geo_polygon_iget_xy( geo_polygon , int , double* , double* )")
CPolyline.cNamespace().segment_intersects = cwrapper.prototype("bool     geo_polygon_segment_intersects( geo_polygon , double , double, double , double)")
CPolyline.cNamespace().get_name           = cwrapper.prototype("char*    geo_polygon_get_name( geo_polygon  )")
CPolyline.cNamespace().set_name           = cwrapper.prototype("void     geo_polygon_set_name( geo_polygon , char*  )")
CPolyline.cNamespace().segment_length     = cwrapper.prototype("double   geo_polygon_get_length( geo_polygon)")
CPolyline.cNamespace().equal              = cwrapper.prototype("bool     geo_polygon_equal( geo_polygon , geo_polygon )")
コード例 #21
0
ファイル: double_vector.py プロジェクト: danielfmva/ert
#  See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html> 
#  for more details.

from ert.cwrap import CWrapper
from ert.util import UTIL_LIB, VectorTemplate


class DoubleVector(VectorTemplate):
    default_format       = "%8.4f"

    def __init__(self, default_value=0, initial_size=0):
        super(DoubleVector, self).__init__(default_value, initial_size)


cwrapper = CWrapper(UTIL_LIB)
CWrapper.registerObjectType("double_vector", DoubleVector)


DoubleVector.cNamespace().alloc            = cwrapper.prototype("c_void_p   double_vector_alloc( int , double )")
DoubleVector.cNamespace().alloc_copy       = cwrapper.prototype("double_vector_obj   double_vector_alloc_copy( double_vector )")
DoubleVector.cNamespace().strided_copy     = cwrapper.prototype("double_vector_obj   double_vector_alloc_strided_copy( double_vector , int , int , int)")
DoubleVector.cNamespace().free             = cwrapper.prototype("void   double_vector_free( double_vector )")
DoubleVector.cNamespace().iget             = cwrapper.prototype("double double_vector_iget( double_vector , int )")
DoubleVector.cNamespace().safe_iget        = cwrapper.prototype("double double_vector_safe_iget(double_vector , int )")
DoubleVector.cNamespace().iset             = cwrapper.prototype("double double_vector_iset( double_vector , int , double)")
DoubleVector.cNamespace().size             = cwrapper.prototype("int    double_vector_size( double_vector )")
DoubleVector.cNamespace().append           = cwrapper.prototype("void   double_vector_append( double_vector , double )")
DoubleVector.cNamespace().idel_block       = cwrapper.prototype("void   double_vector_idel_block( double_vector , int , int )")
DoubleVector.cNamespace().pop              = cwrapper.prototype("double double_vector_pop( double_vector )")
DoubleVector.cNamespace().idel             = cwrapper.prototype("void   double_vector_idel( double_vector , int )")
DoubleVector.cNamespace().lshift           = cwrapper.prototype("void   double_vector_lshift( double_vector , int )")
コード例 #22
0
        self.__test_name = test_name
        self.__model_config = model_config
        self.__site_config = site_config
        self.__store_area = store_area
        self.__test_context = ErtTest(self.__test_name, self.__model_config, site_config=self.__site_config, store_area=self.__store_area)


    def __enter__(self):
        """ @rtype: ErtTest """
        return self.__test_context


    def __exit__(self, exc_type, exc_val, exc_tb):
        del self.__test_context
        return False


    def getErt(self):
        return self.__test_context.getErt()



cwrapper = CWrapper(ENKF_LIB)
cwrapper.registerObjectType("ert_test", ErtTest)

ErtTest.cNamespace().alloc = cwrapper.prototype("c_void_p ert_test_context_alloc( char* , char* , char*)")
ErtTest.cNamespace().set_store = cwrapper.prototype("c_void_p ert_test_context_set_store( ert_test , bool)")
ErtTest.cNamespace().free = cwrapper.prototype("void ert_test_context_free( ert_test )")
ErtTest.cNamespace().get_enkf_main = cwrapper.prototype("enkf_main_ref ert_test_context_get_main( ert_test )")

コード例 #23
0
ファイル: layer.py プロジェクト: eoia/ert
    def cellsEqual(self , value):
        """
        Will return a list [(i1,j1),(i2,j2) , ...(in,jn)] of all cells with value @value.
        """
        i_list = IntVector()
        j_list = IntVector()
        Layer.cNamespace().cells_equal( self , value , i_list , j_list)
        ij_list= []
        for (i,j) in zip(i_list , j_list):
            ij_list.append( (i,j) )
        return ij_list
        


cwrapper = CWrapper(ECL_LIB)
CWrapper.registerObjectType("layer", Layer)
Layer.cNamespace().alloc        = cwrapper.prototype("c_void_p  layer_alloc(int,  int)")
Layer.cNamespace().copy         = cwrapper.prototype("void      layer_memcpy(layer , layer)")
Layer.cNamespace().free         = cwrapper.prototype("void      layer_free(layer)")
Layer.cNamespace().get_nx       = cwrapper.prototype("int       layer_get_nx(layer)")
Layer.cNamespace().get_ny       = cwrapper.prototype("int       layer_get_ny(layer)")
Layer.cNamespace().set_cell     = cwrapper.prototype("void      layer_iset_cell_value(layer , int , int , int)")
Layer.cNamespace().get_cell     = cwrapper.prototype("int       layer_iget_cell_value(layer , int , int )")
Layer.cNamespace().get_bottom_barrier = cwrapper.prototype("bool layer_iget_bottom_barrier(layer , int , int )")
Layer.cNamespace().get_left_barrier = cwrapper.prototype("bool layer_iget_left_barrier(layer , int , int )")
Layer.cNamespace().cell_contact = cwrapper.prototype("bool      layer_cell_contact(layer , int , int , int , int)")
Layer.cNamespace().add_barrier  = cwrapper.prototype("void      layer_add_barrier(layer , int , int)")
Layer.cNamespace().add_ijbarrier  = cwrapper.prototype("void      layer_add_ijbarrier(layer , int , int, int , int)")
Layer.cNamespace().add_interp_barrier = cwrapper.prototype("void  layer_add_interp_barrier(layer , int , int)")
Layer.cNamespace().clear_cells = cwrapper.prototype("void layer_clear_cells(layer)")
Layer.cNamespace().assign = cwrapper.prototype("void layer_assign(layer , int)")
コード例 #24
0
ファイル: layer.py プロジェクト: imclab/ResInsight
    def cellsEqual(self, value):
        """
        Will return a list [(i1,j1),(i2,j2) , ...(in,jn)] of all cells with value @value.
        """
        i_list = IntVector()
        j_list = IntVector()
        Layer.cNamespace().cells_equal(self, value, i_list, j_list)
        ij_list = []
        for (i, j) in zip(i_list, j_list):
            ij_list.append((i, j))
        return ij_list


cwrapper = CWrapper(ECL_LIB)
CWrapper.registerObjectType("layer", Layer)
Layer.cNamespace().alloc = cwrapper.prototype(
    "c_void_p  layer_alloc(int,  int)")
Layer.cNamespace().copy = cwrapper.prototype(
    "void      layer_memcpy(layer , layer)")
Layer.cNamespace().free = cwrapper.prototype("void      layer_free(layer)")
Layer.cNamespace().get_nx = cwrapper.prototype("int       layer_get_nx(layer)")
Layer.cNamespace().get_ny = cwrapper.prototype("int       layer_get_ny(layer)")
Layer.cNamespace().set_cell = cwrapper.prototype(
    "void      layer_iset_cell_value(layer , int , int , int)")
Layer.cNamespace().get_cell = cwrapper.prototype(
    "int       layer_iget_cell_value(layer , int , int )")
Layer.cNamespace().get_bottom_barrier = cwrapper.prototype(
    "bool layer_iget_bottom_barrier(layer , int , int )")
Layer.cNamespace().get_left_barrier = cwrapper.prototype(
    "bool layer_iget_left_barrier(layer , int , int )")
コード例 #25
0
ファイル: model_config.py プロジェクト: bramirex/ert
    def getJobnameFormat(self):
        """ @rtype: str """
        return ModelConfig.cNamespace().get_jobname_fmt(self)

    def getEnspath(self):
        """ @rtype: str """
        return ModelConfig.cNamespace().get_enspath(self)

    def getRunpathFormat(self):
        """ @rtype: PathFormat """
        return ModelConfig.cNamespace().get_runpath_fmt(self)


cwrapper = CWrapper(ENKF_LIB)
cwrapper.registerObjectType("model_config", ModelConfig)

ModelConfig.cNamespace().free = cwrapper.prototype(
    "void model_config_free( model_config )")
ModelConfig.cNamespace().get_enkf_sched_file = cwrapper.prototype(
    "char* model_config_get_enkf_sched_file( model_config )")
ModelConfig.cNamespace().set_enkf_sched_file = cwrapper.prototype(
    "void model_config_set_enkf_sched_file( model_config, char*)")
ModelConfig.cNamespace().get_forward_model = cwrapper.prototype(
    "forward_model_ref model_config_get_forward_model(model_config)")
ModelConfig.cNamespace().get_max_internal_submit = cwrapper.prototype(
    "int model_config_get_max_internal_submit(model_config)")
ModelConfig.cNamespace().set_max_internal_submit = cwrapper.prototype(
    "void model_config_set_max_internal_submit(model_config, int)")
ModelConfig.cNamespace().get_case_table_file = cwrapper.prototype(
    "char* model_config_get_case_table_file(model_config)")
コード例 #26
0
ファイル: config_parser.py プロジェクト: eoia/ert
        if os.path.exists(config_file):
            config_content = ConfigParser.cNamespace().parse(self, config_file, comment_string, include_kw, define_kw, unrecognized, validate)
            if config_content.isValid():
                return config_content
            else:
                raise Exception("Parsing:%s failed" % config_file)
        else:
            raise IOError("File: %s does not exists" % config_file)


    def free(self):
        ConfigParser.cNamespace().free(self)


cwrapper = CWrapper(CONFIG_LIB)
cwrapper.registerObjectType("config_parser", ConfigParser)
cwrapper.registerObjectType("schema_item", SchemaItem)


ConfigParser.cNamespace().alloc = cwrapper.prototype("c_void_p config_alloc( )")
ConfigParser.cNamespace().add = cwrapper.prototype("schema_item_ref config_add_schema_item( config_parser , char* , bool)")
ConfigParser.cNamespace().free = cwrapper.prototype("void config_free( config_parser )")
ConfigParser.cNamespace().parse = cwrapper.prototype("config_content_obj config_parse( config_parser , char* , char* , char* , char* , config_unrecognized_enum , bool )")
ConfigParser.cNamespace().get_schema_item = cwrapper.prototype("schema_item_ref config_get_schema_item( config_parser , char*)")
ConfigParser.cNamespace().has_schema_item = cwrapper.prototype("bool config_has_schema_item( config_parser , char*)")

SchemaItem.cNamespace().alloc = cwrapper.prototype("c_void_p config_schema_item_alloc( char* , bool )")
SchemaItem.cNamespace().free = cwrapper.prototype("void config_schema_item_free( schema_item )")
SchemaItem.cNamespace().iget_type = cwrapper.prototype("config_content_type_enum config_schema_item_iget_type( schema_item, int)")
SchemaItem.cNamespace().iset_type = cwrapper.prototype("void config_schema_item_iset_type( schema_item , int , config_content_type_enum)")
SchemaItem.cNamespace().set_argc_minmax = cwrapper.prototype("void config_schema_item_set_argc_minmax( schema_item , int , int)")
コード例 #27
0
ファイル: arg_pack.py プロジェクト: atgeirr/ResInsight
            ArgPack.cNamespace().append_int( self , data )
        elif isinstance(data , float):
            ArgPack.cNamespace().append_double( self , data )
        elif isinstance(data , BaseCClass):
            ArgPack.cNamespace().append_ptr( self , BaseCClass.from_param( data ) )
            self.child_list.append( data )
        else:
            raise TypeError("Can only add int/double/basecclass")

        
    def __len__(self):
        return ArgPack.cNamespace().size(self)

    

    def free(self):
        ArgPack.cNamespace().free(self)



CWrapper.registerObjectType("arg_pack", ArgPack)

cwrapper = CWrapper(UTIL_LIB)

ArgPack.cNamespace().alloc          = cwrapper.prototype("c_void_p arg_pack_alloc( )")
ArgPack.cNamespace().free           = cwrapper.prototype("void arg_pack_free(arg_pack )")
ArgPack.cNamespace().size           = cwrapper.prototype("int arg_pack_size(arg_pack )")
ArgPack.cNamespace().append_int     = cwrapper.prototype("void arg_pack_append_int(arg_pack , int)")
ArgPack.cNamespace().append_double  = cwrapper.prototype("void arg_pack_append_double(arg_pack ,double)")
ArgPack.cNamespace().append_ptr     = cwrapper.prototype("void arg_pack_append_ptr(arg_pack , c_void_p)")
コード例 #28
0
        LocalMinistep.cNamespace().attach_dataset(self, dataset)

    def getLocalObsData(self):
        """ @rtype: LocalObsdata """
        return LocalMinistep.cNamespace().get_local_obs_data(self)

    def getName(self):
        """ @rtype: str """
        return LocalMinistep.cNamespace().name(self)

    def free(self):
        LocalMinistep.cNamespace().free(self)


cwrapper = CWrapper(ENKF_LIB)
cwrapper.registerObjectType("local_ministep", LocalMinistep)

LocalMinistep.cNamespace().alloc = cwrapper.prototype(
    "c_void_p local_ministep_alloc(char*)")
LocalMinistep.cNamespace().add_node = cwrapper.prototype(
    "void local_ministep_add_obsdata_node(local_ministep,local_obsdata_node)")
LocalMinistep.cNamespace().get_local_obs_data = cwrapper.prototype(
    "local_obsdata_ref local_ministep_get_obsdata(local_ministep)")
LocalMinistep.cNamespace().get_local_data = cwrapper.prototype(
    "local_dataset_ref local_ministep_get_dataset(local_ministep , char*)")
LocalMinistep.cNamespace().has_local_data = cwrapper.prototype(
    "bool              local_ministep_has_dataset(local_ministep , char*)")
LocalMinistep.cNamespace().free = cwrapper.prototype(
    "void local_ministep_free(local_ministep)")
LocalMinistep.cNamespace().attach_obsdata = cwrapper.prototype(
    "void local_ministep_add_obsdata(local_ministep,local_obsdata)")
コード例 #29
0
ファイル: local_dataset.py プロジェクト: statoil-travis/ert
        
        LocalDataset.cNamespace().add_node(self, key)
        active_list = self.getActiveList(key)
        
        active_region = ecl_region.getActiveList()
        
        for i in active_region:
            active_list.addActiveIndex(i)
                            
    def free(self):
        LocalDataset.cNamespace().free(self)



cwrapper = CWrapper(ENKF_LIB)
cwrapper.registerObjectType("local_dataset", LocalDataset)

LocalDataset.cNamespace().alloc          = cwrapper.prototype("c_void_p local_dataset_alloc(char*)")
LocalDataset.cNamespace().size           = cwrapper.prototype("c_void_p local_dataset_get_size(char*)")
LocalDataset.cNamespace().has_key        = cwrapper.prototype("bool local_dataset_has_key(local_dataset, char*)")
LocalDataset.cNamespace().free           = cwrapper.prototype("void local_dataset_free(local_dataset)")
LocalDataset.cNamespace().name           = cwrapper.prototype("char* local_dataset_get_name(local_dataset)")
LocalDataset.cNamespace().active_list    = cwrapper.prototype("active_list_ref local_dataset_get_node_active_list(local_dataset, char*)")
LocalDataset.cNamespace().add_node       = cwrapper.prototype("void local_dataset_add_node(local_dataset, char*)")
LocalDataset.cNamespace().del_node       = cwrapper.prototype("void local_dataset_del_node(local_dataset, char*)")

                                                                                 
                                                                                 


コード例 #30
0
ファイル: runpath_list.py プロジェクト: YingfangZhou/ert
        @type realization_number: int
        @type iteration_number: int
        @type runpath: int
        @type basename: int
        """
        RunpathList.cNamespace().add(self, realization_number, iteration_number, runpath, basename)

    def clear(self):
        RunpathList.cNamespace().clear(self)


    def free(self):
        RunpathList.cNamespace().free(self)


cwrapper = CWrapper(ENKF_LIB)
cwrapper.registerObjectType("runpath_list", RunpathList)

RunpathList.cNamespace().free = cwrapper.prototype("void runpath_list_free(runpath_list)")

RunpathList.cNamespace().add = cwrapper.prototype("void runpath_list_add(runpath_list, int, int, char*, char*)")
RunpathList.cNamespace().clear = cwrapper.prototype("void runpath_list_clear(runpath_list)")

RunpathList.cNamespace().size = cwrapper.prototype("int runpath_list_size(runpath_list)")
RunpathList.cNamespace().iens = cwrapper.prototype("int runpath_list_iget_iens(runpath_list, int)")
RunpathList.cNamespace().iteration = cwrapper.prototype("int runpath_list_iget_iter(runpath_list, int)")
RunpathList.cNamespace().runpath = cwrapper.prototype("char* runpath_list_iget_runpath(runpath_list, int)")
RunpathList.cNamespace().basename = cwrapper.prototype("char* runpath_list_iget_basename(runpath_list, int)")


コード例 #31
0
ファイル: fault_block_layer.py プロジェクト: danielfmva/ert
    def insertBlockContent(self , block):
        self.cNamespace().insert_block_content(self , block)

    def exportKeyword(self , kw):
        if len(kw) != self.grid_ref.getGlobalSize():
            raise ValueError("The size of the target keyword must be equal to the size of the grid. Got:%d Expected:%d" % (len(kw) , self.grid_ref.getGlobalSize()))

        if kw.getEclType() != EclTypeEnum.ECL_INT_TYPE:
            raise TypeError("The target kewyord must be of integer type")
            
        self.cNamespace().export_kw( self , kw )


cwrapper = CWrapper(ECL_LIB)
CWrapper.registerObjectType("fault_block_layer", FaultBlockLayer)


FaultBlockLayer.cNamespace().alloc      = cwrapper.prototype("c_void_p         fault_block_layer_alloc(ecl_grid ,  int)")
FaultBlockLayer.cNamespace().free       = cwrapper.prototype("void             fault_block_layer_free(fault_block_layer)")
FaultBlockLayer.cNamespace().size       = cwrapper.prototype("int              fault_block_layer_get_size(fault_block_layer)")
FaultBlockLayer.cNamespace().iget_block = cwrapper.prototype("fault_block_ref  fault_block_layer_iget_block(fault_block_layer, int)")
FaultBlockLayer.cNamespace().add_block  = cwrapper.prototype("fault_block_ref  fault_block_layer_add_block(fault_block_layer, int)")
FaultBlockLayer.cNamespace().get_block  = cwrapper.prototype("fault_block_ref  fault_block_layer_get_block(fault_block_layer, int)")
FaultBlockLayer.cNamespace().del_block  = cwrapper.prototype("void  fault_block_layer_del_block(fault_block_layer, int)")
FaultBlockLayer.cNamespace().has_block  = cwrapper.prototype("bool  fault_block_layer_has_block(fault_block_layer, int)")
FaultBlockLayer.cNamespace().scan_keyword  = cwrapper.prototype("bool  fault_block_layer_scan_kw(fault_block_layer, ecl_kw)")
FaultBlockLayer.cNamespace().load_keyword  = cwrapper.prototype("bool  fault_block_layer_load_kw(fault_block_layer, ecl_kw)")
FaultBlockLayer.cNamespace().getK          = cwrapper.prototype("int   fault_block_layer_get_k(fault_block_layer)")
FaultBlockLayer.cNamespace().get_next_id   = cwrapper.prototype("int   fault_block_layer_get_next_id(fault_block_layer)")
FaultBlockLayer.cNamespace().scan_layer    = cwrapper.prototype("void  fault_block_layer_scan_layer( fault_block_layer , layer)")
コード例 #32
0
    def hasKey(self, key):
        return key in self

    def getValue(self, key, item_index=-1, node_index=0):
        item = self[key]
        return item.getValue(item_index, node_index)

    def isValid(self):
        return ConfigContent.cNamespace().is_valid(self)

    def free(self):
        ConfigContent.cNamespace().free(self)


cwrapper = CWrapper(CONFIG_LIB)
cwrapper.registerObjectType("config_content", ConfigContent)
cwrapper.registerObjectType("content_item", ContentItem)
cwrapper.registerObjectType("content_node", ContentNode)

ConfigContent.cNamespace().free = cwrapper.prototype(
    "void config_content_free( config_content )")
ConfigContent.cNamespace().is_valid = cwrapper.prototype(
    "bool config_content_is_valid( config_content )")
ConfigContent.cNamespace().has_key = cwrapper.prototype(
    "bool config_content_has_item( config_content , char*)")
ConfigContent.cNamespace().get_item = cwrapper.prototype(
    "content_item_ref config_content_get_item( config_content , char*)")

ContentItem.cNamespace().size = cwrapper.prototype(
    "int config_content_item_get_size( content_item )")
ContentItem.cNamespace().iget_content_node = cwrapper.prototype(
コード例 #33
0
ファイル: enkf_obs.py プロジェクト: akva2/ert
    def load(self , config_file):
        if not os.path.isfile( config_file ):
            raise IOError("The observation config file:%s does not exist" % config_file)
        return EnkfObs.cNamespace().load( self , config_file )


    def clear(self):
        EnkfObs.cNamespace().clear( self )


    def free(self):
        EnkfObs.cNamespace().free(self)


cwrapper = CWrapper(ENKF_LIB)
cwrapper.registerObjectType("enkf_obs", EnkfObs)

EnkfObs.cNamespace().alloc = cwrapper.prototype("c_void_p enkf_obs_alloc( history , time_map , ecl_grid , ecl_sum , ens_config )")
EnkfObs.cNamespace().free = cwrapper.prototype("void enkf_obs_free( enkf_obs )")
EnkfObs.cNamespace().get_size = cwrapper.prototype("int enkf_obs_get_size( enkf_obs )")
EnkfObs.cNamespace().load = cwrapper.prototype("bool enkf_obs_load( enkf_obs , char*)")
EnkfObs.cNamespace().clear = cwrapper.prototype("void enkf_obs_clear( enkf_obs )")
EnkfObs.cNamespace().alloc_typed_keylist = cwrapper.prototype("stringlist_obj enkf_obs_alloc_typed_keylist(enkf_obs, enkf_obs_impl_type)")
EnkfObs.cNamespace().alloc_matching_keylist = cwrapper.prototype("stringlist_obj enkf_obs_alloc_matching_keylist(enkf_obs, char*)")
EnkfObs.cNamespace().has_key = cwrapper.prototype("bool enkf_obs_has_key(enkf_obs, char*)")
EnkfObs.cNamespace().obs_type = cwrapper.prototype("enkf_obs_impl_type enkf_obs_get_type(enkf_obs, char*)")
EnkfObs.cNamespace().get_vector = cwrapper.prototype("obs_vector_ref enkf_obs_get_vector(enkf_obs, char*)")
EnkfObs.cNamespace().iget_vector = cwrapper.prototype("obs_vector_ref enkf_obs_iget_vector(enkf_obs, int)")
EnkfObs.cNamespace().iget_obs_time = cwrapper.prototype("time_t enkf_obs_iget_obs_time(enkf_obs, int)")
EnkfObs.cNamespace().add_obs_vector = cwrapper.prototype("void enkf_obs_add_obs_vector(enkf_obs, obs_vector)")
コード例 #34
0
ファイル: active_list.py プロジェクト: imclab/ResInsight
from ert.cwrap import BaseCClass, CWrapper
from ert.enkf import ENKF_LIB


class ActiveList(BaseCClass):
    def __init__(self):
        c_ptr = ActiveList.cNamespace().alloc()
        super(ActiveList, self).__init__(c_ptr)

    def getMode(self):
        return ActiveList.cNamespace().get_mode(self)

    def addActiveIndex(self, index):
        ActiveList.cNamespace().add_index(self, index)

    def free(self):
        ActiveList.cNamespace().free(self)


cwrapper = CWrapper(ENKF_LIB)
cwrapper.registerObjectType("active_list", ActiveList)

ActiveList.cNamespace().alloc = cwrapper.prototype(
    "c_void_p active_list_alloc()")
ActiveList.cNamespace().free = cwrapper.prototype(
    "void     active_list_free(active_list)")
ActiveList.cNamespace().get_mode = cwrapper.prototype(
    "active_mode_enum active_list_get_mode(active_list)")
ActiveList.cNamespace().add_index = cwrapper.prototype(
    "void active_list_add_index(active_list , int)")
コード例 #35
0
    def hasWorkflow(self):
        """ @rtype: bool """
        return PostSimulationHook.cNamespace().has_workflow(self)

    def getWorkflow(self):
        """ @rtype: Workflow """
        return PostSimulationHook.cNamespace().get_workflow(self)

    def checkRunpathListFile(self):
        """ @rtype: bool """
        runpath_list_file = PostSimulationHook.cNamespace(
        ).get_runpath_list_file(self)

        if not os.path.exists(runpath_list_file):
            sys.stderr.write(
                "** Warning: the file: %s with a list of runpath directories was not found - QC workflow wil probably fail.\n"
                % runpath_list_file)


cwrapper = CWrapper(ENKF_LIB)

cwrapper.registerObjectType("qc_module", PostSimulationHook)

PostSimulationHook.cNamespace().has_workflow = cwrapper.prototype(
    "bool qc_module_has_workflow(qc_module)")
PostSimulationHook.cNamespace().get_workflow = cwrapper.prototype(
    "workflow_ref qc_module_get_workflow(qc_module)")
PostSimulationHook.cNamespace().get_runpath_list_file = cwrapper.prototype(
    "char* qc_module_get_runpath_list_file(qc_module)")
コード例 #36
0
ファイル: well_connection.py プロジェクト: danielfmva/ert
    def __eq__(self, other):
        return WellConnection.cNamespace().equal(self, other)

    def __ne__(self, other):
        return not self == other

    def free(self):
        pass

    def isMultiSegmentWell(self):
        """ @rtype: bool """
        return WellConnection.cNamespace().is_msw(self)


CWrapper.registerObjectType("well_connection", WellConnection)
cwrapper = CWrapper(ECL_WELL_LIB)

WellConnection.cNamespace().i = cwrapper.prototype(
    "int well_conn_get_i(well_connection)")
WellConnection.cNamespace().j = cwrapper.prototype(
    "int well_conn_get_j(well_connection)")
WellConnection.cNamespace().k = cwrapper.prototype(
    "int well_conn_get_k(well_connection)")
WellConnection.cNamespace().get_dir = cwrapper.prototype(
    "well_connection_dir_enum well_conn_get_dir(well_connection)")

WellConnection.cNamespace().segment_id = cwrapper.prototype(
    "int well_conn_get_segment_id(well_connection)")
WellConnection.cNamespace().is_open = cwrapper.prototype(
    "bool well_conn_open(well_connection)")
コード例 #37
0
    def free(self):
        EnsembleConfig.cNamespace().free(self)

    def addDefinedCustomKW(self, group_name, definition):
        """ @rtype: EnkfConfigNode """
        if not group_name in self:
            type_hash = CustomKWConfig.convertDefinition(definition)
            EnsembleConfig.cNamespace().add_defined_custom_kw(self, group_name, type_hash)

        return self[group_name]



cwrapper = CWrapper(ENKF_LIB)
cwrapper.registerObjectType("ens_config", EnsembleConfig)

EnsembleConfig.cNamespace().alloc = cwrapper.prototype("c_void_p ensemble_config_alloc(  )")
EnsembleConfig.cNamespace().free = cwrapper.prototype("void ensemble_config_free( ens_config )")
EnsembleConfig.cNamespace().has_key = cwrapper.prototype("bool ensemble_config_has_key( ens_config , char* )")
EnsembleConfig.cNamespace().size = cwrapper.prototype("int ensemble_config_get_size( ens_config)")
EnsembleConfig.cNamespace().get_node = cwrapper.prototype("enkf_config_node_ref ensemble_config_get_node( ens_config , char*)")
EnsembleConfig.cNamespace().alloc_keylist = cwrapper.prototype("stringlist_obj ensemble_config_alloc_keylist( ens_config )")
EnsembleConfig.cNamespace().add_summary = cwrapper.prototype("enkf_config_node_ref ensemble_config_add_summary( ens_config, char*, int)")
EnsembleConfig.cNamespace().add_gen_kw = cwrapper.prototype("enkf_config_node_ref ensemble_config_add_gen_kw( ens_config, char*)")
EnsembleConfig.cNamespace().add_field = cwrapper.prototype("enkf_config_node_ref ensemble_config_add_field( ens_config, char*, ecl_grid)")
EnsembleConfig.cNamespace().alloc_keylist_from_var_type = cwrapper.prototype("stringlist_obj ensemble_config_alloc_keylist_from_var_type(ens_config, enkf_var_type_enum)")
EnsembleConfig.cNamespace().alloc_keylist_from_impl_type = cwrapper.prototype("stringlist_obj ensemble_config_alloc_keylist_from_impl_type(ens_config, ert_impl_type_enum)")
EnsembleConfig.cNamespace().add_node = cwrapper.prototype("void ensemble_config_add_node( ens_config , enkf_config_node )")
EnsembleConfig.cNamespace().summary_key_matcher = cwrapper.prototype("summary_key_matcher_ref ensemble_config_get_summary_key_matcher(ens_config)")
コード例 #38
0
ファイル: model_config.py プロジェクト: YingfangZhou/ert
    def getGenKWExportFile(self):
        """ @rtype: str """
        return ModelConfig.cNamespace().gen_kw_export_file(self)

    def runpathRequiresIterations(self):
        """ @rtype: bool """
        return ModelConfig.cNamespace().runpath_requires_iterations(self)

    def getJobnameFormat(self):
        """ @rtype: str """
        return ModelConfig.cNamespace().get_jobname_fmt(self)


cwrapper = CWrapper(ENKF_LIB)
cwrapper.registerObjectType("model_config", ModelConfig)

ModelConfig.cNamespace().free = cwrapper.prototype("void model_config_free( model_config )")
ModelConfig.cNamespace().get_enkf_sched_file = cwrapper.prototype("char* model_config_get_enkf_sched_file( model_config )")
ModelConfig.cNamespace().set_enkf_sched_file = cwrapper.prototype("void model_config_set_enkf_sched_file( model_config, char*)")
ModelConfig.cNamespace().get_forward_model = cwrapper.prototype("forward_model_ref model_config_get_forward_model(model_config)")
ModelConfig.cNamespace().get_max_internal_submit = cwrapper.prototype("int model_config_get_max_internal_submit(model_config)")
ModelConfig.cNamespace().set_max_internal_submit = cwrapper.prototype("void model_config_set_max_internal_submit(model_config, int)")
ModelConfig.cNamespace().get_case_table_file = cwrapper.prototype("char* model_config_get_case_table_file(model_config)")
ModelConfig.cNamespace().get_runpath_as_char = cwrapper.prototype("char* model_config_get_runpath_as_char(model_config)")
ModelConfig.cNamespace().select_runpath = cwrapper.prototype("bool model_config_select_runpath(model_config, char*)")
ModelConfig.cNamespace().set_runpath = cwrapper.prototype("void model_config_set_runpath(model_config, char*)")
ModelConfig.cNamespace().get_fs_type = cwrapper.prototype("enkf_fs_type_enum model_config_get_dbase_type(model_config)")

ModelConfig.cNamespace().get_history = cwrapper.prototype("history_ref model_config_get_history(model_config)")
ModelConfig.cNamespace().get_history_source = cwrapper.prototype("history_source_enum model_config_get_history_source(model_config)")
コード例 #39
0
        if not self.tryLoad(fs, node_id):
            raise Exception("Could not load node: %s iens: %d report: %d" %
                            (self.name(), node_id.iens, node_id.report_step))

    def save(self, fs, node_id):
        assert isinstance(fs, EnkfFs)
        assert isinstance(node_id, NodeId)

        return EnkfNode.cNamespace().store(self, fs, False, node_id)

    def free(self):
        EnkfNode.cNamespace().free(self)


cwrapper = CWrapper(ENKF_LIB)
cwrapper.registerObjectType("enkf_node", EnkfNode)

EnkfNode.cNamespace().free = cwrapper.prototype(
    "void enkf_node_free(enkf_node)")
EnkfNode.cNamespace().alloc = cwrapper.prototype(
    "void* enkf_node_alloc(enkf_config_node)")
EnkfNode.cNamespace().alloc_private = cwrapper.prototype(
    "void* enkf_node_alloc_private_container(enkf_config_node)")
EnkfNode.cNamespace().get_name = cwrapper.prototype(
    "char* enkf_node_get_key(enkf_node)")

EnkfNode.cNamespace().value_ptr = cwrapper.prototype(
    "void* enkf_node_value_ptr(enkf_node)")

EnkfNode.cNamespace().try_load = cwrapper.prototype(
    "bool enkf_node_try_load(enkf_node, enkf_fs, node_id)")
コード例 #40
0
    def getNumRetries(self):
        """ @rtype: int """
        return AnalysisIterConfig.cNamespace().get_num_retries(self)

    def getCaseFormat(self):
        """ @rtype: str """
        return AnalysisIterConfig.cNamespace().get_case_fmt(self)

    def setCaseFormat(self, case_fmt):
        AnalysisIterConfig.cNamespace().set_case_fmt(self, case_fmt)

    def caseFormatSet(self):
        return AnalysisIterConfig.cNamespace().case_fmt_set(self)

    def free(self):
        AnalysisIterConfig.cNamespace().free(self)

cwrapper = CWrapper(ENKF_LIB)
cwrapper.registerObjectType("analysis_iter_config", AnalysisIterConfig)


AnalysisIterConfig.cNamespace().alloc = cwrapper.prototype("c_void_p analysis_iter_config_alloc( )")
AnalysisIterConfig.cNamespace().free = cwrapper.prototype("void analysis_iter_config_free( analysis_iter_config )")
AnalysisIterConfig.cNamespace().set_num_iterations = cwrapper.prototype("void analysis_iter_config_set_num_iterations(analysis_iter_config, int)")
AnalysisIterConfig.cNamespace().get_num_iterations = cwrapper.prototype("int analysis_iter_config_get_num_iterations(analysis_iter_config)")
AnalysisIterConfig.cNamespace().get_num_retries = cwrapper.prototype("int analysis_iter_config_get_num_retries_per_iteration(analysis_iter_config)")
AnalysisIterConfig.cNamespace().num_iterations_set = cwrapper.prototype("bool analysis_iter_config_num_iterations_set(analysis_iter_config)")
AnalysisIterConfig.cNamespace().set_case_fmt = cwrapper.prototype("void analysis_iter_config_set_case_fmt( analysis_iter_config , char* )")
AnalysisIterConfig.cNamespace().get_case_fmt = cwrapper.prototype("char* analysis_iter_config_get_case_fmt( analysis_iter_config)")
AnalysisIterConfig.cNamespace().case_fmt_set = cwrapper.prototype("bool analysis_iter_config_case_fmt_set(analysis_iter_config)")
コード例 #41
0
ファイル: vector_template.py プロジェクト: danielfmva/ert
import sys
from types import IntType, SliceType

from ert.cwrap import CWrapper, CFILE, BaseCClass
from ert.util import UTIL_LIB


class PermutationVector(BaseCClass):
    def __init__(self):
        raise NotImplementedError("Class can not be instantiated directly!")

    def free(self):
        PermutationVector.cNamespace().free(self)


CWrapper.registerObjectType("permutation_vector", PermutationVector)

cwrapper = CWrapper(UTIL_LIB)
PermutationVector.cNamespace().free = cwrapper.prototype("void util_safe_free(permutation_vector)")


# TVector takes advantage of the fact that self.cNamespace belongs to the inheriting class
class VectorTemplate(BaseCClass):
    @classmethod
    def strided_copy(cls, obj, slice_range):
        """
        Will create a new copy according to @slice.

        Mainly a support function to support slice based lookup like

           v = IntVector()
コード例 #42
0
ファイル: enkf_main.py プロジェクト: bramirex/ert
    def submitSimulation(self , run_arg):
        EnKFMain.cNamespace().submit_simulation( self , run_arg)


    def getRunContextENSEMPLE_EXPERIMENT(self , fs , iactive , init_mode = EnkfInitModeEnum.INIT_CONDITIONAL , iteration = 0):
        return EnKFMain.cNamespace().alloc_run_context_ENSEMBLE_EXPERIMENT( self , fs , iactive , init_mode , iteration )
    

    def getRunpathList(self):
        return EnKFMain.cNamespace().get_runpath_list( self )
    

##################################################################

cwrapper = CWrapper(ENKF_LIB)
cwrapper.registerObjectType("enkf_main", EnKFMain)

EnKFMain.cNamespace().bootstrap = cwrapper.prototype("c_void_p enkf_main_bootstrap(char*, bool, bool)")
EnKFMain.cNamespace().free = cwrapper.prototype("void enkf_main_free(enkf_main)")

EnKFMain.cNamespace().get_ensemble_size = cwrapper.prototype("int enkf_main_get_ensemble_size( enkf_main )")
EnKFMain.cNamespace().get_ens_config = cwrapper.prototype("ens_config_ref enkf_main_get_ensemble_config( enkf_main )")
EnKFMain.cNamespace().get_model_config = cwrapper.prototype("model_config_ref enkf_main_get_model_config( enkf_main )")
EnKFMain.cNamespace().get_local_config = cwrapper.prototype("local_config_ref enkf_main_get_local_config( enkf_main )")
EnKFMain.cNamespace().get_analysis_config = cwrapper.prototype("analysis_config_ref enkf_main_get_analysis_config( enkf_main)")
EnKFMain.cNamespace().get_site_config = cwrapper.prototype("site_config_ref enkf_main_get_site_config( enkf_main)")
EnKFMain.cNamespace().get_ecl_config = cwrapper.prototype("ecl_config_ref enkf_main_get_ecl_config( enkf_main)")
EnKFMain.cNamespace().get_plot_config = cwrapper.prototype("plot_config_ref enkf_main_get_plot_config( enkf_main)")
EnKFMain.cNamespace().set_eclbase = cwrapper.prototype("ui_return_obj enkf_main_set_eclbase( enkf_main, char*)")
EnKFMain.cNamespace().set_datafile = cwrapper.prototype("void enkf_main_set_data_file( enkf_main, char*)")
EnKFMain.cNamespace().get_schedule_prediction_file = cwrapper.prototype("char* enkf_main_get_schedule_prediction_file( enkf_main )")
コード例 #43
0
ファイル: time_vector.py プロジェクト: YingfangZhou/ert
            ct = CTime( currentTime )
            timeVector.append( ct )
            currentTime = timeVector.nextTime( num , timeUnit )
            
        return timeVector
                

    def getDataPtr(self):
        raise NotImplementedError("The getDataPtr() function is not implemented for time_t vectors")


#################################################################

cwrapper = CWrapper(UTIL_LIB)

CWrapper.registerObjectType("time_t_vector", TimeVector)


TimeVector.cNamespace().alloc               = cwrapper.prototype("c_void_p time_t_vector_alloc(int, time_t )")
TimeVector.cNamespace().alloc_copy          = cwrapper.prototype("time_t_vector_obj time_t_vector_alloc_copy(time_t_vector )")
TimeVector.cNamespace().strided_copy        = cwrapper.prototype("time_t_vector_obj time_t_vector_alloc_strided_copy(time_t_vector , time_t , time_t , time_t)")
TimeVector.cNamespace().free                = cwrapper.prototype("void   time_t_vector_free( time_t_vector )")
TimeVector.cNamespace().iget                = cwrapper.prototype("time_t   time_t_vector_iget( time_t_vector , int )")
TimeVector.cNamespace().safe_iget           = cwrapper.prototype("time_t   time_t_vector_safe_iget( time_t_vector , int )")
TimeVector.cNamespace().iset                = cwrapper.prototype("time_t   time_t_vector_iset( time_t_vector , int , time_t)")
TimeVector.cNamespace().size                = cwrapper.prototype("int      time_t_vector_size( time_t_vector )")
TimeVector.cNamespace().append              = cwrapper.prototype("void     time_t_vector_append( time_t_vector , time_t )")
TimeVector.cNamespace().idel_block          = cwrapper.prototype("void     time_t_vector_idel_block( time_t_vector , int , int )")
TimeVector.cNamespace().idel                = cwrapper.prototype("void     time_t_vector_idel( time_t_vector , int )")
TimeVector.cNamespace().pop                 = cwrapper.prototype("time_t   time_t_vector_pop( time_t_vector )")
TimeVector.cNamespace().lshift              = cwrapper.prototype("void     time_t_vector_lshift( time_t_vector , int )")
コード例 #44
0
    def __len__(self):
        """ @rtype: int """
        return WellTimeLine.cNamespace().size(self)

    def __getitem__(self, index):
        """
         @type index: int
         @rtype: WellState
        """

        if index < 0:
            index += len(self)

        if not 0 <= index < len(self):
            raise IndexError("Index must be in range 0 <= %d < %d" %
                             (index, len(self)))

        return WellTimeLine.cNamespace().iget(self, index).setParent(self)

    def free(self):
        pass


CWrapper.registerObjectType("well_time_line", WellTimeLine)
cwrapper = CWrapper(ECL_WELL_LIB)

WellTimeLine.cNamespace().size = cwrapper.prototype(
    "int well_ts_get_size(well_time_line)")
WellTimeLine.cNamespace().iget = cwrapper.prototype(
    "well_state_ref well_ts_iget_state(well_time_line, int)")
コード例 #45
0
ファイル: field.py プロジェクト: akva2/ert
    
    def ijk_get_double(self, i, j, k):
        return Field.cNamespace().ijk_get_double(self, i, j, k)

    
    def export(self , filename , file_type = None , init_file = None):
        output_transform = False
        if file_type is None:
            try:
                file_type = FieldConfig.exportFormat( filename )
            except ValueError:
                sys.stderr.write("Sorry - could not infer output format from filename:%s\n" % filename)
                return False

        Field.cNamespace().export(self , filename , None , file_type , output_transform , init_file )
        return True

    
    def free(self):
        Field.cNamespace().free(self)


##################################################################

cwrapper = CWrapper(ENKF_LIB)
cwrapper.registerObjectType("field", Field)

Field.cNamespace().free = cwrapper.prototype("void field_free( field )")
Field.cNamespace().ijk_get_double = cwrapper.prototype("double field_ijk_get_double(field, int, int, int)")
Field.cNamespace().export = cwrapper.prototype("void field_export(field, char* , fortio , enkf_field_file_format_enum , bool , char*)")
コード例 #46
0
ファイル: gen_kw_config.py プロジェクト: YingfangZhou/ert
    def __len__(self):
        return GenKwConfig.cNamespace().size(self)

    def __getitem__(self, index):
        """ @rtype: str """
        return GenKwConfig.cNamespace().iget_name(self, index)

    def __iter__(self):
        index = 0
        while index < len(self):
            yield self[index]
            index += 1


cwrapper = CWrapper(ENKF_LIB)
cwrapper.registerObjectType("gen_kw_config", GenKwConfig)

GenKwConfig.cNamespace().free = cwrapper.prototype("void gen_kw_config_free( gen_kw_config )")
GenKwConfig.cNamespace().alloc_empty = cwrapper.prototype("c_void_p gen_kw_config_alloc_empty( char*, char* )")
GenKwConfig.cNamespace().get_template_file = cwrapper.prototype("char* gen_kw_config_get_template_file(gen_kw_config)")
GenKwConfig.cNamespace().set_template_file = cwrapper.prototype("void gen_kw_config_set_template_file(gen_kw_config , char*)")
GenKwConfig.cNamespace().get_parameter_file = cwrapper.prototype("char* gen_kw_config_get_parameter_file(gen_kw_config)")
GenKwConfig.cNamespace().set_parameter_file = cwrapper.prototype("void gen_kw_config_set_parameter_file( gen_kw_config, char* )")
GenKwConfig.cNamespace().alloc_name_list = cwrapper.prototype("stringlist_obj gen_kw_config_alloc_name_list(gen_kw_config)")

GenKwConfig.cNamespace().should_use_log_scale = cwrapper.prototype("bool gen_kw_config_should_use_log_scale(gen_kw_config, int)")
GenKwConfig.cNamespace().get_key = cwrapper.prototype("char* gen_kw_config_get_key(gen_kw_config)")
GenKwConfig.cNamespace().size = cwrapper.prototype("int gen_kw_config_get_data_size(gen_kw_config)")
GenKwConfig.cNamespace().iget_name = cwrapper.prototype("char* gen_kw_config_iget_name(gen_kw_config, int)")
コード例 #47
0
ファイル: enkf_node.py プロジェクト: patricknraanes/ert
        @type fs: EnkfFS
        @type node_id: NodeId
        @rtype: bool
        """
        assert isinstance(fs, EnkfFs)
        assert isinstance(node_id, NodeId)

        return EnkfNode.cNamespace().try_load(self, fs, node_id)


    def free(self):
        EnkfNode.cNamespace().free(self)


cwrapper = CWrapper(ENKF_LIB)
cwrapper.registerObjectType("enkf_node", EnkfNode)

EnkfNode.cNamespace().free = cwrapper.prototype("void enkf_node_free( enkf_node )")
EnkfNode.cNamespace().alloc = cwrapper.prototype("c_void_p enkf_node_alloc(enkf_node)")
EnkfNode.cNamespace().alloc_private = cwrapper.prototype("c_void_p enkf_node_alloc_private_container(enkf_node)")

# EnkfNode.cNamespace().user_get = cwrapper.prototype("bool enkf_node_user_get_no_id(enkf_node , enkf_fs , char*  , int, int , c_uint, double*)")
# EnkfNode.cNamespace().user_get_vector = cwrapper.prototype("bool enkf_node_user_get_vector( enkf_node , enkf_fs , char*, int, c_uint, double_vector)")
EnkfNode.cNamespace().value_ptr = cwrapper.prototype("c_void_p enkf_node_value_ptr(enkf_node)")
# EnkfNode.cNamespace().vector_storage = cwrapper.prototype("bool enkf_node_vector_storage(enkf_node)")

EnkfNode.cNamespace().try_load = cwrapper.prototype("bool enkf_node_try_load(enkf_node, enkf_fs, node_id)")

#todo fix this
# EnkfNode.cNamespace().get_config = cwrapper.prototype("c_void_p enkf_node_get_config(enkf_node)")
コード例 #48
0
ファイル: bool_vector.py プロジェクト: danielfmva/ert
        for index in source_list:
            index = int(index)
            bool_vector[index] = True

        return bool_vector

    @classmethod
    def createActiveList(cls, mask):
        """ @rtype: IntVectorTemplate """
        assert isinstance(mask, BoolVector)
        return cls.cNamespace().active_list(mask)


cwrapper = CWrapper(UTIL_LIB)
CWrapper.registerObjectType("bool_vector", BoolVector)


BoolVector.cNamespace().alloc               = cwrapper.prototype("c_void_p   bool_vector_alloc( int , bool )")
BoolVector.cNamespace().alloc_copy          = cwrapper.prototype("bool_vector_obj bool_vector_alloc_copy( bool_vector )")
BoolVector.cNamespace().strided_copy        = cwrapper.prototype("bool_vector_obj bool_vector_alloc_strided_copy( bool_vector , int , int , int)")
BoolVector.cNamespace().free                = cwrapper.prototype("void   bool_vector_free( bool_vector )")
BoolVector.cNamespace().iget                = cwrapper.prototype("bool   bool_vector_iget( bool_vector , int )")
BoolVector.cNamespace().safe_iget           = cwrapper.prototype("bool   bool_vector_safe_iget( bool_vector , int )")
BoolVector.cNamespace().iset                = cwrapper.prototype("void   bool_vector_iset( bool_vector , int , bool)")
BoolVector.cNamespace().size                = cwrapper.prototype("int    bool_vector_size( bool_vector )")
BoolVector.cNamespace().append              = cwrapper.prototype("void   bool_vector_append( bool_vector , bool )")
BoolVector.cNamespace().idel_block          = cwrapper.prototype("void   bool_vector_idel_block( bool_vector , bool , bool )")
BoolVector.cNamespace().idel                = cwrapper.prototype("void   bool_vector_idel( bool_vector , int )")
BoolVector.cNamespace().pop                 = cwrapper.prototype("bool   bool_vector_pop( bool_vector )")
BoolVector.cNamespace().lshift              = cwrapper.prototype("void   bool_vector_lshift( bool_vector , int )")
コード例 #49
0
ファイル: job_queue_manager.py プロジェクト: YingfangZhou/ert
    def getNumRunning(self):
        return JobQueueManager.cNamespace().get_num_running( self )

    def getNumComplete(self):
        return JobQueueManager.cNamespace().get_num_complete( self )

    def isRunning(self):
        return JobQueueManager.cNamespace().is_running( self )

    def free(self):
        JobQueueManager.cNamespace().free(self)

    def jobComplete(self , job_index):
        return JobQueueManager.cNamespace().job_complete( self , job_index )
        
    
        

#################################################################

cwrapper = CWrapper(JOB_QUEUE_LIB)
cwrapper.registerObjectType("job_queue_manager", JobQueueManager)

JobQueueManager.cNamespace().alloc             = cwrapper.prototype("c_void_p job_queue_manager_alloc( job_queue) ")
JobQueueManager.cNamespace().free              = cwrapper.prototype("void job_queue_manager_free( job_queue_manager )")
JobQueueManager.cNamespace().start_queue       = cwrapper.prototype("void job_queue_manager_start_queue( job_queue_manager , int , bool)")
JobQueueManager.cNamespace().get_num_running   = cwrapper.prototype("int job_queue_manager_get_num_running( job_queue_manager )")
JobQueueManager.cNamespace().get_num_complete  = cwrapper.prototype("int job_queue_manager_get_num_complete( job_queue_manager )")
JobQueueManager.cNamespace().is_running        = cwrapper.prototype("bool job_queue_manager_is_running( job_queue_manager )")
JobQueueManager.cNamespace().job_complete      = cwrapper.prototype("bool job_queue_manager_job_complete( job_queue_manager , int)")
コード例 #50
0
ファイル: job_queue_manager.py プロジェクト: danielfmva/ert
        return JobQueueManager.cNamespace().get_num_complete(self)

    def isRunning(self):
        return JobQueueManager.cNamespace().is_running(self)

    def free(self):
        JobQueueManager.cNamespace().free(self)

    def jobComplete(self, job_index):
        return JobQueueManager.cNamespace().job_complete(self, job_index)


#################################################################

cwrapper = CWrapper(JOB_QUEUE_LIB)
cwrapper.registerObjectType("job_queue_manager", JobQueueManager)

JobQueueManager.cNamespace().alloc = cwrapper.prototype(
    "c_void_p job_queue_manager_alloc( job_queue) ")
JobQueueManager.cNamespace().free = cwrapper.prototype(
    "void job_queue_manager_free( job_queue_manager )")
JobQueueManager.cNamespace().start_queue = cwrapper.prototype(
    "void job_queue_manager_start_queue( job_queue_manager , int , bool)")
JobQueueManager.cNamespace().get_num_running = cwrapper.prototype(
    "int job_queue_manager_get_num_running( job_queue_manager )")
JobQueueManager.cNamespace().get_num_complete = cwrapper.prototype(
    "int job_queue_manager_get_num_complete( job_queue_manager )")
JobQueueManager.cNamespace().is_running = cwrapper.prototype(
    "bool job_queue_manager_is_running( job_queue_manager )")
JobQueueManager.cNamespace().job_complete = cwrapper.prototype(
    "bool job_queue_manager_job_complete( job_queue_manager , int)")
コード例 #51
0
ファイル: ecl_sum_tstep.py プロジェクト: atgeirr/ResInsight
        if not key in self:
            raise KeyError("Key '%s' is not available." % key)

        return EclSumTStep.cNamespace().get_from_key(self, key)

    def __setitem__(self, key, value):
        if not key in self:
            raise KeyError("Key '%s' is not available." % key)

        EclSumTStep.cNamespace().set_from_key(self, key, value)

    def __contains__(self, key):
        return EclSumTStep.cNamespace().has_key(self, key)

    def free(self):
        EclSumTStep.cNamespace().free(self)


cwrapper = CWrapper(ECL_LIB)
cwrapper.registerObjectType("ecl_sum_tstep", EclSumTStep)

EclSumTStep.cNamespace().alloc = cwrapper.prototype("void* ecl_sum_tstep_alloc_new(int, int, float, void*)")
EclSumTStep.cNamespace().free = cwrapper.prototype("void ecl_sum_tstep_free(ecl_sum_tstep)")

EclSumTStep.cNamespace().get_sim_days = cwrapper.prototype("double ecl_sum_tstep_get_sim_days(ecl_sum_tstep)")
EclSumTStep.cNamespace().get_report = cwrapper.prototype("int ecl_sum_tstep_get_report(ecl_sum_tstep)")
EclSumTStep.cNamespace().get_ministep = cwrapper.prototype("int ecl_sum_tstep_get_ministep(ecl_sum_tstep)")

EclSumTStep.cNamespace().set_from_key = cwrapper.prototype("void ecl_sum_tstep_set_from_key(ecl_sum_tstep, char*, float)")
EclSumTStep.cNamespace().get_from_key = cwrapper.prototype("double ecl_sum_tstep_get_from_key(ecl_sum_tstep, char*)")
EclSumTStep.cNamespace().has_key = cwrapper.prototype("bool ecl_sum_tstep_has_key(ecl_sum_tstep)")
コード例 #52
0
ファイル: hash.py プロジェクト: bramirex/ert
        if isinstance(value, float):
            DoubleHash.cNamespace().insert_double(self, key, value)
        else:
            raise ValueError("DoubleHash does not support type: %s" %
                             value.__class__)

    def __getitem__(self, key):
        if key in self:
            return DoubleHash.cNamespace().get_double(self, key)
        else:
            raise KeyError("Hash does not have key: %s" % key)


cwrapper = CWrapper(UTIL_LIB)
CWrapper.registerObjectType("hash", Hash)  # c_void_p type
CWrapper.registerObjectType("integer_hash", IntegerHash)
CWrapper.registerObjectType("string_hash", StringHash)
CWrapper.registerObjectType("double_hash", DoubleHash)

Hash.cNamespace().alloc = cwrapper.prototype("long hash_alloc()")
Hash.cNamespace().free = cwrapper.prototype("void hash_free(hash)")
Hash.cNamespace().size = cwrapper.prototype("int hash_get_size(hash)")
Hash.cNamespace().keys = cwrapper.prototype(
    "stringlist_obj hash_alloc_stringlist(hash)")
Hash.cNamespace().has_key = cwrapper.prototype(
    "bool hash_has_key(hash, char*)")

Hash.cNamespace().get = cwrapper.prototype("c_void_p hash_get(hash, char*)")
IntegerHash.cNamespace().get_int = cwrapper.prototype(
    "int hash_get_int(hash, char*)")
コード例 #53
0
    def free(self):
        JobQueue.cNamespace().free(self)

    def __len__(self):
        return self.cNamespace().get_active_size(self)

    def getJobStatus(self, job_number):
        """ @rtype: JobStatusType """
        return self.cNamespace().get_job_status(self, job_number)


#################################################################

cwrapper = CWrapper(JOB_QUEUE_LIB)
cwrapper.registerObjectType("job_queue", JobQueue)

JobQueue.cNamespace().alloc = cwrapper.prototype(
    "c_void_p job_queue_alloc( int , char* , char* )")
JobQueue.cNamespace().user_exit = cwrapper.prototype(
    "void job_queue_user_exit( job_queue )")
JobQueue.cNamespace().free = cwrapper.prototype(
    "void job_queue_free( job_queue )")
JobQueue.cNamespace().set_max_running = cwrapper.prototype(
    "void job_queue_set_max_running( job_queue , int)")
JobQueue.cNamespace().get_max_running = cwrapper.prototype(
    "int  job_queue_get_max_running( job_queue )")
JobQueue.cNamespace().set_driver = cwrapper.prototype(
    "void job_queue_set_driver( job_queue , c_void_p )")
JobQueue.cNamespace().add_job = cwrapper.prototype(
    "int   job_queue_add_job( job_queue , char* , c_void_p , c_void_p , c_void_p , c_void_p , int , char* , char* , int , char**)"
コード例 #54
0
ファイル: meas_block.py プロジェクト: YingfangZhou/ert
    def igetMean(self , iobs):
        if 0 <= iobs < self.getObsSize():
            return MeasBlock.cNamespace().iget_mean(self , iobs)
        else:
            raise IndexError("Invalid observation index:%d  valid range: [0,%d)" % (iobs , self.getObsSize()))

    def igetStd(self , iobs):
        if 0 <= iobs < self.getObsSize():
            return MeasBlock.cNamespace().iget_std(self , iobs)
        else:
            raise IndexError("Invalid observation index:%d  valid range: [0,%d)" % (iobs , self.getObsSize()))



cwrapper = CWrapper(ENKF_LIB)
cwrapper.registerObjectType("meas_block", MeasBlock)

MeasBlock.cNamespace().alloc = cwrapper.prototype("c_void_p meas_block_alloc( char* , bool_vector , int)")
MeasBlock.cNamespace().free = cwrapper.prototype("void meas_block_free( meas_block )")
MeasBlock.cNamespace().get_active_ens_size = cwrapper.prototype("int meas_block_get_active_ens_size( meas_block )")
MeasBlock.cNamespace().get_total_ens_size = cwrapper.prototype("int meas_block_get_total_ens_size( meas_block )")
MeasBlock.cNamespace().get_total_obs_size = cwrapper.prototype("int meas_block_get_total_obs_size( meas_block )")
MeasBlock.cNamespace().iget_value = cwrapper.prototype("double meas_block_iget( meas_block , int , int)")
MeasBlock.cNamespace().iset_value = cwrapper.prototype("void meas_block_iset( meas_block , int , int , double)")
MeasBlock.cNamespace().iget_mean = cwrapper.prototype("double meas_block_iget_ens_mean( meas_block , int )")
MeasBlock.cNamespace().iget_std = cwrapper.prototype("double meas_block_iget_ens_std( meas_block , int )")
MeasBlock.cNamespace().iens_active = cwrapper.prototype("bool meas_block_iens_active( meas_block , int )")


    
コード例 #55
0
ファイル: block_observation.py プロジェクト: YingfangZhou/ert
    def getData(self, state, obs_index, node_id):
        """
        @type state: c_void_p
        @type obs_index: int
        @type node_id: NodeId
        @rtype: float """

        return BlockObservation.cNamespace().iget_data(self, state, obs_index, node_id)


    def free(self):
        BlockObservation.cNamespace().free(self)

##################################################################

cwrapper = CWrapper(ENKF_LIB)
cwrapper.registerObjectType("block_obs", BlockObservation)

BlockObservation.cNamespace().free = cwrapper.prototype("void block_obs_free( block_obs )")
BlockObservation.cNamespace().iget_i = cwrapper.prototype("int block_obs_iget_i(block_obs, int)")
BlockObservation.cNamespace().iget_j = cwrapper.prototype("int block_obs_iget_j( block_obs, int)")
BlockObservation.cNamespace().iget_k = cwrapper.prototype("int block_obs_iget_k( block_obs , int)")
BlockObservation.cNamespace().get_size = cwrapper.prototype("int block_obs_get_size( block_obs )")
BlockObservation.cNamespace().get_std = cwrapper.prototype("double block_obs_iget_std( block_obs, int )")
BlockObservation.cNamespace().get_value = cwrapper.prototype("double block_obs_iget_value( block_obs, int)")
BlockObservation.cNamespace().get_depth = cwrapper.prototype("double block_obs_iget_depth( block_obs, int)")

BlockObservation.cNamespace().iget_data = cwrapper.prototype("double block_obs_iget_data(block_obs, c_void_p, int, node_id)")

コード例 #56
0
ファイル: ert_test_context.py プロジェクト: danielfmva/ert
        return self.__test_context

    def __exit__(self, exc_type, exc_val, exc_tb):
        del self.__test_context
        return False

    def getErt(self):
        return self.__test_context.getErt()

    def getCwd(self):
        """
        Returns the current working directory of this context.
        @rtype: string
        """
        return self.__test_context.getCwd()


cwrapper = CWrapper(ENKF_LIB)
cwrapper.registerObjectType("ert_test", ErtTest)

ErtTest.cNamespace().alloc = cwrapper.prototype(
    "c_void_p ert_test_context_alloc_python( char* , char* , char*)")
ErtTest.cNamespace().set_store = cwrapper.prototype(
    "c_void_p ert_test_context_set_store( ert_test , bool)")
ErtTest.cNamespace().free = cwrapper.prototype(
    "void ert_test_context_free( ert_test )")
ErtTest.cNamespace().get_enkf_main = cwrapper.prototype(
    "enkf_main_ref ert_test_context_get_main( ert_test )")
ErtTest.cNamespace().get_cwd = cwrapper.prototype(
    "char* ert_test_context_get_cwd( ert_test )")
コード例 #57
0
ファイル: int_vector.py プロジェクト: imclab/ResInsight
        characters the returned active list will be empty:

           "1,4-7,10"  =>  {1,4,5,6,7,10}
           "1,4-7,10X" =>  {}
        
        The empty list will evaluate to false
        """
        return cls.cNamespace().create_active_list(range_string)

    def count(self, value):
        """ @rtype: int """
        return IntVector.cNamespace().count_equal(self, value)


cwrapper = CWrapper(UTIL_LIB)
CWrapper.registerObjectType("int_vector", IntVector)

IntVector.cNamespace().alloc = cwrapper.prototype(
    "c_void_p   int_vector_alloc( int , int )")
IntVector.cNamespace().alloc_copy = cwrapper.prototype(
    "int_vector_obj int_vector_alloc_copy( int_vector )")
IntVector.cNamespace().strided_copy = cwrapper.prototype(
    "int_vector_obj int_vector_alloc_strided_copy( int_vector , int , int , int)"
)
IntVector.cNamespace().free = cwrapper.prototype(
    "void   int_vector_free( int_vector )")
IntVector.cNamespace().iget = cwrapper.prototype(
    "int    int_vector_iget( int_vector , int )")
IntVector.cNamespace().safe_iget = cwrapper.prototype(
    "int    int_vector_safe_iget( int_vector , int )")
IntVector.cNamespace().iset = cwrapper.prototype(