Example #1
0
class BaseCValueTest(ExtendedTestCase):
    def setUp(self):
        ert = clib.ert_load("libert_util")

        self.ert_wrapper = CWrapper(ert)

        self.ert_wrapper.registerType("time_t", TimeTValue)
        self.make_date = self.ert_wrapper.prototype("time_t util_make_date(int, int, int)")


    def test_illegal_type(self):
        class ExceptionValueTest(BaseCValue):
            DATA_TYPE = str
            def __init__(self, value):
                super(ExceptionValueTest, self).__init__(value)

        with self.assertRaises(ValueError):
            test = ExceptionValueTest("Failure")


        class NoDataTypeTest(BaseCValue):
            def __init__(self, value):
                super(NoDataTypeTest, self).__init__(value)

        with self.assertRaises(ValueError):
            test = ExceptionValueTest(0)


    def test_creation(self):
        test_value = UnsignedByteValue(255)

        self.assertEqual(test_value.value(), 255)

        test_value.setValue(256)
        self.assertEqual(test_value.value(), 0)

        self.assertEqual(test_value.type(), c_ubyte)


    def test_from_param(self):
        test_value = UnsignedByteValue(127)

        self.assertEqual(UnsignedByteValue.from_param(test_value).value, 127)

        with self.assertRaises(AttributeError):
            UnsignedByteValue.from_param(None)

        with self.assertRaises(ValueError):
           UnsignedByteValue.from_param("exception")


    def test_time_t(self):
        future = self.make_date(1, 1, 2050)

        self.assertIsInstance(future, TimeTValue)
        self.assertEqual(future.value(), 2524604400)
Example #2
0
class BaseCValueTest(ExtendedTestCase):
    def setUp(self):
        ert = clib.ert_load("libert_util")

        self.ert_wrapper = CWrapper(ert)

        self.ert_wrapper.registerType("pow_double", MaxDouble)
        self.double_max = self.ert_wrapper.prototype("pow_double util_double_max(double, double)")


    def test_illegal_type(self):
        class ExceptionValueTest(BaseCValue):
            DATA_TYPE = str
            def __init__(self, value):
                super(ExceptionValueTest, self).__init__(value)

        with self.assertRaises(ValueError):
            test = ExceptionValueTest("Failure")


        class NoDataTypeTest(BaseCValue):
            def __init__(self, value):
                super(NoDataTypeTest, self).__init__(value)

        with self.assertRaises(ValueError):
            test = ExceptionValueTest(0)


    def test_creation(self):
        test_value = UnsignedByteValue(255)

        self.assertEqual(test_value.value(), 255)

        test_value.setValue(256)
        self.assertEqual(test_value.value(), 0)

        self.assertEqual(test_value.type(), c_ubyte)


    def test_from_param(self):
        test_value = UnsignedByteValue(127)

        self.assertEqual(UnsignedByteValue.from_param(test_value).value, 127)

        with self.assertRaises(AttributeError):
            UnsignedByteValue.from_param(None)

        with self.assertRaises(ValueError):
           UnsignedByteValue.from_param("exception")


    def test_double_max(self):
        double_max = self.double_max(2.97, 2.98)

        self.assertIsInstance(double_max, MaxDouble)
        self.assertEqual(double_max.value(), 2.98)
Example #3
0
    def test_method_type(self):
        wrapper =  CWrapper(test_lib)
        def stringObj(c_ptr):
            char_ptr = ctypes.c_char_p( c_ptr )
            python_string = char_ptr.value
            test_lib.free(c_ptr)
            return python_string

        wrapper.registerType("string_obj", stringObj)

        dateStamp  = wrapper.prototype("string_obj util_alloc_date_stamp()")
        date_stamp = dateStamp()
        self.assertIsInstance(date_stamp, str)
