How to use the ert.cwrap.BaseCClass function in ert

To help you get started, we’ve selected a few ert examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github OPM / ResInsight / ThirdParty / Ert / devel / python / python / ert / ecl / ecl_file.py View on Github external
implementation from the libecl library.

[1]: In particular for restart files, which do not have a special
     RestartFile class, there is some specialized functionality.
"""
import re
import types
import datetime
import ctypes
import warnings
from ert.cwrap import BaseCClass
from ert.ecl import EclPrototype, EclKW, EclFileEnum
from ert.util import CTime


class EclFile(BaseCClass):
    TYPE_NAME = "ecl_file"
    _open                        = EclPrototype("void*       ecl_file_open( char* , int )" , bind = False)
    _new                         = EclPrototype("void*       ecl_file_alloc_empty(  )" , bind = False)
    _get_file_type               = EclPrototype("ecl_file_enum ecl_util_get_file_type( char* , bool* , int*)" , bind = False)
    _writable                    = EclPrototype("bool        ecl_file_writable( ecl_file )")
    _save_kw                     = EclPrototype("void        ecl_file_save_kw( ecl_file , ecl_kw )")
    _select_block                = EclPrototype("bool        ecl_file_select_block( ecl_file , char* , int )")
    _restart_block_time          = EclPrototype("bool        ecl_file_select_rstblock_sim_time( ecl_file , time_t )")
    _restart_block_step          = EclPrototype("bool        ecl_file_select_rstblock_report_step( ecl_file , int )")
    _restart_block_iselect       = EclPrototype("bool        ecl_file_iselect_rstblock( ecl_file , int )")
    _select_global               = EclPrototype("void        ecl_file_select_global( ecl_file )")
    _iget_kw                     = EclPrototype("ecl_kw_ref    ecl_file_iget_kw( ecl_file , int)")
    _iget_named_kw               = EclPrototype("ecl_kw_ref    ecl_file_iget_named_kw( ecl_file , char* , int)")
    _close                       = EclPrototype("void        ecl_file_close( ecl_file )")
    _get_size                    = EclPrototype("int         ecl_file_get_size( ecl_file )")
    _get_unique_size             = EclPrototype("int         ecl_file_get_num_distinct_kw( ecl_file )")
github Ensembles / ert / devel / python / python / ert / ecl / ecl_subsidence.py View on Github external
#   
#  See the GNU General Public License at  
#  for more details. 
"""
Calculate dynamic change in gravitational strength.