Example #4
0
        (utm_x , utm_y , depth) position where we want to evaluate the
        change in subsidence.

        If supplied the optional argument @region should be an
        EclRegion() instance; this region will be used to limit the
        part of the reserviour included in the subsidence calculations.

        The argument @compressibility is the total reservoir compressibility.
        """
        return cfunc.eval(self, base_survey, monitor_survey, region, pos[0],
                          pos[1], pos[2], compressibility, poisson_ratio)


# 2. Creating a wrapper object around the libecl library,
cwrapper = CWrapper(ECL_LIB)
cwrapper.registerType("ecl_subsidence", EclSubsidence)

# 3. Installing the c-functions used to manipulate ecl_subsidence instances.
#    These functions are used when implementing the EclSubsidence class, not
#    used outside this scope.
cfunc = CWrapperNameSpace("ecl_subsidence")

cfunc.subsidence_alloc = cwrapper.prototype(
    "c_void_p ecl_subsidence_alloc( ecl_grid , ecl_file )")
cfunc.free = cwrapper.prototype("void ecl_subsidence_free( ecl_subsidence )")

# Return value ignored in the add_survey_xxx() functions:
cfunc.add_survey_PRESSURE = cwrapper.prototype(
    "c_void_p  ecl_subsidence_add_survey_PRESSURE( ecl_subsidence , char* , ecl_file )"
)
cfunc.eval = cwrapper.prototype(
Example #5
0
            cfunc.global_kw_copy( self , kw_copy , kw)
            return kw_copy
        else:
            raise ValueError("The input keyword must have nx*n*nz or nactive elements. Size:%d invalid" % len(kw))


    def exportACTNUMKw(self):
        actnum = EclKW.create("ACTNUM" , self.getGlobalSize() , EclTypeEnum.ECL_INT_TYPE)
        cfunc.init_actnum( self , actnum.getDataPtr() )
        return actnum
        

# 2. Creating a wrapper object around the libecl library, 
#    registering the type map : ecl_kw <-> EclKW
cwrapper = CWrapper(ECL_LIB)
cwrapper.registerType( "ecl_grid" , EclGrid )

# 3. Installing the c-functions used to manipulate ecl_kw instances.
#    These functions are used when implementing the EclKW class, not
#    used outside this scope.
cfunc = CWrapperNameSpace("ecl_grid")



cfunc.fread_alloc                  = cwrapper.prototype("c_void_p ecl_grid_load_case( char* )")
cfunc.grdecl_create                = cwrapper.prototype("c_void_p ecl_grid_alloc_GRDECL_kw( int , int , int , ecl_kw , ecl_kw , ecl_kw , ecl_kw)") 
cfunc.get_lgr                      = cwrapper.prototype("c_void_p ecl_grid_get_lgr( ecl_grid , char* )")
cfunc.get_cell_lgr                 = cwrapper.prototype("c_void_p ecl_grid_get_cell_lgr1( ecl_grid , int )")
cfunc.alloc_rectangular            = cwrapper.prototype("c_void_p ecl_grid_alloc_rectangular( int , int , int , double , double , double , int*)")

cfunc.num_coarse_groups            = cwrapper.prototype("int  ecl_grid_get_num_coarse_groups( ecl_grid )")
Example #6
0
        else:
            raise TypeError("The kw type must be string. Input:%s" % kw)


    def __contains__(self , kw):
        return EnKFState.cNamespace().has_key( self , kw )


    def hasKey(self , kw):
        return kw in self


    def getNode(self , kw):
        return self[kw]


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



cwrapper = CWrapper(ENKF_LIB)
cwrapper.registerType("enkf_state", EnKFState)
cwrapper.registerType("enkf_state_obj", EnKFState.createPythonObject)
cwrapper.registerType("enkf_state_ref", EnKFState.createCReference)


EnKFState.cNamespace().free     = cwrapper.prototype("void enkf_state_free( enkf_state )")
EnKFState.cNamespace().has_key  = cwrapper.prototype("bool enkf_state_has_node( enkf_state , char* )")
EnKFState.cNamespace().get_node = cwrapper.prototype("enkf_node_ref enkf_state_get_node( enkf_state , char* )")
Example #7
0
    def runIteratedEnsembleSmoother(self, last_report_step):
        #warn: Remember to select correct analysis module RML
        EnKFMain.cNamespace().run_iterated_ensemble_smoother(self, last_report_step)

    def runOneMoreIteration(self, last_report_step):
        #warn: need some way of validating that the case has run
        EnKFMain.cNamespace().run_one_more_iteration(self, last_report_step)


    def isCaseInitialized(self, case):
        return EnKFMain.cNamespace().is_case_initialized(self, case, None)

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

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


EnKFMain.cNamespace().bootstrap = cwrapper.prototype("c_void_p enkf_main_bootstrap(char*, 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("void enkf_main_set_eclbase( enkf_main, char*)")
EnKFMain.cNamespace().set_datafile = cwrapper.prototype("void enkf_main_set_data_file( enkf_main, char*)")
Example #8
0
File: ctime.py Project: eoia/ert
    def __add__(self, other):
        copy = CTime( self )
        copy += other
        return copy

    def __radd__(self, other):
        return self + other


    def __mul__(self , other):
        copy = CTime( self )
        copy *= other
        return copy

    def __rmul__(self , other):
        return self * other

    def timetuple(self):
        # this function is a requirement for comparing against datetime objects where the CTime is on the right side
        pass

    @property
    def stripped(self):
        return time.strptime(self, "%Y-%m-%d %H:%M:S%")


cwrapper = CWrapper(None)
cwrapper.registerType("time_t", CTime)

        assert isinstance(active_realization_mask, BoolVector)
        assert isinstance(initialization_mode, EnkfInitModeEnum)
        return EnkfSimulationRunner.cNamespace().run_simple_step(self, active_realization_mask, initialization_mode , iter_nr)


    def runEnsembleExperiment(self, active_realization_mask):
        """ @rtype: bool """
        iter_nr = 0
        return self.runSimpleStep(active_realization_mask , EnkfInitModeEnum.INIT_CONDITIONAL , iter_nr)

    def runPostWorkflow(self):
        EnkfSimulationRunner.cNamespace().run_post_workflow(self)


    def smootherUpdate(self, target_fs):
        """ @rtype: bool """
        assert isinstance(target_fs, EnkfFs)
        return EnkfSimulationRunner.cNamespace().smoother_update(self, target_fs)



cwrapper = CWrapper(ENKF_LIB)
cwrapper.registerType("enkf_simulation_runner", EnkfSimulationRunner)

EnkfSimulationRunner.cNamespace().run_assimilation  = cwrapper.prototype("void enkf_main_run_assimilation(enkf_simulation_runner, bool_vector, int, int, int)")
EnkfSimulationRunner.cNamespace().run_smoother      = cwrapper.prototype("void enkf_main_run_smoother(enkf_simulation_runner, char*, bool)")

EnkfSimulationRunner.cNamespace().run_simple_step   = cwrapper.prototype("bool enkf_main_run_simple_step(enkf_simulation_runner, bool_vector, enkf_init_mode_enum, int)")
EnkfSimulationRunner.cNamespace().smoother_update   = cwrapper.prototype("bool enkf_main_smoother_update(enkf_simulation_runner, enkf_fs)")
EnkfSimulationRunner.cNamespace().run_post_workflow = cwrapper.prototype("void enkf_main_run_post_workflow(enkf_simulation_runner)")
Example #10
0

    def __getitem__(self, index):
        """ @rtype: double """
        assert isinstance(index, int)
        return PlotBlockVector.cNamespace().get(self, index)

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


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



cwrapper = CWrapper(ENKF_LIB)
cwrapper.registerType("plot_block_vector", PlotBlockVector)
cwrapper.registerType("plot_block_vector_obj", PlotBlockVector.createPythonObject)
cwrapper.registerType("plot_block_vector_ref", PlotBlockVector.createCReference)

PlotBlockVector.cNamespace().free = cwrapper.prototype("void enkf_plot_blockvector_free(plot_block_vector)")
PlotBlockVector.cNamespace().alloc = cwrapper.prototype("c_void_p enkf_plot_blockvector_alloc(obs_vector, int)")
PlotBlockVector.cNamespace().size = cwrapper.prototype("int enkf_plot_blockvector_get_size(plot_block_vector)")
PlotBlockVector.cNamespace().get = cwrapper.prototype("double enkf_plot_blockvector_iget(plot_block_vector, int)")


Example #11
0
from ctypes import Structure, c_int
from ert.cwrap import CWrapper


class NodeId(Structure):
    """
    NodeId is specified in enkf_types.h
    """
    _fields_ = [("report_step", c_int), ("iens", c_int)]

    def __init__(self, report_step, realization_number):
        """
        @type report_step: int
        @type realization_number: int
        """
        super(NodeId, self).__init__(report_step, realization_number)


CWrapper.registerType("node_id", NodeId)
Example #12
0
    def getDouble(self, var):
        return AnalysisModule.cNamespace().get_double(self, var)

    def getInt(self, var):
        return AnalysisModule.cNamespace().get_int(self, var)

    def getBool(self, var):
            return AnalysisModule.cNamespace().get_bool(self, var)

    def getStr(self, var):
            test = AnalysisModule.cNamespace().get_str(self, var)
            return str(test)


cwrapper = CWrapper(ANALYSIS_LIB)
cwrapper.registerType("analysis_module", AnalysisModule)
cwrapper.registerType("analysis_module_obj", AnalysisModule.createPythonObject)
cwrapper.registerType("analysis_module_ref", AnalysisModule.createCReference)

AnalysisModule.cNamespace().alloc_external      = cwrapper.prototype("c_void_p analysis_module_alloc_external(rng, char*, char*)")
AnalysisModule.cNamespace().free                = cwrapper.prototype("void analysis_module_free(analysis_module)")
AnalysisModule.cNamespace().get_lib_name        = cwrapper.prototype("char* analysis_module_get_lib_name(analysis_module)")
AnalysisModule.cNamespace().get_module_internal = cwrapper.prototype("bool analysis_module_internal(analysis_module)")
AnalysisModule.cNamespace().set_var             = cwrapper.prototype("bool analysis_module_set_var(analysis_module, char*, char*)")
AnalysisModule.cNamespace().get_table_name      = cwrapper.prototype("char* analysis_module_get_table_name(analysis_module)")
AnalysisModule.cNamespace().get_name            = cwrapper.prototype("char* analysis_module_get_name(analysis_module)")
AnalysisModule.cNamespace().check_option        = cwrapper.prototype("bool analysis_module_check_option(analysis_module, long)")
AnalysisModule.cNamespace().has_var             = cwrapper.prototype("bool analysis_module_has_var(analysis_module, char*)")
AnalysisModule.cNamespace().get_double          = cwrapper.prototype("double analysis_module_get_double(analysis_module, char*)")
AnalysisModule.cNamespace().get_int             = cwrapper.prototype("int analysis_module_get_int(analysis_module, char*)")
AnalysisModule.cNamespace().get_bool             = cwrapper.prototype("bool analysis_module_get_bool(analysis_module, char*)")
Example #13
0
    def dump(self):
        """ 
        Will return a list of tuples (step , CTime , days).
        """
        step_list = []
        for step, t in enumerate(self):
            step_list.append((step, t, self.getSimulationDays(step)))
        return step_list

    def getLastStep(self):
        return TimeMap.cNamespace().last_step(self)


##################################################################
cwrapper = CWrapper(ENKF_LIB)
cwrapper.registerType("time_map", TimeMap)
cwrapper.registerType("time_map_obj", TimeMap.createPythonObject)
cwrapper.registerType("time_map_ref", TimeMap.createCReference)

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

TimeMap.cNamespace().free = cwrapper.prototype(
    "void time_map_free( time_map )")
TimeMap.cNamespace().fread_alloc_readonly = cwrapper.prototype(
    "c_void_p time_map_fread_alloc_readonly(char*)")
TimeMap.cNamespace().alloc = cwrapper.prototype("c_void_p time_map_alloc()")
TimeMap.cNamespace().load = cwrapper.prototype(
    "bool time_map_fread(time_map , char*)")
TimeMap.cNamespace().fload = cwrapper.prototype(
    "bool time_map_fscanf(time_map , char*)")
Example #14
0
        self.__assert_error()
        return UIReturn.cNamespace().last_error(self)
    
    
    def first_error(self):
        self.__assert_error()
        return UIReturn.cNamespace().first_error(self)
    

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




CWrapper.registerType("ui_return_status" , UIReturnStatusEnum)
CWrapper.registerType("ui_return", UIReturn)
CWrapper.registerType("ui_return_obj", UIReturn.createPythonObject)
CWrapper.registerType("ui_return_ref", UIReturn.createCReference)
cwrapper = CWrapper(UTIL_LIB)

UIReturn.cNamespace().alloc = cwrapper.prototype("c_void_p ui_return_alloc( ui_return_status )")
UIReturn.cNamespace().free = cwrapper.prototype("void ui_return_free(ui_return)")
UIReturn.cNamespace().get_status = cwrapper.prototype("ui_return_status ui_return_get_status(ui_return)")
UIReturn.cNamespace().get_help = cwrapper.prototype("char* ui_return_get_help(ui_return)")
UIReturn.cNamespace().add_help = cwrapper.prototype("void ui_return_add_help(ui_return)")
UIReturn.cNamespace().add_error = cwrapper.prototype("void ui_return_add_error(ui_return)")
UIReturn.cNamespace().num_error = cwrapper.prototype("int ui_return_get_error_count(ui_return)")
UIReturn.cNamespace().last_error = cwrapper.prototype("char* ui_return_get_last_error(ui_return)")
UIReturn.cNamespace().first_error = cwrapper.prototype("char* ui_return_get_first_error(ui_return)")
UIReturn.cNamespace().iget_error = cwrapper.prototype("char* ui_return_iget_error(ui_return , int)")
Example #15
0
        host_list = SiteConfig.cNamespace().get_rsh_host_list(self)
        return host_list

    def addRshHost(self, host, max_running):
        SiteConfig.cNamespace().add_rsh_host(self, host, max_running)

    def getLocation(self):
        """ @rtype: str """
        return SiteConfig.cNamespace().get_location(self)


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

cwrapper = CWrapper(ENKF_LIB)
cwrapper.registerType( "site_config" , SiteConfig )
cwrapper.registerType( "site_config_obj" , SiteConfig.createPythonObject)
cwrapper.registerType( "site_config_ref" , SiteConfig.createCReference)


SiteConfig.cNamespace().free                  = cwrapper.prototype("void site_config_free( site_config )")
SiteConfig.cNamespace().get_queue_name        = cwrapper.prototype("char* site_config_get_queue_name(site_config)")
SiteConfig.cNamespace().get_lsf_queue         = cwrapper.prototype("char* site_config_get_lsf_queue(site_config)")
SiteConfig.cNamespace().set_lsf_queue         = cwrapper.prototype("void site_config_set_lsf_queue(site_config, char*)")
SiteConfig.cNamespace().get_max_running_lsf   = cwrapper.prototype("int site_config_get_max_running_lsf(site_config)")
SiteConfig.cNamespace().set_max_running_lsf   = cwrapper.prototype("void site_config_set_max_running_lsf(site_config, int)")
SiteConfig.cNamespace().get_lsf_request       = cwrapper.prototype("char* site_config_get_lsf_request(site_config)")
SiteConfig.cNamespace().set_lsf_request       = cwrapper.prototype("void site_config_set_lsf_request(site_config, char*)")

SiteConfig.cNamespace().get_rsh_command       = cwrapper.prototype("char* site_config_get_rsh_command(site_config)")
SiteConfig.cNamespace().set_rsh_command       = cwrapper.prototype("void site_config_set_rsh_command(site_config, char*)")
Example #16
0
        assert isinstance(obs_key, str)

        c_pointer = LocalObsdataNode.cNamespace().alloc(obs_key)
        super(LocalObsdataNode, self).__init__(c_pointer)

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

    def addRange(self, step_1, step_2):
        assert isinstance(step_1, int)
        assert isinstance(step_2, int)
        LocalObsdataNode.cNamespace().add_range(self, step_1, step_2)

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



cwrapper = CWrapper(ENKF_LIB)
cwrapper.registerType("local_obsdata_node", LocalObsdataNode)
cwrapper.registerType("local_obsdata_node_obj", LocalObsdataNode.createPythonObject)
cwrapper.registerType("local_obsdata_node_ref", LocalObsdataNode.createCReference)

LocalObsdataNode.cNamespace().alloc     = cwrapper.prototype("c_void_p local_obsdata_node_alloc(char*)")
LocalObsdataNode.cNamespace().free      = cwrapper.prototype("void local_obsdata_node_free(local_obsdata_node)")
LocalObsdataNode.cNamespace().get_key   = cwrapper.prototype("char* local_obsdata_node_get_key(local_obsdata_node)")
LocalObsdataNode.cNamespace().add_range = cwrapper.prototype("void local_obsdata_node_add_range(local_obsdata_node, int, int)")



Example #17
0
        return EnsemblePlotData.cNamespace().size(self)

    def __getitem__(self, index):
        """ @rtype: EnsemblePlotDataVector """
        return EnsemblePlotData.cNamespace().get(self, index)

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


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



cwrapper = CWrapper(ENKF_LIB)
cwrapper.registerType("ensemble_plot_data", EnsemblePlotData)
cwrapper.registerType("ensemble_plot_data_obj", EnsemblePlotData.createPythonObject)
cwrapper.registerType("ensemble_plot_data_ref", EnsemblePlotData.createCReference)

EnsemblePlotData.cNamespace().free = cwrapper.prototype("void enkf_plot_data_free(ensemble_plot_data)")
EnsemblePlotData.cNamespace().alloc = cwrapper.prototype("c_void_p enkf_plot_data_alloc(enkf_config_node)")
EnsemblePlotData.cNamespace().load = cwrapper.prototype("void enkf_plot_data_load(ensemble_plot_data, enkf_fs, char*, enkf_state_type_enum, bool_vector)")
EnsemblePlotData.cNamespace().size = cwrapper.prototype("int enkf_plot_data_get_size(ensemble_plot_data)")
EnsemblePlotData.cNamespace().get = cwrapper.prototype("ensemble_plot_data_vector_ref enkf_plot_data_iget(ensemble_plot_data, int)")


Example #18
0
        FortIO stream already opened for writing:

           import ert.ecl.ecl as ecl
           ...
           fortio = ecl.FortIO( "FILE.XX" )
           file.fwrite( fortio )
           fortio.close()
           
        """
        cfunc.fwrite( self , fortio , 0 )

        

# 2. Creating a wrapper object around the libecl library, 
cwrapper = CWrapper(ECL_LIB)
cwrapper.registerType( "ecl_file" , EclFile )


# 3. Installing the c-functions used to manipulate ecl_file instances.
#    These functions are used when implementing the EclFile class, not
#    used outside this scope.
cfunc = CWrapperNameSpace("ecl_file")

cfunc.open                        = cwrapper.prototype("c_void_p    ecl_file_try_open( char* , int )")
cfunc.writable                    = cwrapper.prototype("bool        ecl_file_writable( ecl_file )")
cfunc.new                         = cwrapper.prototype("c_void_p    ecl_file_alloc_empty(  )")
cfunc.save_kw                     = cwrapper.prototype("void        ecl_file_save_kw( ecl_file , ecl_kw )")

cfunc.select_block                = cwrapper.prototype("bool        ecl_file_select_block( ecl_file , char* , int )")
cfunc.restart_block_time          = cwrapper.prototype("bool        ecl_file_select_rstblock_sim_time( ecl_file , time_t )")
cfunc.restart_block_step          = cwrapper.prototype("bool        ecl_file_select_rstblock_report_step( ecl_file , int )")
Example #19
0
        the global index of the cell in the nums vector. If the
        variable in question makes use of the NUMS value this property
        will return the value, otherwise it will return None:

           sum.smspec_node("FOPT").num     => None
           sum.smspec_node("BPR:1000").num => 1000
        """
        if EclSMSPECNode.cNamespace().node_need_num(self):
            return EclSMSPECNode.cNamespace().node_num(self)
        else:
            return None


cwrapper = CWrapper(ECL_LIB)

cwrapper.registerType("smspec_node", EclSMSPECNode)
cwrapper.registerType("smspec_node_obj", EclSMSPECNode.createPythonObject)
cwrapper.registerType("smspec_node_ref", EclSMSPECNode.createCReference)

EclSMSPECNode.cNamespace().node_is_total = cwrapper.prototype(
    "bool smspec_node_is_total( smspec_node )")
EclSMSPECNode.cNamespace().node_is_historical = cwrapper.prototype(
    "bool smspec_node_is_historical( smspec_node )")
EclSMSPECNode.cNamespace().node_is_rate = cwrapper.prototype(
    "bool smspec_node_is_rate( smspec_node )")
EclSMSPECNode.cNamespace().node_unit = cwrapper.prototype(
    "char* smspec_node_get_unit( smspec_node )")
EclSMSPECNode.cNamespace().node_wgname = cwrapper.prototype(
    "char* smspec_node_get_wgname( smspec_node )")
EclSMSPECNode.cNamespace().node_keyword = cwrapper.prototype(
    "char* smspec_node_get_keyword( smspec_node )")
Example #20
0
    def getEnkfSimulationRunner(self):
        """ @rtype: EnkfSimulationRunner """
        return self.__simulation_runner

    def getEnkfFsManager(self):
        """ @rtype: EnkfFsManager """
        return self.__fs_manager

    def getWorkflowList(self):
        """ @rtype: ErtWorkflowList """
        return EnKFMain.cNamespace().get_workflow_list(self).setParent(self)

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

cwrapper = CWrapper(ENKF_LIB)
cwrapper.registerType("enkf_main", EnKFMain)
cwrapper.registerType("enkf_main_ref", EnKFMain.createCReference)


EnKFMain.cNamespace().bootstrap = cwrapper.prototype("c_void_p enkf_main_bootstrap(char*, 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*)")
Example #21
0
        else:
            raise IOError("File: %s does not exists")

    def __getitem__(self, keyword):
        if ConfigParser.cNamespace().has_content(self, keyword):
            return ConfigParser.cNamespace().get_content(
                self, keyword).setParent(self)
        else:
            return None

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


cwrapper = CWrapper(CONFIG_LIB)
cwrapper.registerType("config_parser", ConfigParser)
cwrapper.registerType("config_parser_obj", ConfigParser.createPythonObject)
cwrapper.registerType("config_parser_ref", ConfigParser.createCReference)

cwrapper.registerType("schema_item", SchemaItem)
cwrapper.registerType("schema_item_obj", SchemaItem.createPythonObject)
cwrapper.registerType("schema_item_ref", SchemaItem.createCReference)

cwrapper.registerType("content_item", ContentItem)
cwrapper.registerType("content_item_obj", ContentItem.createPythonObject)
cwrapper.registerType("content_item_ref", ContentItem.createCReference)

cwrapper.registerType("content_node", ContentNode)
cwrapper.registerType("content_node_obj", ContentNode.createPythonObject)
cwrapper.registerType("content_node_ref", ContentNode.createCReference)
Example #22
0
        """ @rtype: EnkfConfigNode """
        return EnsConfig.cNamespace().add_gen_data(self, key).setParent(self)

    def add_field(self, key, eclipse_grid):
        """ @rtype: EnkfConfigNode """
        return EnsConfig.cNamespace().add_field(self, key, eclipse_grid).setParent(self)

    def getKeylistFromVarType(self, var_mask):
        """ @rtype: StringList """
        assert isinstance(var_mask, EnkfVarType)
        return EnsConfig.cNamespace().alloc_keylist_from_var_type(self, var_mask).setParent(self)

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


cwrapper = CWrapper(ENKF_LIB)
cwrapper.registerType("ens_config", EnsConfig)
cwrapper.registerType("ens_config_obj", EnsConfig.createPythonObject)
cwrapper.registerType("ens_config_ref", EnsConfig.createCReference)

EnsConfig.cNamespace().free = cwrapper.prototype("void ensemble_config_free( ens_config )")
EnsConfig.cNamespace().has_key = cwrapper.prototype("bool ensemble_config_has_key( ens_config , char* )")
EnsConfig.cNamespace().get_node = cwrapper.prototype("enkf_config_node_ref ensemble_config_get_node( ens_config , char*)")
EnsConfig.cNamespace().alloc_keylist = cwrapper.prototype("stringlist_ref ensemble_config_alloc_keylist( ens_config )")
EnsConfig.cNamespace().add_summary = cwrapper.prototype("enkf_config_node_ref ensemble_config_add_summary( ens_config, char*, int)")
EnsConfig.cNamespace().add_gen_kw = cwrapper.prototype("enkf_config_node_ref ensemble_config_add_gen_kw( ens_config, char*)")
EnsConfig.cNamespace().add_gen_data = cwrapper.prototype("enkf_config_node_ref ensemble_config_add_gen_data( ens_config, char*)")
EnsConfig.cNamespace().add_field = cwrapper.prototype("enkf_config_node_ref ensemble_config_add_field( ens_config, char*, ecl_grid)")
EnsConfig.cNamespace().alloc_keylist_from_var_type = cwrapper.prototype("stringlist_ref ensemble_config_alloc_keylist_from_var_type(ens_config, enkf_var_type_enum)")
Example #23
0
        """ @rtype: bool """
        return AnalysisConfig.cNamespace().select_module(self, module_name)

    def getActiveModule(self):
        """ :rtype: AnalysisModule """
        return self.getModule(self.activeModuleName())

    def setGlobalStdScaling(self, std_scaling):
        AnalysisConfig.cNamespace().set_global_std_scaling(self, std_scaling)

    def getGlobalStdScaling(self):
        return AnalysisConfig.cNamespace().get_global_std_scaling(self)


cwrapper = CWrapper(ENKF_LIB)
cwrapper.registerType("analysis_config", AnalysisConfig)
cwrapper.registerType("analysis_config_obj", AnalysisConfig.createPythonObject)
cwrapper.registerType("analysis_config_ref", AnalysisConfig.createCReference)

AnalysisConfig.cNamespace().alloc                  = cwrapper.prototype("c_void_p analysis_config_alloc()")
AnalysisConfig.cNamespace().free                   = cwrapper.prototype("void analysis_config_free( analysis_config )")
AnalysisConfig.cNamespace().get_rerun              = cwrapper.prototype("int analysis_config_get_rerun( analysis_config )")
AnalysisConfig.cNamespace().set_rerun              = cwrapper.prototype("void analysis_config_set_rerun( analysis_config, bool)")
AnalysisConfig.cNamespace().get_rerun_start        = cwrapper.prototype("int analysis_config_get_rerun_start( analysis_config )")
AnalysisConfig.cNamespace().set_rerun_start        = cwrapper.prototype("void analysis_config_set_rerun_start( analysis_config, int)")
AnalysisConfig.cNamespace().get_log_path           = cwrapper.prototype("char* analysis_config_get_log_path( analysis_config)")
AnalysisConfig.cNamespace().set_log_path           = cwrapper.prototype("void analysis_config_set_log_path( analysis_config, char*)")

AnalysisConfig.cNamespace().get_merge_observations = cwrapper.prototype("bool analysis_config_get_merge_observations(analysis_config)")
AnalysisConfig.cNamespace().set_merge_observations = cwrapper.prototype("void analysis_config_set_merge_observations(analysis_config, bool)")
AnalysisConfig.cNamespace().get_iter_config        = cwrapper.prototype("analysis_iter_config_ref analysis_config_get_iter_config(analysis_config)")
Example #24
0
            kw = self.getKeyWordForIndex(index)
            if kw == keyword:
                return index
        return None

    def shouldUseLogScale(self, index):
        """ @rtype: bool """
        return bool(EnsemblePlotGenKW.cNamespace().should_use_log_scale(self, index))

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



cwrapper = CWrapper(ENKF_LIB)
cwrapper.registerType("ensemble_plot_gen_kw", EnsemblePlotGenKW)
cwrapper.registerType("ensemble_plot_gen_kw_obj", EnsemblePlotGenKW.createPythonObject)
cwrapper.registerType("ensemble_plot_gen_kw_ref", EnsemblePlotGenKW.createCReference)

EnsemblePlotGenKW.cNamespace().free = cwrapper.prototype("void enkf_plot_gen_kw_free(ensemble_plot_gen_kw)")
EnsemblePlotGenKW.cNamespace().alloc = cwrapper.prototype("c_void_p enkf_plot_gen_kw_alloc(enkf_config_node)")

EnsemblePlotGenKW.cNamespace().size = cwrapper.prototype("int enkf_plot_gen_kw_get_size(ensemble_plot_gen_kw)")
EnsemblePlotGenKW.cNamespace().load = cwrapper.prototype("void enkf_plot_gen_kw_load(ensemble_plot_gen_kw, enkf_fs, bool, int, enkf_state_type_enum, bool_vector)")
EnsemblePlotGenKW.cNamespace().get = cwrapper.prototype("ensemble_plot_gen_kw_vector_ref enkf_plot_gen_kw_iget(ensemble_plot_gen_kw, int)")
EnsemblePlotGenKW.cNamespace().iget_key = cwrapper.prototype("char* enkf_plot_gen_kw_iget_key(ensemble_plot_gen_kw, int)")
EnsemblePlotGenKW.cNamespace().get_keyword_count = cwrapper.prototype("int enkf_plot_gen_kw_get_keyword_count(ensemble_plot_gen_kw)")
EnsemblePlotGenKW.cNamespace().should_use_log_scale = cwrapper.prototype("bool enkf_plot_gen_kw_should_use_log_scale(ensemble_plot_gen_kw, int)")


Example #25
0
        if not isinstance(index, int):
            raise TypeError("Expected an integer")

        size = len(self)
        if index >= size:
            raise IndexError("Index out of range: %d < %d" % (index, size))

        return ConfigError.cNamespace().iget(self, index)

    def __len__(self):
        """ @rtype: int """
        return ConfigError.cNamespace().count(self)

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


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

cwrapper = CWrapper(CONFIG_LIB)
cwrapper.registerType("config_error", ConfigError)
cwrapper.registerType("config_error_obj", ConfigError.createPythonObject)
cwrapper.registerType("config_error_ref", ConfigError.createCReference)

ConfigError.cNamespace().free = cwrapper.prototype(
    "void config_error_free(config_error)")
ConfigError.cNamespace().count = cwrapper.prototype(
    "int config_error_count(config_error)")
ConfigError.cNamespace().iget = cwrapper.prototype(
    "char* config_error_iget(config_error, int)")
Example #26
0
        raise NotImplementedError("Class can not be instantiated directly!")

    def joblist(self):
        """ @rtype: StringList """
        return ForwardModel.cNamespace().alloc_joblist(self)

    def iget_job(self, index):
        """ @rtype: ExtJob """
        return ForwardModel.cNamespace().iget_job(self, index).setParent(self)

    def add_job(self, name):
        """ @rtype: ExtJob """
        return ForwardModel.cNamespace().add_job(self, name).setParent(self)

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

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

cwrapper = CWrapper(JOB_QUEUE_LIB)
cwrapper.registerType("forward_model", ForwardModel)
cwrapper.registerType("forward_model_obj", ForwardModel.createPythonObject)
cwrapper.registerType("forward_model_ref", ForwardModel.createCReference)

ForwardModel.cNamespace().free = cwrapper.prototype("void forward_model_free( forward_model )")
ForwardModel.cNamespace().clear = cwrapper.prototype("void forward_model_clear(forward_model)")
ForwardModel.cNamespace().add_job = cwrapper.prototype("ext_job_ref forward_model_add_job(forward_model, char*)")
ForwardModel.cNamespace().alloc_joblist = cwrapper.prototype("stringlist_obj forward_model_alloc_joblist(forward_model)")
ForwardModel.cNamespace().iget_job = cwrapper.prototype("ext_job_ref forward_model_iget_job( forward_model, int)")
Example #27
0
        assert isinstance(case, str)

        if self.isCaseMounted(case):
            fs = self.getFileSystem(case)
            return fs.getStateMap()
        else:
            return EnkfFsManager.cNamespace().alloc_readonly_state_map(self, case)

    def getTimeMapForCase(self, case):
        """ @rtype: TimeMap """
        assert isinstance(case, str)
        return EnkfFsManager.cNamespace().alloc_readonly_time_map(self, case)


cwrapper = CWrapper(ENKF_LIB)
cwrapper.registerType("enkf_fs_manager", EnkfFsManager)

EnkfFsManager.cNamespace().get_current_fs = cwrapper.prototype("enkf_fs_ref enkf_main_get_fs_ref(enkf_fs_manager)")
EnkfFsManager.cNamespace().switch_fs = cwrapper.prototype("void enkf_main_set_fs(enkf_fs_manager, enkf_fs, char*)")
EnkfFsManager.cNamespace().fs_exists = cwrapper.prototype("bool enkf_main_fs_exists(enkf_fs_manager, char*)")
EnkfFsManager.cNamespace().alloc_caselist = cwrapper.prototype("stringlist_obj enkf_main_alloc_caselist(enkf_fs_manager)")
EnkfFsManager.cNamespace().set_case_table = cwrapper.prototype("void enkf_main_set_case_table(enkf_fs_manager, char*)")

EnkfFsManager.cNamespace().initialize_from_scratch = cwrapper.prototype("void enkf_main_initialize_from_scratch(enkf_fs_manager, stringlist, int, int, bool)")
EnkfFsManager.cNamespace().is_initialized = cwrapper.prototype("bool enkf_main_is_initialized(enkf_fs_manager, bool_vector)")
EnkfFsManager.cNamespace().is_case_initialized = cwrapper.prototype("bool enkf_main_case_is_initialized(enkf_fs_manager, char*, bool_vector)")
EnkfFsManager.cNamespace().initialize_current_case_from_existing = cwrapper.prototype("void enkf_main_init_current_case_from_existing(enkf_fs_manager, enkf_fs, int, enkf_state_type_enum)")
EnkfFsManager.cNamespace().initialize_case_from_existing = cwrapper.prototype("void enkf_main_init_case_from_existing(enkf_fs_manager, enkf_fs, int, enkf_state_type_enum, enkf_fs)")
EnkfFsManager.cNamespace().custom_initialize_from_existing = cwrapper.prototype("void enkf_main_init_current_case_from_existing_custom(enkf_fs_manager, enkf_fs, int, enkf_state_type_enum, stringlist, bool_vector)")

EnkfFsManager.cNamespace().alloc_readonly_state_map = cwrapper.prototype("state_map_obj enkf_main_alloc_readonly_state_map(enkf_fs_manager, char*)")
Example #28
0
        return AnalysisConfig.cNamespace().get_module_list(self)

    def getModule(self, module_name):
        """ @rtype: AnalysisModule """
        return AnalysisConfig.cNamespace().get_module(self, module_name)

    def selectModule(self, module_name):
        """ @rtype: bool """
        return AnalysisConfig.cNamespace().select_module(self, module_name)



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

cwrapper = CWrapper(ENKF_LIB)
cwrapper.registerType("analysis_config", AnalysisConfig)
cwrapper.registerType("analysis_config_obj", AnalysisConfig.createPythonObject)
cwrapper.registerType("analysis_config_ref", AnalysisConfig.createCReference)

AnalysisConfig.cNamespace().alloc                  = cwrapper.prototype("c_void_p analysis_config_alloc()")
AnalysisConfig.cNamespace().free                   = cwrapper.prototype("void analysis_config_free( analysis_config )")
AnalysisConfig.cNamespace().get_rerun              = cwrapper.prototype("int analysis_config_get_rerun( analysis_config )")
AnalysisConfig.cNamespace().set_rerun              = cwrapper.prototype("void analysis_config_set_rerun( analysis_config, bool)")
AnalysisConfig.cNamespace().get_rerun_start        = cwrapper.prototype("int analysis_config_get_rerun_start( analysis_config )")
AnalysisConfig.cNamespace().set_rerun_start        = cwrapper.prototype("void analysis_config_set_rerun_start( analysis_config, int)")
AnalysisConfig.cNamespace().get_log_path           = cwrapper.prototype("char* analysis_config_get_log_path( analysis_config)")
AnalysisConfig.cNamespace().set_log_path           = cwrapper.prototype("void analysis_config_set_log_path( analysis_config, char*)")
AnalysisConfig.cNamespace().get_alpha              = cwrapper.prototype("double analysis_config_get_alpha(analysis_config)")
AnalysisConfig.cNamespace().set_alpha              = cwrapper.prototype("void analysis_config_set_alpha(analysis_config, double)")
AnalysisConfig.cNamespace().get_merge_observations = cwrapper.prototype("bool analysis_config_get_merge_observations(analysis_config)")
AnalysisConfig.cNamespace().set_merge_observations = cwrapper.prototype("void analysis_config_set_merge_observations(analysis_config, bool)")
Example #29
0
    def getOutputFormat(self):
        return GenDataConfig.cNamespace().get_output_format(self)

    def getInputFormat(self):
        return GenDataConfig.cNamespace().get_input_format(self)

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

    def hasReportStep(self, report_step):
        """ @rtype: bool """
        return GenDataConfig.cNamespace().has_report_step(self, report_step)


cwrapper = CWrapper(ENKF_LIB)
cwrapper.registerType("gen_data_config", GenDataConfig)
cwrapper.registerType("gen_data_config_obj", GenDataConfig.createPythonObject)
cwrapper.registerType("gen_data_config_ref", GenDataConfig.createCReference)

GenDataConfig.cNamespace().alloc = cwrapper.prototype(
    "c_void_p gen_data_config_alloc_GEN_DATA_result( char* , gen_data_file_format_type)"
)
GenDataConfig.cNamespace().free = cwrapper.prototype(
    "void gen_data_config_free( gen_data_config )")
GenDataConfig.cNamespace().get_output_format = cwrapper.prototype(
    "gen_data_file_format_type gen_data_config_get_output_format(gen_data_config)"
)
GenDataConfig.cNamespace().get_input_format = cwrapper.prototype(
    "gen_data_file_format_type gen_data_config_get_input_format(gen_data_config)"
)
GenDataConfig.cNamespace().get_template_file = cwrapper.prototype(
Example #30
0
            self.setValue(self.value() + CTime(other).value())
            return self

    def __add__(self, other):
        copy = CTime(self)
        copy += other
        return copy

    def __radd__(self, other):
        return self + other

    def __mul__(self, other):
        copy = CTime(self)
        copy *= other
        return copy

    def __rmul__(self, other):
        return self * other

    def timetuple(self):
        # this function is a requirement for comparing against datetime objects where the CTime is on the right side
        pass

    @property
    def stripped(self):
        return time.strptime(self, "%Y-%m-%d %H:%M:S%")


cwrapper = CWrapper(None)
cwrapper.registerType("time_t", CTime)
Example #31
0
        EclConfig.cNamespace().clear_static_kw(self)

    def add_static_kw(self, kw):
        EclConfig.cNamespace().add_static_kw(self, kw)

    #-----------------------------------------------------------------

    def getDepthUnit(self):
        return EclConfig.cNamespace().get_depth_unit(self)

    def getPressureUnit(self):
        return EclConfig.cNamespace().get_pressure_unit(self)


cwrapper = CWrapper(ENKF_LIB)
cwrapper.registerType("ecl_config", EclConfig)
cwrapper.registerType("ecl_config_obj", EclConfig.createPythonObject)
cwrapper.registerType("ecl_config_ref", EclConfig.createCReference)

EclConfig.cNamespace().alloc = cwrapper.prototype(
    "c_void_p ecl_config_alloc( )")
EclConfig.cNamespace().free = cwrapper.prototype(
    "void ecl_config_free( ecl_config )")

EclConfig.cNamespace().get_eclbase = cwrapper.prototype(
    "char* ecl_config_get_eclbase( ecl_config )")
EclConfig.cNamespace().validate_eclbase = cwrapper.prototype(
    "ui_return_obj ecl_config_validate_eclbase( ecl_config , char*)")
EclConfig.cNamespace().set_eclbase = cwrapper.prototype(
    "void ecl_config_set_eclbase( ecl_config , char*)")
    def __init__(self):
        raise NotImplementedError("Class can not be instantiated directly!")

    def __len__(self):
        """ @rtype: int """
        return EnsemblePlotDataVector.cNamespace().size(self)

    def getValue(self, index):
        """ @rtype: float """
        return EnsemblePlotDataVector.cNamespace().get_value(self, index)

    def getTime(self, index):
        """ @rtype: CTime """
        return EnsemblePlotDataVector.cNamespace().get_time(self, index)

    def isActive(self, index):
        """ @rtype: bool """
        return EnsemblePlotDataVector.cNamespace().is_active(self, index)



cwrapper = CWrapper(ENKF_LIB)
cwrapper.registerType("ensemble_plot_data_vector", EnsemblePlotDataVector)
cwrapper.registerType("ensemble_plot_data_vector_obj", EnsemblePlotDataVector.createPythonObject)
cwrapper.registerType("ensemble_plot_data_vector_ref", EnsemblePlotDataVector.createCReference)

EnsemblePlotDataVector.cNamespace().size = cwrapper.prototype("int enkf_plot_tvector_size(ensemble_plot_data_vector)")
EnsemblePlotDataVector.cNamespace().get_value = cwrapper.prototype("double enkf_plot_tvector_iget_value(ensemble_plot_data_vector, int)")
EnsemblePlotDataVector.cNamespace().get_time = cwrapper.prototype("time_t enkf_plot_tvector_iget_time(ensemble_plot_data_vector, int)")
EnsemblePlotDataVector.cNamespace().is_active = cwrapper.prototype("bool enkf_plot_tvector_iget_active(ensemble_plot_data_vector, int)")
Example #33
0
        densities for as many PVT regions as you like, and then fall
        back to the default density for the others.

        The new_std_density() method must be called before calling the
        add_std_density() method.
        
        The new_std_density() and add_std_density() methods must be
        used before you use the add_survey_FIP() method to add a
        survey based on the FIP keyword.
        """
        cfunc.add_std_density(self, phase_enum, pvtnum, density)