The ecl_subsidence module contains functionality to load time-lapse ECLIPSE
results and calculate the change in seafloor subsidence between the
different surveys. The implementation is a thin wrapper around the
ecl_subsidence.c implementation in the libecl library.
"""
from ert.cwrap import BaseCClass
from ert.ecl import EclPrototype


class EclSubsidence(BaseCClass):
    """
    Holding ECLIPSE results for calculating subsidence changes.
    
    The EclSubsidence class is a collection class holding the results from
    ECLIPSE forward modelling of subsidence surveys. Observe that the
    class is focused on the ECLIPSE side of things, and does not have
    any notion of observed values or measurement locations; that
    should be handled by the scope using the EclSubsidence class.

    Typical use of the EclSubsidence class involves the following steps:

      1. Create the EclSubsidence instance.
      2. Add surveys with the add_survey_XXXX() methods.
      3. Evalute the subsidence response with the eval() method.
    """
    TYPE_NAME = "ecl_subsidence"
github OPM / ResInsight / ThirdParty / Ert / devel / python / python / ert / enkf / enkf_main.py View on Github external
#   
#  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  
#  for more details.
from ert.cwrap import BaseCClass, CWrapper

from ert.enkf import AnalysisConfig, EclConfig, EnkfObs, EnKFState, LocalConfig, ModelConfig, EnsembleConfig, PlotConfig, SiteConfig, ENKF_LIB, EnkfSimulationRunner, EnkfFsManager, ErtWorkflowList, PostSimulationHook
from ert.enkf.enums import EnkfInitModeEnum
from ert.enkf.key_manager import KeyManager
from ert.util import SubstitutionList, Log


class EnKFMain(BaseCClass):
    def __init__(self, model_config, strict=True):
        c_ptr = EnKFMain.cNamespace().bootstrap(model_config, strict, False)
        super(EnKFMain, self).__init__(c_ptr)

        # The model_config argument can be None; the only reason to
        # allow that possibility is to be able to test that the
        # site-config loads correctly.
        if model_config is None:
            self.__simulation_runner = None
            self.__fs_manager = None
        else:
            self.__simulation_runner = EnkfSimulationRunner(self)
            self.__fs_manager = EnkfFsManager(self)
            

        self.__key_manager = KeyManager(self)
github OPM / ResInsight / ThirdParty / Ert / devel / python / python / ert / config / config_parser.py View on Github external
def iset_type( self, index, schema_type ):
        """
        @type schema_type: ContentTypeEnum
        """
        assert isinstance(schema_type, ContentTypeEnum)
        self._iset_type(index, schema_type)

    def set_argc_minmax(self, minimum, maximum):
        self._set_argc_minmax(minimum, maximum)

    def free(self):
        self._free()


class ConfigParser(BaseCClass):
    TYPE_NAME = "config_parser"

    _alloc = ConfigPrototype("void* config_alloc( )", bind=False)
    _add = ConfigPrototype("schema_item_ref config_add_schema_item( config_parser , char* , bool)")
    _free = ConfigPrototype("void config_free( config_parser )")
    _parse = ConfigPrototype("config_content_obj config_parse( config_parser , char* , char* , char* , char* , hash , config_unrecognized_enum , bool )")
    _get_schema_item = ConfigPrototype("schema_item_ref config_get_schema_item( config_parser , char*)")
    _has_schema_item = ConfigPrototype("bool config_has_schema_item( config_parser , char*)")

    def __init__(self):
        c_ptr = self._alloc()
        super(ConfigParser, self).__init__(c_ptr)

    
    def __contains__(self , keyword):
        return self._has_schema_item( keyword )
github Ensembles / ert / devel / python / python / ert / job_queue / workflow_joblist.py View on Github external
import os
from ert.cwrap import BaseCClass
from ert.job_queue import QueuePrototype, WorkflowJob


class WorkflowJoblist(BaseCClass):
    TYPE_NAME = "workflow_joblist"
    _alloc              = QueuePrototype("void*            workflow_joblist_alloc()" , bind = False)
    _free               = QueuePrototype("void             workflow_joblist_free(workflow_joblist)")
    _add_job            = QueuePrototype("void             workflow_joblist_add_job(workflow_joblist, workflow_job)")
    _add_job_from_file  = QueuePrototype("bool             workflow_joblist_add_job_from_file(workflow_joblist, char*, char*)")
    _has_job            = QueuePrototype("bool             workflow_joblist_has_job(workflow_joblist, char*)")
    _get_job            = QueuePrototype("workflow_job_ref workflow_joblist_get_job(workflow_joblist, char*)")
    _count              = QueuePrototype("workflow_job_ref workflow_joblist_get_job(workflow_joblist, char*)")

    def __init__(self):
        c_ptr = self._alloc( )
        super(WorkflowJoblist, self).__init__(c_ptr)


    def addJob(self, job):
        """ @type job: WorkflowJob """
github OPM / ResInsight / ThirdParty / Ert / devel / python / python / ert / ecl / ecl_region.py View on Github external
region.select_jslice(0 , 5)     # Selects all cells with j:[0:5] AND i:[0:5]
    """

    def select_wrapper(self , *args ,  **kwargs):
        intersect = kwargs.has_key('intersect') and kwargs['intersect']
        if intersect:
            new_region = EclRegion( self.grid , False )
            select(new_region , *args )

            self &= new_region
        else:
            select(self , *args )

    return select_wrapper