# 2. Creating a wrapper object around the libecl library,
cwrapper = CWrapper(ECL_LIB)
cwrapper.registerType("ecl_grav", EclGrav)

# 3. Installing the c-functions used to manipulate ecl_grav instances.
#    These functions are used when implementing the EclGrav class, not
#    used outside this scope.
cfunc = CWrapperNameSpace("ecl_grav")

cfunc.grav_alloc = cwrapper.prototype(
    "c_void_p ecl_grav_alloc( ecl_grid , ecl_file )")
cfunc.free = cwrapper.prototype("void ecl_grav_free( ecl_grav )")

# Return value ignored in the add_survey_xxx() functions:
cfunc.add_survey_RPORV = cwrapper.prototype(
    "c_void_p  ecl_grav_add_survey_RPORV( ecl_grav , char* , ecl_file )")
cfunc.add_survey_PORMOD = cwrapper.prototype(
    "c_void_p  ecl_grav_add_survey_PORMOD( ecl_grav , char* , ecl_file )")
Example #34
0
            return LocalObsdata.cNamespace().has_node(self, item)
        elif isinstance(item, LocalObsdataNode):
            return LocalObsdata.cNamespace().has_node(self, item.getKey())

        return False

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

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



cwrapper = CWrapper(ENKF_LIB)
cwrapper.registerType("local_obsdata", LocalObsdata)
cwrapper.registerType("local_obsdata_obj", LocalObsdata.createPythonObject)
cwrapper.registerType("local_obsdata_ref", LocalObsdata.createCReference)

LocalObsdata.cNamespace().alloc    = cwrapper.prototype("c_void_p local_obsdata_alloc(char*)")
LocalObsdata.cNamespace().free     = cwrapper.prototype("void local_obsdata_free(local_obsdata)")
LocalObsdata.cNamespace().size     = cwrapper.prototype("int local_obsdata_get_size(local_obsdata)")
LocalObsdata.cNamespace().has_node = cwrapper.prototype("bool local_obsdata_has_node(local_obsdata, char*)")
LocalObsdata.cNamespace().add_node = cwrapper.prototype("bool local_obsdata_add_node(local_obsdata, local_obsdata_node)")
LocalObsdata.cNamespace().get_node = cwrapper.prototype("local_obsdata_node_ref local_obsdata_iget(local_obsdata, int)")
LocalObsdata.cNamespace().name     = cwrapper.prototype("char* local_obsdata_get_name(local_obsdata)")



Example #35
0
        return len(self)

    def getIndex(self, obs_index):
        """ @rtype: int """
        return self.getDataIndex( obs_index )
        
    def getDataIndex(self, obs_index):
        return GenObservation.cNamespace().get_data_index(self, obs_index)

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



cwrapper = CWrapper(ENKF_LIB)
cwrapper.registerType("gen_obs", GenObservation)
cwrapper.registerType("gen_obs_obj", GenObservation.createPythonObject)
cwrapper.registerType("gen_obs_ref", GenObservation.createCReference)