class EclRegion(BaseCClass):
    TYPE_NAME = "ecl_region"
    _alloc                      = EclPrototype("void* ecl_region_alloc( ecl_grid , bool )", bind = False)
    _alloc_copy                 = EclPrototype("ecl_region_obj ecl_region_alloc_copy( ecl_region )")

    _set_kw_int                 = EclPrototype("void ecl_region_set_kw_int( ecl_region , ecl_kw , int, bool) ")
    _set_kw_float               = EclPrototype("void ecl_region_set_kw_float( ecl_region , ecl_kw , float, bool ) ")
    _set_kw_double              = EclPrototype("void ecl_region_set_kw_double( ecl_region , ecl_kw , double , bool) ")
    _shift_kw_int               = EclPrototype("void ecl_region_shift_kw_int( ecl_region , ecl_kw , int, bool) ")
    _shift_kw_float             = EclPrototype("void ecl_region_shift_kw_float( ecl_region , ecl_kw , float, bool ) ")
    _shift_kw_double            = EclPrototype("void ecl_region_shift_kw_double( ecl_region , ecl_kw , double , bool) ")
    _scale_kw_int               = EclPrototype("void ecl_region_scale_kw_int( ecl_region , ecl_kw , int, bool) ")
    _scale_kw_float             = EclPrototype("void ecl_region_scale_kw_float( ecl_region , ecl_kw , float, bool ) ")
    _scale_kw_double            = EclPrototype("void ecl_region_scale_kw_double( ecl_region , ecl_kw , double , bool) ")

    _free                       = EclPrototype("void ecl_region_free( ecl_region )")     
    _reset                      = EclPrototype("void ecl_region_reset( ecl_region )")
github Ensembles / ert / devel / python / python / ert / util / cthread_pool.py View on Github external
def addTask(self, cfunc, arg):
        """
        The function should come from CThreadPool.lookupCFunction().
        """
        if isinstance(arg, BaseCClass):
            arg_ptr = BaseCClass.from_param(arg)
        else:
            arg_ptr = arg

        self.arg_list.append(arg)
        self._add_job(cfunc, arg_ptr)
github OPM / ResInsight / ThirdParty / Ert / devel / python / python / ert / enkf / enkf_fs.py View on Github external
#  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  
#  for more details.
from ert.cwrap import BaseCClass, CWrapper
from ert.enkf import ENKF_LIB, TimeMap, StateMap, SummaryKeySet
from ert.enkf.enums import EnKFFSType


class EnkfFs(BaseCClass):
    def __init__(self, mount_point):
        c_ptr = EnkfFs.cNamespace().mount(mount_point)
        super(EnkfFs, self).__init__(c_ptr)

        self.__umounted = False # Keep track of umounting so we only do it once


    @classmethod
    def createCReference(cls, c_pointer, parent=None):
        obj = super(EnkfFs, cls).createCReference(c_pointer, parent)
        if not obj is None:
            obj.__umounted = False
        return obj


    # def has_node(self, node_key, var_type, report_step, iens, state):
github Ensembles / ert / devel / python / python / ert / enkf / ert_workflow_list_handler.py View on Github external
from ert.cwrap import BaseCClass, CWrapper
from ert.enkf import ENKF_LIB



class ErtWorkflowListHandler(BaseCClass):
    def __init__(self, workflow_list, workflow_name, enkf_main_pointer):
        pointer = ErtWorkflowListHandler.cNamespace().alloc()
        super(ErtWorkflowListHandler, self).__init__(pointer)

        self.__workflow_list = workflow_list
        self.__workflow_name = workflow_name
        self.__enkf_main_pointer = enkf_main_pointer

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

    def getWorkflowResult(self):
        return ErtWorkflowListHandler.cNamespace().read_result(self)

    def runWorkflow(self):
        ErtWorkflowListHandler.cNamespace().run_workflow(self, self.__workflow_list, self.__workflow_name, self.__enkf_main_pointer)
github OPM / ResInsight / ThirdParty / Ert / devel / python / python / ert / enkf / ecl_config.py View on Github external
#   
#  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  
#  for more details.
from ert.cwrap import BaseCClass, CWrapper
from ert.enkf import ENKF_LIB
from ert.util import StringList
from ert.ecl import EclSum
from ert.ecl import EclGrid
from ert.util import UIReturn


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

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

    def getEclBase(self):
        return EclConfig.cNamespace().get_eclbase(self)

    def validateEclBase(self , eclbase_fmt):
        return EclConfig.cNamespace().validate_eclbase(self , eclbase_fmt)

    # Warning: You should probably use the EnkFMain.setEclBase() method to update the Eclipse basename format