GenObservation.cNamespace().alloc = cwrapper.prototype("c_void_p gen_obs_alloc__(gen_data_config , char*)")
GenObservation.cNamespace().free = cwrapper.prototype("void gen_obs_free(gen_data_config)")
GenObservation.cNamespace().load = cwrapper.prototype("void gen_obs_load_observation(gen_obs , char*)")
GenObservation.cNamespace().scalar_set = cwrapper.prototype("void gen_obs_set_scalar(gen_obs , double , double)")
GenObservation.cNamespace().get_value = cwrapper.prototype("double gen_obs_iget_value(summary_obs)")
GenObservation.cNamespace().get_std_scaling = cwrapper.prototype("double gen_obs_iget_std_scaling(summary_obs)")
GenObservation.cNamespace().get_std = cwrapper.prototype("double gen_obs_iget_std(gen_obs, int)")
GenObservation.cNamespace().get_size = cwrapper.prototype("int gen_obs_get_size(gen_obs)")
GenObservation.cNamespace().get_data_index = cwrapper.prototype("int gen_obs_get_obs_index(gen_obs, int)")
GenObservation.cNamespace().load_data_index = cwrapper.prototype("void gen_obs_load_data_index(gen_obs , char*)")
GenObservation.cNamespace().add_data_index = cwrapper.prototype("void gen_obs_attach_data_index(gen_obs , int_vector)")
GenObservation.cNamespace().update_std_scaling = cwrapper.prototype("void gen_obs_update_std_scale(gen_obs , double , active_list)")
Example #36
0
File: driver.py Project: akva2/ert
        """

        options = [("RSH_CMD", rsh_cmd)]
        for (host, host_max) in rsh_host_list:
            options.append(("RSH_HOST", "%s:%d" % (host, host_max)))
        Driver.__init__(self, QueueDriverEnum.RSH_DRIVER, max_running, options=options)


#Legacy enum support for ecl_local.py
LSF_DRIVER = QueueDriverEnum.LSF_DRIVER
RSH_DRIVER = QueueDriverEnum.RSH_DRIVER
LOCAL_DRIVER = QueueDriverEnum.LOCAL_DRIVER

#################################################################
cwrapper = CWrapper(JOB_QUEUE_LIB)
cwrapper.registerType("driver", Driver)
cwrapper.registerType("job", Job)

cfunc = CWrapperNameSpace("driver")

cfunc.alloc_driver_lsf = cwrapper.prototype("c_void_p    queue_driver_alloc_LSF( char* , char* , char* )")
cfunc.alloc_driver_local = cwrapper.prototype("c_void_p    queue_driver_alloc_local( )")
cfunc.alloc_driver_rsh = cwrapper.prototype("c_void_p    queue_driver_alloc_RSH( char* , c_void_p )")
cfunc.alloc_driver = cwrapper.prototype("c_void_p    queue_driver_alloc( int )")
cfunc.set_driver_option = cwrapper.prototype("void        queue_driver_set_option(driver , char* , char*)")

cfunc.free_driver = cwrapper.prototype("void        queue_driver_free( driver )")
cfunc.submit = cwrapper.prototype("c_void_p    queue_driver_submit_job( driver , char* , int , char* , char* , int , char**)")
cfunc.free_job = cwrapper.prototype("void        queue_driver_free_job( driver , job )")
cfunc.cget_status = cwrapper.prototype("int         queue_driver_get_status( driver , job)")
cfunc.kill_job = cwrapper.prototype("void        queue_driver_kill_job( driver , job )")
Example #37
0
        surrounded by \'<\' and \'>\'.
        """
        doc_string = None
        if isinstance(value, str):
            EnKFState.cNamespace().add_subst_kw(self, key, value, doc_string)
        else:
            raise TypeError("The value argument must be a string")

    def getDataKW(self):
        """
        Will return the substitution map for this realisation.
        """
        return EnKFState.cNamespace().get_subst_list(self)


cwrapper = CWrapper(ENKF_LIB)
cwrapper.registerType("enkf_state", EnKFState)
cwrapper.registerType("enkf_state_obj", EnKFState.createPythonObject)
cwrapper.registerType("enkf_state_ref", EnKFState.createCReference)

EnKFState.cNamespace().free = cwrapper.prototype(
    "void enkf_state_free( enkf_state )")
EnKFState.cNamespace().has_key = cwrapper.prototype(
    "bool enkf_state_has_node( enkf_state , char* )")
EnKFState.cNamespace().get_node = cwrapper.prototype(
    "enkf_node_ref enkf_state_get_node( enkf_state , char* )")
EnKFState.cNamespace().add_subst_kw = cwrapper.prototype(
    "void enkf_state_add_subst_kw( enkf_state , char* , char* , char*)")
EnKFState.cNamespace().get_subst_list = cwrapper.prototype(
    "subst_list_ref enkf_state_get_subst_list( enkf_state )")
Example #38
0
            yield self[cur]
            cur += 1

    def getObservation(self):
        """ @rtype: float """
        return PcaPlotVector.cNamespace().get_obs(self)

    def getSingularValue(self):
        """ @rtype: float """
        return PcaPlotVector.cNamespace().get_singular_value(self)
        

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



cwrapper = CWrapper(ENKF_LIB)
cwrapper.registerType("pca_plot_vector", PcaPlotVector)
cwrapper.registerType("pca_plot_vector_obj", PcaPlotVector.createPythonObject)
cwrapper.registerType("pca_plot_vector_ref", PcaPlotVector.createCReference)

PcaPlotVector.cNamespace().alloc   = cwrapper.prototype("c_void_p pca_plot_vector_alloc(int, matrix, matrix)")
PcaPlotVector.cNamespace().free    = cwrapper.prototype("void pca_plot_vector_free(pca_plot_vector)")
PcaPlotVector.cNamespace().size    = cwrapper.prototype("int pca_plot_vector_get_size(pca_plot_vector)")
PcaPlotVector.cNamespace().get     = cwrapper.prototype("double pca_plot_vector_iget_sim_value(pca_plot_vector, int)")
PcaPlotVector.cNamespace().get_obs = cwrapper.prototype("double pca_plot_vector_get_obs_value(pca_plot_vector)")
PcaPlotVector.cNamespace().get_singular_value = cwrapper.prototype("double pca_plot_vector_get_singular_value(pca_plot_vector)")


Example #39
0
            result._initialize()
        return result

    @classmethod
    def createPythonObject(cls, c_pointer):
        result = super(EclSum, cls).createPythonObject(c_pointer)
        result._initialize()
        return result

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


# 2. Creating a wrapper object around the libecl library,
#    registering the type map : ecl_kw <-> EclKW
cwrapper = CWrapper(ECL_LIB)
cwrapper.registerType("ecl_sum", EclSum)
cwrapper.registerType("ecl_sum_obj", EclSum.createPythonObject)
cwrapper.registerType("ecl_sum_ref", EclSum.createCReference)

# 3. Installing the c-functions used to manipulate ecl_kw instances.
#    These functions are used when implementing the EclKW class, not
#    used outside this scope.

EclSum.cNamespace().fread_alloc = cwrapper.prototype(
    "c_void_p ecl_sum_fread_alloc_case__( char* , char* , bool)")
EclSum.cNamespace().iiget = cwrapper.prototype(
    "double   ecl_sum_iget( ecl_sum , int , int)")
EclSum.cNamespace().free = cwrapper.prototype(
    "void     ecl_sum_free( ecl_sum )")
EclSum.cNamespace().data_length = cwrapper.prototype(
    "int      ecl_sum_get_data_length( ecl_sum )")
Example #40
0

class TimeVector(TVector):
    default_format = "%d"

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


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

buffer_from_ptr = ctypes.pythonapi.PyBuffer_FromMemory
buffer_from_ptr.restype  = ctypes.py_object
buffer_from_ptr.argtypes = [ ctypes.c_void_p , ctypes.c_long ]

CWrapper.registerType("double_vector", DoubleVector)
CWrapper.registerType("double_vector_obj", DoubleVector.createPythonObject)
CWrapper.registerType("double_vector_ref", DoubleVector.createCReference)

CWrapper.registerType("int_vector", IntVector)
CWrapper.registerType("int_vector_obj", IntVector.createPythonObject)
CWrapper.registerType("int_vector_ref", IntVector.createCReference)

CWrapper.registerType("bool_vector", BoolVector)
CWrapper.registerType("bool_vector_obj", BoolVector.createPythonObject)
CWrapper.registerType("bool_vector_ref", BoolVector.createCReference)

CWrapper.registerType("time_t_vector", TimeVector)
CWrapper.registerType("time_t_vector_obj", TimeVector.createPythonObject)
CWrapper.registerType("time_t_vector_ref", TimeVector.createCReference)
Example #41
0
#  (at your option) any later version.
#
#  ERT is distributed in the hope that it will be useful, but WITHOUT ANY
#  WARRANTY; without even the implied warranty of MERCHANTABILITY or
#  FITNESS FOR A PARTICULAR PURPOSE.
#
#  See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
#  for more details.

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


class Buffer(BaseCClass):
    def __init__(self, size):
        super(Buffer, self).__init__(Buffer.cNamespace().alloc(size))

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


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

cwrapper = CWrapper(UTIL_LIB)
cwrapper.registerType("buffer", Buffer)
cwrapper.registerType("buffer_obj", Buffer.createPythonObject)
cwrapper.registerType("buffer_ref", Buffer.createCReference)

Buffer.cNamespace().free = cwrapper.prototype("void buffer_free(buffer)")
Buffer.cNamespace().alloc = cwrapper.prototype("c_void_p buffer_alloc(int)")
Example #42
0
    def get_initial_size(self):
        return GenDataConfig.cNamespace().get_initial_size(self)

    def get_output_format(self):
        return GenDataConfig.cNamespace().get_output_format(self)

    def get_input_format(self):
        return GenDataConfig.cNamespace().get_input_format(self)

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


cwrapper = CWrapper(ENKF_LIB)
cwrapper.registerType("gen_data_config", GenDataConfig)
cwrapper.registerType("gen_data_config_obj", GenDataConfig.createPythonObject)
cwrapper.registerType("gen_data_config_ref", GenDataConfig.createCReference)

# 3. Installing the c-functions used to manipulate ecl_kw instances.
#    These functions are used when implementing the EclKW class, not
#    used outside this scope.

GenDataConfig.cNamespace().free = cwrapper.prototype("void gen_data_config_free( gen_data_config )")
GenDataConfig.cNamespace().get_output_format = cwrapper.prototype(
    "c_void_p gen_data_config_get_output_format(gen_data_config)"
)  # todo: fix return type
GenDataConfig.cNamespace().get_input_format = cwrapper.prototype(
    "c_void_p gen_data_config_get_input_format(gen_data_config)"
)  # todo: fix return type
GenDataConfig.cNamespace().get_template_file = cwrapper.prototype(
Example #43
0
        c_pointer = LocalObsdataNode.cNamespace().alloc(obs_key)
        super(LocalObsdataNode, self).__init__(c_pointer)

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

    def addRange(self, step_1, step_2):
        assert isinstance(step_1, int)
        assert isinstance(step_2, int)
        LocalObsdataNode.cNamespace().add_range(self, step_1, step_2)

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


cwrapper = CWrapper(ENKF_LIB)
cwrapper.registerType("local_obsdata_node", LocalObsdataNode)
cwrapper.registerType("local_obsdata_node_obj",
                      LocalObsdataNode.createPythonObject)
cwrapper.registerType("local_obsdata_node_ref",
                      LocalObsdataNode.createCReference)

LocalObsdataNode.cNamespace().alloc = cwrapper.prototype(
    "c_void_p local_obsdata_node_alloc(char*)")
LocalObsdataNode.cNamespace().free = cwrapper.prototype(
    "void local_obsdata_node_free(local_obsdata_node)")
LocalObsdataNode.cNamespace().get_key = cwrapper.prototype(
    "char* local_obsdata_node_get_key(local_obsdata_node)")
LocalObsdataNode.cNamespace().add_range = cwrapper.prototype(
    "void local_obsdata_node_add_range(local_obsdata_node, int, int)")
Example #44
0
    def __getitem__(self, index):
        if not isinstance(index, int):
            raise IndexError("Index must be a number!")

        if index < 0 or index >= len(self):
            raise IndexError("Index must be in the range: [%i, %i]" % (0, len(self) - 1))

        key =  SubstitutionList.cNamespace().get_key(self, index)
        value =  SubstitutionList.cNamespace().get_value(self, index)
        doc_string = SubstitutionList.cNamespace().get_doc_string(self, index)

        return key, value, doc_string

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

cwrapper = CWrapper(UTIL_LIB)
CWrapper.registerType("subst_list", SubstitutionList)
CWrapper.registerType("subst_list_obj", SubstitutionList.createPythonObject)
CWrapper.registerType("subst_list_ref", SubstitutionList.createCReference)

SubstitutionList.cNamespace().alloc = cwrapper.prototype("c_void_p subst_list_alloc(c_void_p)")
SubstitutionList.cNamespace().free = cwrapper.prototype("void subst_list_free(subst_list)")

SubstitutionList.cNamespace().size = cwrapper.prototype("int subst_list_get_size(subst_list)")
SubstitutionList.cNamespace().get_key = cwrapper.prototype("char* subst_list_iget_key(subst_list, int)")
SubstitutionList.cNamespace().get_value = cwrapper.prototype("char* subst_list_iget_value(subst_list, int)")
SubstitutionList.cNamespace().get_doc_string = cwrapper.prototype("char* subst_list_iget_doc_string(subst_list, int)")

SubstitutionList.cNamespace().append_copy = cwrapper.prototype("void subst_list_append_copy(subst_list, char*, char*, char*)")
Example #45
0
        @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)
cwrapper.registerType("block_data_config", BlockDataConfig)

BlockObservation.cNamespace().alloc = cwrapper.prototype(
    "c_void_p block_obs_alloc( char* , block_data_config , ecl_grid )")
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 )")
Example #46
0
        else:
            super(EclSumKeyWordVector, self).__init__(c_pointer)

    def __len__(self):
        return EclSumKeyWordVector.cNamespace().get_size(self)

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

    def addKeyword(self, keyword):
        success = EclSumKeyWordVector.cNamespace().add(self, keyword)
        if not success:
            raise KeyError("Failed to add keyword to vector")

    def addKeywords(self, keyword_pattern):
        EclSumKeyWordVector.cNamespace().add_multiple(self, keyword_pattern)


cwrapper = CWrapper(ECL_LIB)
cwrapper.registerType("ecl_sum_vector", EclSumKeyWordVector)
cwrapper.registerType("ecl_sum_vector_obj", EclSumKeyWordVector.createPythonObject)
cwrapper.registerType("ecl_sum_vector_ref", EclSumKeyWordVector.createCReference)

EclSumKeyWordVector.cNamespace().alloc = cwrapper.prototype("c_void_p ecl_sum_vector_alloc(ecl_sum )")
EclSumKeyWordVector.cNamespace().free = cwrapper.prototype("void ecl_sum_vector_free(ecl_sum_vector )")
EclSumKeyWordVector.cNamespace().add = cwrapper.prototype("bool ecl_sum_vector_add_key( ecl_sum_vector ,  char* )")
EclSumKeyWordVector.cNamespace().add_multiple = cwrapper.prototype(
    "void ecl_sum_vector_add_keys( ecl_sum_vector ,  char* )"
)
EclSumKeyWordVector.cNamespace().get_size = cwrapper.prototype("int ecl_sum_vector_get_size( ecl_sum_vector )")
Example #47
0
#  WARRANTY; without even the implied warranty of MERCHANTABILITY or
#  FITNESS FOR A PARTICULAR PURPOSE.
#
#  See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
#  for more details.

import ctypes
from ert.cwrap import CWrapper
from ert.util import UTIL_LIB


def cstringObj(c_ptr):
    """The cstringObj function is a convenience function which creates a
    Python string copy, and discards the underlying C allocated storage
    for strings created with *alloc() functions in C.

    This function should not be invoked directly, only indirectly
    through the prototyping of the symbol 'cstring_obj'.

    """
    if c_ptr is not None:
        python_string = ctypes.c_char_p(c_ptr).value
        UTIL_LIB.free(c_ptr)
        return python_string
    else:
        return None


cwrapper = CWrapper(UTIL_LIB)
cwrapper.registerType("cstring_obj", cstringObj)
Example #48
0
class SchedFile(BaseCClass):
    def __init__(self, filename, start_time):
        if os.path.isfile(filename):
            c_ptr = SchedFile.cNamespace().parse(filename, CTime(start_time))
            super(SchedFile, self).__init__(c_ptr)
        else:
            raise IOError("No such file: %s" % filename)

    @property
    def length(self):
        """ @rtype: int """
        return SchedFile.cNamespace().length(self)

    def write(self, filename, num_dates, add_end=True):
        SchedFile.cNamespace().write(self, num_dates, filename, add_end)

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


cwrapper = CWrapper(SCHED_LIB)
cwrapper.registerType("sched_file", SchedFile)
cwrapper.registerType("sched_file_obj", SchedFile.createPythonObject)
cwrapper.registerType("sched_file_ref", SchedFile.createCReference)

SchedFile.cNamespace().parse = cwrapper.prototype("c_void_p sched_file_parse_alloc( char*, time_t )")
SchedFile.cNamespace().write = cwrapper.prototype("void sched_file_fprintf_i( sched_file , int , char* , bool)")
SchedFile.cNamespace().length = cwrapper.prototype("int sched_file_get_num_restart_files( sched_file )")
SchedFile.cNamespace().free = cwrapper.prototype("void sched_file_free( sched_file )")
Example #49
0
    def setAll(self , value):
        Matrix.cNamespace().set_all(self, value)


    def prettyPrint(self, name, fmt="%6.3g"):
        Matrix.cNamespace().pretty_print(self, name, fmt)


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


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

cwrapper = CWrapper(UTIL_LIB)
CWrapper.registerType("matrix", Matrix)
CWrapper.registerType("matrix_obj", Matrix.createPythonObject)
CWrapper.registerType("matrix_ref", Matrix.createCReference)

Matrix.cNamespace().matrix_alloc = cwrapper.prototype("c_void_p matrix_alloc(int, int )")
Matrix.cNamespace().free = cwrapper.prototype("void   matrix_free(matrix)")
Matrix.cNamespace().iget = cwrapper.prototype("double matrix_iget( matrix , int , int )")
Matrix.cNamespace().iset = cwrapper.prototype("void   matrix_iset( matrix , int , int , double)")
Matrix.cNamespace().set_all = cwrapper.prototype("void   matrix_scalar_set( matrix , double)")
Matrix.cNamespace().scale_column = cwrapper.prototype("void matrix_scale_column(matrix , int , double)")
Matrix.cNamespace().scale_row    = cwrapper.prototype("void matrix_scale_row(matrix , int , double)")

Matrix.cNamespace().rows = cwrapper.prototype("int matrix_get_rows(matrix)")
Matrix.cNamespace().columns = cwrapper.prototype("int matrix_get_columns(matrix)")
Matrix.cNamespace().equal = cwrapper.prototype("bool matrix_equal(matrix, matrix)")
Example #50
0
    def get_runpath_as_char(self):
        """ @rtype: str """
        return ModelConfig.cNamespace().get_runpath_as_char(self)

    def select_runpath(self, path_key):
        """ @rtype: bool """
        return ModelConfig.cNamespace().select_runpath(self, path_key)

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

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

cwrapper = CWrapper(ENKF_LIB)
cwrapper.registerType("model_config", ModelConfig)
cwrapper.registerType("model_config_obj", ModelConfig.createPythonObject)
cwrapper.registerType("model_config_ref", ModelConfig.createCReference)


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

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)")
Example #51
0
#  Copyright (C) 2012  Statoil ASA, Norway. 
#   
#  The file 'field_config.py' is part of ERT - Ensemble based Reservoir Tool. 
#   
#  ERT is free software: you can redistribute it and/or modify 
#  it under the terms of the GNU General Public License as published by 
#  the Free Software Foundation, either version 3 of the License, or 
#  (at your option) any later version. 
#   
#  ERT is distributed in the hope that it will be useful, but WITHOUT ANY 
#  WARRANTY; without even the implied warranty of MERCHANTABILITY or 
#  FITNESS FOR A PARTICULAR PURPOSE.   
#   
#  See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html> 
#  for more details.
from ert.cwrap import BaseCClass, CWrapper
from ert.enkf import ENKF_LIB


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


cwrapper = CWrapper(ENKF_LIB)
cwrapper.registerType("summary_config", SummaryConfig)
cwrapper.registerType("summary_config", SummaryConfig.createPythonObject)
cwrapper.registerType("summary_config", SummaryConfig.createCReference)

Example #52
0
 def registerEnum(cls, library, enum_name):
     cwrapper = CWrapper(library)
     cwrapper.registerType(enum_name, cls)
Example #53
0
        """ @rtype: Matrix """
        assert isinstance(size, int)
        return ObsData.cNamespace().allocdObs(self, size)

    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.registerType("obs_data", ObsData)
cwrapper.registerType("obs_data_obj", ObsData.createPythonObject)
cwrapper.registerType("obs_data_ref", ObsData.createCReference)

ObsData.cNamespace().alloc = cwrapper.prototype("c_void_p obs_data_alloc()")
ObsData.cNamespace().free = cwrapper.prototype("void obs_data_free(obs_data)")
ObsData.cNamespace().active_size = cwrapper.prototype(
    "int obs_data_get_active_size(obs_data)")

ObsData.cNamespace().allocdObs = cwrapper.prototype(
    "matrix_obj obs_data_allocdObs(obs_data, int)")
ObsData.cNamespace().scale = cwrapper.prototype(
    "void obs_data_scale(obs_data, matrix, matrix, matrix, matrix, matrix)")
Example #54
0
        i.e. you must subtract 1 from the (i,j,k) values given in the ECLIPSE input.
        """
        cell_ptr = cfunc_rft.lookup_ijk( self , ijk[0] , ijk[1] , ijk[2])
        if cell_ptr:
            return self.__cell_ref( cell_ptr )
        else:
            return None





# 2. Creating a wrapper object around the libecl library, 
#    registering the type map : ecl_kw <-> EclKW
cwrapper = CWrapper(ECL_LIB)
cwrapper.registerType( "ecl_rft_file" , EclRFTFile )
cwrapper.registerType( "ecl_rft"      , EclRFT )

cfunc_file = CWrapperNameSpace("ecl_rft_file")
cfunc_rft  = CWrapperNameSpace("ecl_rft")

cfunc_file.load                     = cwrapper.prototype("c_void_p ecl_rft_file_alloc_case( char* )")
cfunc_file.has_rft                  = cwrapper.prototype("bool ecl_rft_file_case_has_rft( char* )")
cfunc_file.free                     = cwrapper.prototype("void ecl_rft_file_free( ecl_rft_file )")
cfunc_file.get_size                 = cwrapper.prototype("int ecl_rft_file_get_size__( ecl_rft_file , char* , time_t)")
cfunc_file.iget                     = cwrapper.prototype("c_void_p ecl_rft_file_iget_node( ecl_rft_file , int )")
cfunc_file.get_num_wells            = cwrapper.prototype("int  ecl_rft_file_get_num_wells( ecl_rft_file )")
cfunc_file.get_rft                  = cwrapper.prototype("c_void_p ecl_rft_file_get_well_time_rft( ecl_rft_file , char* , time_t)")

cfunc_rft.get_type                  = cwrapper.prototype("int    ecl_rft_node_get_type( ecl_rft )")
cfunc_rft.get_well                  = cwrapper.prototype("char*  ecl_rft_node_get_well_name( ecl_rft )")
Example #55
0
        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.registerType("hash", Hash)  #c_void_p type
CWrapper.registerType("integer_hash", IntegerHash)
CWrapper.registerType("string_has", StringHash)
CWrapper.registerType("double_hash", DoubleHash)

CWrapper.registerType("hash_obj", Hash.createPythonObject)  #c_void_p type
CWrapper.registerType("string_hash_obj", StringHash.createPythonObject)
CWrapper.registerType("integer_hash_obj", IntegerHash.createPythonObject)
CWrapper.registerType("double_hash_obj", DoubleHash.createPythonObject)

CWrapper.registerType("hash_ref", Hash.createCReference)  #c_void_p type
CWrapper.registerType("string_hash_ref", StringHash.createCReference)
CWrapper.registerType("integer_hash_ref", IntegerHash.createCReference)
CWrapper.registerType("double_hash_ref", DoubleHash.createCReference)

Hash.cNamespace().alloc = cwrapper.prototype("long hash_alloc()")
Example #56
0
    def iget_node(self, index):
        ObsVector.cNamespace().iget_node(self, index) #warn: should return something!

    def get_num_active(self):
        """ @rtype: int """
        return ObsVector.cNamespace().get_num_active(self)

    def iget_active(self, index):
        """ @rtype: bool """
        return ObsVector.cNamespace().iget_active(self, index)

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


cwrapper = CWrapper(ENKF_LIB)
cwrapper.registerType("obs_vector", ObsVector)
cwrapper.registerType("obs_vector_obj", ObsVector.createPythonObject)
cwrapper.registerType("obs_vector_ref", ObsVector.createCReference)

# 3. Installing the c-functions used to manipulate ecl_kw instances.
#    These functions are used when implementing the EclKW class, not
#    used outside this scope.

ObsVector.cNamespace().free = cwrapper.prototype("void obs_vector_free( obs_vector )")
ObsVector.cNamespace().get_state_kw = cwrapper.prototype("char* obs_vector_get_state_kw( obs_vector )")
ObsVector.cNamespace().iget_node = cwrapper.prototype("c_void_p obs_vector_iget_node( obs_vector, int)")
ObsVector.cNamespace().get_num_active = cwrapper.prototype("int obs_vector_get_num_active( obs_vector )")
ObsVector.cNamespace().iget_active = cwrapper.prototype("bool obs_vector_iget_active( obs_vector, int)")
Example #57
0
    def __len__(self):
        """ @rtype: int """
        return EnsemblePlotGenKWVector.cNamespace().size(self)

    def getValue(self, index):
        """ @rtype: float """
        return self[index]

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

    def __getitem__(self, index):
        """ @rtype: float """
        return EnsemblePlotGenKWVector.cNamespace().get_value(self, index)


cwrapper = CWrapper(ENKF_LIB)
cwrapper.registerType("ensemble_plot_gen_kw_vector", EnsemblePlotGenKWVector)
cwrapper.registerType("ensemble_plot_gen_kw_vector_obj",
                      EnsemblePlotGenKWVector.createPythonObject)
cwrapper.registerType("ensemble_plot_gen_kw_vector_ref",
                      EnsemblePlotGenKWVector.createCReference)

EnsemblePlotGenKWVector.cNamespace().size = cwrapper.prototype(
    "int enkf_plot_gen_kw_vector_get_size(ensemble_plot_gen_kw_vector)")
EnsemblePlotGenKWVector.cNamespace().get_value = cwrapper.prototype(
    "double enkf_plot_gen_kw_vector_iget(ensemble_plot_gen_kw_vector, int)")
Example #58
0
        result._initialize()
        return result

    @classmethod
    def createPythonObject(cls, c_pointer):
        result = super(EclSum, cls).createPythonObject(c_pointer)
        result._initialize()
        return result


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

# 2. Creating a wrapper object around the libecl library, 
#    registering the type map : ecl_kw <-> EclKW
cwrapper = CWrapper(ECL_LIB)
cwrapper.registerType( "ecl_sum" , EclSum )
cwrapper.registerType( "ecl_sum_obj" , EclSum.createPythonObject )
cwrapper.registerType( "ecl_sum_ref" , EclSum.createCReference )


# 3. Installing the c-functions used to manipulate ecl_kw instances.
#    These functions are used when implementing the EclKW class, not
#    used outside this scope.


EclSum.cNamespace().fread_alloc                   = cwrapper.prototype("c_void_p ecl_sum_fread_alloc_case__( char* , char* , bool)")
EclSum.cNamespace().iiget                         = cwrapper.prototype("double   ecl_sum_iget( ecl_sum , int , int)")
EclSum.cNamespace().free                          = cwrapper.prototype("void     ecl_sum_free( ecl_sum )")
EclSum.cNamespace().data_length                   = cwrapper.prototype("int      ecl_sum_get_data_length( ecl_sum )")
EclSum.cNamespace().iget_sim_days                 = cwrapper.prototype("double   ecl_sum_iget_sim_days( ecl_sum , int) ")
EclSum.cNamespace().iget_report_step              = cwrapper.prototype("int      ecl_sum_iget_report_step( ecl_sum , int) ")
Example #59
0
#  See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html> 
#  for more details.
from ert.cwrap import BaseCClass, CWrapper
from ert.enkf import ENKF_LIB


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

    def getPath(self):
        """ @rtype: str """
        return PlotConfig.cNamespace().get_path(self)

    def setPath(self, path):
        PlotConfig.cNamespace().set_path(self, path)

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


cwrapper = CWrapper(ENKF_LIB)
cwrapper.registerType("plot_config", PlotConfig)
cwrapper.registerType("plot_config_obj", PlotConfig.createPythonObject)
cwrapper.registerType("plot_config_ref", PlotConfig.createCReference)

PlotConfig.cNamespace().free = cwrapper.prototype("void plot_config_free( plot_config )")
PlotConfig.cNamespace().get_path = cwrapper.prototype("char* plot_config_get_path(plot_config)")
PlotConfig.cNamespace().set_path = cwrapper.prototype("void plot_config_set_path(plot_config, char*)")