Beispiel #1
0
    def __init__(self, ert, function_name, argument_types, argument_count):
        super(FunctionErtScript, self).__init__(ert)

        lib = clib.ert_load(None)
        wrapper = CWrapper(lib)

        parsed_argument_types = []

        if ert is not None:
            self.__function = wrapper.prototype("c_void_p %s(c_void_p, stringlist)" % function_name)

        else:
            for arg in argument_types:
                if arg is bool:
                    parsed_argument_types.append("bool")
                elif arg is str:
                    parsed_argument_types.append("char*")
                elif arg is int:
                    parsed_argument_types.append("int")
                elif arg is float:
                    parsed_argument_types.append("float")
                else:
                    raise TypeError("Unknown type: %s" % arg)

            self.__function = wrapper.prototype("c_void_p %s(%s)" % (function_name, ", ".join(parsed_argument_types[:argument_count])))
Beispiel #2
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)
Beispiel #3
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)
Beispiel #4
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)
Beispiel #5
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)
Beispiel #6
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)
Beispiel #7
0
        return EclConfig.cNamespace().get_static_kw_list(self).setParent(self)

    def clear_static_kw(self):
        EclConfig.cNamespace().clear_static_kw(self)

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


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*)")

EclConfig.cNamespace().get_data_file = cwrapper.prototype("char* ecl_config_get_data_file(ecl_config)")
EclConfig.cNamespace().set_data_file = cwrapper.prototype("void ecl_config_set_data_file(ecl_config , char*)")
EclConfig.cNamespace().validate_data_file = cwrapper.prototype("ui_return_obj ecl_config_validate_data_file(ecl_config , char*)")

EclConfig.cNamespace().get_gridfile = cwrapper.prototype("char* ecl_config_get_gridfile(ecl_config)")
EclConfig.cNamespace().set_gridfile = cwrapper.prototype("void ecl_config_set_grid(ecl_config, char*)")
EclConfig.cNamespace().validate_gridfile = cwrapper.prototype("ui_return_obj ecl_config_validate_grid(ecl_config, char*)")
EclConfig.cNamespace().get_grid = cwrapper.prototype("c_void_p ecl_config_get_grid(ecl_config)")  #todo: fix return type!!!
Beispiel #8
0
    #################################################################

# 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) ")
EclSum.cNamespace().iget_mini_step                = cwrapper.prototype("int      ecl_sum_iget_mini_step( ecl_sum , int) ")
EclSum.cNamespace().iget_sim_time                 = cwrapper.prototype("time_t   ecl_sum_iget_sim_time( ecl_sum , int) ")
EclSum.cNamespace().get_report_end                = cwrapper.prototype("int      ecl_sum_iget_report_end( ecl_sum , int)")
EclSum.cNamespace().get_general_var               = cwrapper.prototype("double   ecl_sum_get_general_var( ecl_sum , int , char*)")
EclSum.cNamespace().get_general_var_index         = cwrapper.prototype("int      ecl_sum_get_general_var_params_index( ecl_sum , char*)")
EclSum.cNamespace().get_general_var_from_sim_days = cwrapper.prototype("double   ecl_sum_get_general_var_from_sim_days( ecl_sum , double , char*)")
EclSum.cNamespace().get_general_var_from_sim_time = cwrapper.prototype("double   ecl_sum_get_general_var_from_sim_time( ecl_sum , time_t , char*)")
EclSum.cNamespace().get_first_gt                  = cwrapper.prototype("int      ecl_sum_get_first_gt( ecl_sum , int , double )")
EclSum.cNamespace().get_first_lt                  = cwrapper.prototype("int      ecl_sum_get_first_lt( ecl_sum , int , double )")
EclSum.cNamespace().get_start_date                = cwrapper.prototype("time_t   ecl_sum_get_start_time( ecl_sum )")
Beispiel #9
0
        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 )")
cfunc.in_coarse_group1             = cwrapper.prototype("bool ecl_grid_cell_in_coarse_group1( ecl_grid , int)")

cfunc.exists                       = cwrapper.prototype("bool ecl_grid_exists( char* )")
cfunc.free                         = cwrapper.prototype("void ecl_grid_free( ecl_grid )")     
cfunc.get_nx                       = cwrapper.prototype("int ecl_grid_get_nx( ecl_grid )")
cfunc.get_ny                       = cwrapper.prototype("int ecl_grid_get_ny( ecl_grid )")
cfunc.get_nz                       = cwrapper.prototype("int ecl_grid_get_nz( ecl_grid )")
cfunc.get_global_size              = cwrapper.prototype("int ecl_grid_get_global_size( ecl_grid )")
cfunc.get_active                   = cwrapper.prototype("int ecl_grid_get_active_size( ecl_grid )")
Beispiel #10
0

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

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

# 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_kw")

cfunc.load_grdecl = cwrapper.prototype(
    "c_void_p ecl_kw_fscanf_alloc_grdecl_dynamic__( FILE , char* , bool , int )"
)
cfunc.fseek_grdecl = cwrapper.prototype(
    "bool     ecl_kw_grdecl_fseek_kw(char* , bool , FILE )")
cfunc.fprintf_grdecl = cwrapper.prototype(
    "void     ecl_kw_fprintf_grdecl( ecl_kw , FILE )")
cfunc.fprintf_data = cwrapper.prototype(
    "void     ecl_kw_fprintf_data( ecl_kw , char* , FILE )")

cfunc.alloc_new = cwrapper.prototype(
    "c_void_p ecl_kw_alloc( char* , int , ecl_type_enum )")
cfunc.copyc = cwrapper.prototype("c_void_p ecl_kw_alloc_copy( ecl_kw )")
cfunc.sub_copy = cwrapper.prototype(
    "c_void_p ecl_kw_alloc_sub_copy( ecl_kw , char*, int , int)")
cfunc.slice_copyc = cwrapper.prototype(
    "c_void_p ecl_kw_alloc_slice_copy( ecl_kw , int , int , int )")
Beispiel #11
0
    def get_ny(self):
        return FieldConfig.cNamespace().get_ny(self)

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

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

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


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

FieldConfig.cNamespace().alloc = cwrapper.prototype("c_void_p field_config_alloc_empty(char* , ecl_grid , c_void_p , bool)")  
FieldConfig.cNamespace().free = cwrapper.prototype("void field_config_free( field_config )")
FieldConfig.cNamespace().get_type = cwrapper.prototype("int field_config_get_type(field_config)")
FieldConfig.cNamespace().get_truncation_mode = cwrapper.prototype("int field_config_get_truncation_mode(field_config)")
FieldConfig.cNamespace().get_truncation_min = cwrapper.prototype("double field_config_get_truncation_min(field_config)")
FieldConfig.cNamespace().get_truncation_max = cwrapper.prototype("double field_config_get_truncation_max(field_config)")
FieldConfig.cNamespace().get_init_transform_name = cwrapper.prototype("char* field_config_get_init_transform_name(field_config)")
FieldConfig.cNamespace().get_output_transform_name = cwrapper.prototype("char* field_config_get_output_transform_name(field_config)")
FieldConfig.cNamespace().ijk_active = cwrapper.prototype("bool field_config_ijk_active(field_config, int, int, int)")
FieldConfig.cNamespace().get_nx = cwrapper.prototype("int field_config_get_nx(field_config)")
FieldConfig.cNamespace().get_ny = cwrapper.prototype("int field_config_get_ny(field_config)")
FieldConfig.cNamespace().get_nz = cwrapper.prototype("int field_config_get_nz(field_config)")
FieldConfig.cNamespace().get_grid = cwrapper.prototype("c_void_p field_config_get_grid(field_config)")  #todo: fix return type

Beispiel #12
0
    def cellsEqual(self, value):
        """
        Will return a list [(i1,j1),(i2,j2) , ...(in,jn)] of all cells with value @value.
        """
        i_list = IntVector()
        j_list = IntVector()
        Layer.cNamespace().cells_equal(self, value, i_list, j_list)
        ij_list = []
        for (i, j) in zip(i_list, j_list):
            ij_list.append((i, j))
        return ij_list


cwrapper = CWrapper(ECL_LIB)
CWrapper.registerObjectType("layer", Layer)
Layer.cNamespace().alloc = cwrapper.prototype(
    "c_void_p  layer_alloc(int,  int)")
Layer.cNamespace().copy = cwrapper.prototype(
    "void      layer_memcpy(layer , layer)")
Layer.cNamespace().free = cwrapper.prototype("void      layer_free(layer)")
Layer.cNamespace().get_nx = cwrapper.prototype("int       layer_get_nx(layer)")
Layer.cNamespace().get_ny = cwrapper.prototype("int       layer_get_ny(layer)")
Layer.cNamespace().set_cell = cwrapper.prototype(
    "void      layer_iset_cell_value(layer , int , int , int)")
Layer.cNamespace().get_cell = cwrapper.prototype(
    "int       layer_iget_cell_value(layer , int , int )")
Layer.cNamespace().get_bottom_barrier = cwrapper.prototype(
    "bool layer_iget_bottom_barrier(layer , int , int )")
Layer.cNamespace().get_left_barrier = cwrapper.prototype(
    "bool layer_iget_left_barrier(layer , int , int )")
Layer.cNamespace().cell_contact = cwrapper.prototype(
    "bool      layer_cell_contact(layer , int , int , int , int)")
Beispiel #13
0
        item = self[key]
        return item.getValue(item_index, node_index)

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

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


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

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

ContentItem.cNamespace().size = cwrapper.prototype(
    "int config_content_item_get_size( content_item )")
ContentItem.cNamespace().iget_content_node = cwrapper.prototype(
    "content_node_ref config_content_item_iget_node( content_item , int)")

ContentNode.cNamespace().iget = cwrapper.prototype(
    "char* config_content_node_iget( content_node , int)")
ContentNode.cNamespace().size = cwrapper.prototype(
Beispiel #14
0
            self,
            fs,
            iactive,
            init_mode=EnkfInitModeEnum.INIT_CONDITIONAL,
            iteration=0):
        return EnKFMain.cNamespace().alloc_run_context_ENSEMBLE_EXPERIMENT(
            self, fs, iactive, init_mode, iteration)


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

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)")
Beispiel #15
0
    def free(self):
        GenData.cNamespace().free(self)

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

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


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

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

GenData.cNamespace().export = cwrapper.prototype(
    "void gen_data_export(gen_data , char*, gen_data_file_format_type, fortio)"
)
GenData.cNamespace().export_data = cwrapper.prototype(
    "void gen_data_export_data(gen_data , double_vector)")
Beispiel #16
0
            bool_vector[index] = True

        return bool_vector

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


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


BoolVector.cNamespace().alloc               = cwrapper.prototype("c_void_p   bool_vector_alloc( int , bool )")
BoolVector.cNamespace().alloc_copy          = cwrapper.prototype("bool_vector_obj bool_vector_alloc_copy( bool_vector )")
BoolVector.cNamespace().strided_copy        = cwrapper.prototype("bool_vector_obj bool_vector_alloc_strided_copy( bool_vector , int , int , int)")
BoolVector.cNamespace().free                = cwrapper.prototype("void   bool_vector_free( bool_vector )")
BoolVector.cNamespace().iget                = cwrapper.prototype("bool   bool_vector_iget( bool_vector , int )")
BoolVector.cNamespace().safe_iget           = cwrapper.prototype("bool   bool_vector_safe_iget( bool_vector , int )")
BoolVector.cNamespace().iset                = cwrapper.prototype("void   bool_vector_iset( bool_vector , int , bool)")
BoolVector.cNamespace().size                = cwrapper.prototype("int    bool_vector_size( bool_vector )")
BoolVector.cNamespace().append              = cwrapper.prototype("void   bool_vector_append( bool_vector , bool )")
BoolVector.cNamespace().idel_block          = cwrapper.prototype("void   bool_vector_idel_block( bool_vector , bool , bool )")
BoolVector.cNamespace().idel                = cwrapper.prototype("void   bool_vector_idel( bool_vector , int )")
BoolVector.cNamespace().pop                 = cwrapper.prototype("bool   bool_vector_pop( bool_vector )")
BoolVector.cNamespace().lshift              = cwrapper.prototype("void   bool_vector_lshift( bool_vector , int )")
BoolVector.cNamespace().rshift              = cwrapper.prototype("void   bool_vector_rshift( bool_vector , int )")
BoolVector.cNamespace().insert              = cwrapper.prototype("void   bool_vector_insert( bool_vector , int , bool)")
BoolVector.cNamespace().fprintf             = cwrapper.prototype("void   bool_vector_fprintf( bool_vector , FILE , char* , char*)")
Beispiel #17
0
#  See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
#  for more details.
"""
Create a polygon
"""
from ert.cwrap import CClass, CWrapper, CWrapperNameSpace
from ert.geo import ERT_GEOMETRY_LIB


class GeoPolygon(CClass):
    def __init__(self, points):
        c_ptr = cfunc.alloc_new()
        self.init_cobj(c_ptr, cfunc.free)
        for (xc, yc) in points:
            self.add_point(xc, yc)

    def add_point(self, xc, yc):
        cfunc.add_point(self, xc, yc)


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

cwrapper = CWrapper(ERT_GEOMETRY_LIB)
cwrapper.registerType("geo_polygon", GeoPolygon)

cfunc = CWrapperNameSpace("geo_polygon")
cfunc.alloc_new = cwrapper.prototype("c_void_p geo_polygon_alloc( )")
cfunc.add_point = cwrapper.prototype(
    "void     geo_polygon_add_point( geo_polygon , double , double )")
cfunc.free = cwrapper.prototype("void     geo_polygon_free( geo_polygon )")
Beispiel #18
0
from ert.cwrap import CWrapper
from ert.util import UTIL_LIB, VectorTemplate


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

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


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

DoubleVector.cNamespace().alloc = cwrapper.prototype(
    "c_void_p   double_vector_alloc( int , double )")
DoubleVector.cNamespace().alloc_copy = cwrapper.prototype(
    "double_vector_obj   double_vector_alloc_copy( double_vector )")
DoubleVector.cNamespace().strided_copy = cwrapper.prototype(
    "double_vector_obj   double_vector_alloc_strided_copy( double_vector , int , int , int)"
)
DoubleVector.cNamespace().free = cwrapper.prototype(
    "void   double_vector_free( double_vector )")
DoubleVector.cNamespace().iget = cwrapper.prototype(
    "double double_vector_iget( double_vector , int )")
DoubleVector.cNamespace().safe_iget = cwrapper.prototype(
    "double double_vector_safe_iget(double_vector , int )")
DoubleVector.cNamespace().iset = cwrapper.prototype(
    "double double_vector_iset( double_vector , int , double)")
DoubleVector.cNamespace().size = cwrapper.prototype(
    "int    double_vector_size( double_vector )")
Beispiel #19
0
    def isRunning(self):
        return JobQueueManager.cNamespace().is_running(self)

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

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


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

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

JobQueueManager.cNamespace().alloc = cwrapper.prototype(
    "c_void_p job_queue_manager_alloc( job_queue) ")
JobQueueManager.cNamespace().free = cwrapper.prototype(
    "void job_queue_manager_free( job_queue_manager )")
JobQueueManager.cNamespace().start_queue = cwrapper.prototype(
    "void job_queue_manager_start_queue( job_queue_manager , int , bool)")
JobQueueManager.cNamespace().get_num_running = cwrapper.prototype(
    "int job_queue_manager_get_num_running( job_queue_manager )")
JobQueueManager.cNamespace().get_num_complete = cwrapper.prototype(
    "int job_queue_manager_get_num_complete( job_queue_manager )")
JobQueueManager.cNamespace().is_running = cwrapper.prototype(
    "bool job_queue_manager_is_running( job_queue_manager )")
JobQueueManager.cNamespace().job_complete = cwrapper.prototype(
    "bool job_queue_manager_job_complete( job_queue_manager , int)")
Beispiel #20
0
from ert.cwrap import BaseCClass, CWrapper
from ert.enkf import ENKF_LIB


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

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

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

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


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

ActiveList.cNamespace().alloc = cwrapper.prototype(
    "c_void_p active_list_alloc()")
ActiveList.cNamespace().free = cwrapper.prototype(
    "void     active_list_free(active_list)")
ActiveList.cNamespace().get_mode = cwrapper.prototype(
    "active_mode_enum active_list_get_mode(active_list)")
ActiveList.cNamespace().add_index = cwrapper.prototype(
    "void active_list_add_index(active_list , int)")
Beispiel #21
0
                             value.__class__)

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


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

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

Hash.cNamespace().get = cwrapper.prototype("c_void_p hash_get(hash, char*)")
IntegerHash.cNamespace().get_int = cwrapper.prototype(
    "int hash_get_int(hash, char*)")
DoubleHash.cNamespace().get_double = cwrapper.prototype(
    "double hash_get_double(hash, char*)")
StringHash.cNamespace().get_string = cwrapper.prototype(
    "char* hash_get_string(hash, char*)")
Beispiel #22
0
    def __ne__(self, other):
        return not self == other

    def free(self):
        pass

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


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

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

WellConnection.cNamespace().segment_id = cwrapper.prototype(
    "int well_conn_get_segment_id(well_connection)")
WellConnection.cNamespace().is_open = cwrapper.prototype(
    "bool well_conn_open(well_connection)")
WellConnection.cNamespace().is_msw = cwrapper.prototype(
    "bool well_conn_MSW(well_connection)")
WellConnection.cNamespace().fracture_connection = cwrapper.prototype(
    "bool well_conn_fracture_connection(well_connection)")
Beispiel #23
0
            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 )")
cfunc_rft.get_date                  = cwrapper.prototype("time_t ecl_rft_node_get_date( ecl_rft )")
cfunc_rft.get_size                  = cwrapper.prototype("int ecl_rft_node_get_size( ecl_rft )")
cfunc_rft.iget_cell                 = cwrapper.prototype("c_void_p ecl_rft_node_iget_cell( ecl_rft )")
cfunc_rft.iget_cell_sorted          = cwrapper.prototype("c_void_p ecl_rft_node_iget_cell_sorted( ecl_rft )")
cfunc_rft.sort_cells                = cwrapper.prototype("c_void_p ecl_rft_node_inplace_sort_cells( ecl_rft )")
cfunc_rft.iget_depth                = cwrapper.prototype("double ecl_rft_node_iget_depth( ecl_rft )")
    def runPostWorkflow(self):
        post_simulation_hook = self.ert.getPostSimulationHook()
        if post_simulation_hook.hasWorkflow():
            post_simulation_hook.checkRunpathListFile()
            workflow = post_simulation_hook.getWorkflow()
            workflow_list = self.ert.getWorkflowList()
            workflow.run(self.ert, context=workflow_list.getContext())

    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)")
Beispiel #25
0
from ert.cwrap import clib, CWrapper
from ert.enkf.data import EnkfNode
from ert.enkf.config import GenDataConfig
from ert.enkf import NodeId
from ert.enkf import ForwardLoadContext
from ert.test import ErtTestContext, ExtendedTestCase
from ert.util import BoolVector

test_lib  = clib.ert_load("libenkf")
cwrapper =  CWrapper(test_lib)

get_active_mask = cwrapper.prototype("bool_vector_ref gen_data_config_get_active_mask( gen_data_config )")
update_active_mask = cwrapper.prototype("void gen_data_config_update_active( gen_data_config, forward_load_context , bool_vector)")

alloc_run_arg = cwrapper.prototype("run_arg_obj run_arg_alloc_ENSEMBLE_EXPERIMENT( enkf_fs , int , int , char*) ")


def updateMask(gen_data_config , report_step , fs, active_mask):
    run_arg = alloc_run_arg( fs , 0 , 0 , "Path")
    load_context = ForwardLoadContext( run_arg = run_arg , report_step = report_step )
    update_active_mask( gen_data_config , load_context , active_mask )

    

class GenDataConfigTest(ExtendedTestCase):
    def setUp(self):
        self.config_file = self.createTestPath("Statoil/config/with_GEN_DATA/config")

    def load_active_masks(self, case1, case2 ):
        with ErtTestContext("gen_data_config_test", self.config_file) as test_context:
            ert = test_context.getErt()
Beispiel #26
0
    def getNumRetries(self):
        """ @rtype: int """
        return AnalysisIterConfig.cNamespace().get_num_retries(self)

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

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

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

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

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


AnalysisIterConfig.cNamespace().alloc = cwrapper.prototype("c_void_p analysis_iter_config_alloc( )")
AnalysisIterConfig.cNamespace().free = cwrapper.prototype("void analysis_iter_config_free( analysis_iter_config )")
AnalysisIterConfig.cNamespace().set_num_iterations = cwrapper.prototype("void analysis_iter_config_set_num_iterations(analysis_iter_config, int)")
AnalysisIterConfig.cNamespace().get_num_iterations = cwrapper.prototype("int analysis_iter_config_get_num_iterations(analysis_iter_config)")
AnalysisIterConfig.cNamespace().get_num_retries = cwrapper.prototype("int analysis_iter_config_get_num_retries_per_iteration(analysis_iter_config)")
AnalysisIterConfig.cNamespace().num_iterations_set = cwrapper.prototype("bool analysis_iter_config_num_iterations_set(analysis_iter_config)")
AnalysisIterConfig.cNamespace().set_case_fmt = cwrapper.prototype("void analysis_iter_config_set_case_fmt( analysis_iter_config , char* )")
AnalysisIterConfig.cNamespace().get_case_fmt = cwrapper.prototype("char* analysis_iter_config_get_case_fmt( analysis_iter_config)")
AnalysisIterConfig.cNamespace().case_fmt_set = cwrapper.prototype("bool analysis_iter_config_case_fmt_set(analysis_iter_config)")
Beispiel #27
0
from ert.cwrap import CWrapper, CFILE, BaseCClass
from ert.util import UTIL_LIB


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

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


CWrapper.registerObjectType("permutation_vector", PermutationVector)

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


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

        Mainly a support function to support slice based lookup like

           v = IntVector()
           v[0] = 1
           v[1] = 1
           v[100] = 100
Beispiel #28
0
    ECL_FILE_CLOSE_STREAM = None
    ECL_FILE_WRITABLE = None

EclFileFlagEnum.addEnum("ECL_FILE_CLOSE_STREAM" , 1 )
EclFileFlagEnum.addEnum("ECL_FILE_WRITABLE" , 2 )


EclFileFlagEnum.registerEnum(ECL_LIB, "ecl_file_flag_enum")


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

cwrapper = CWrapper(ECL_LIB)
cfunc = CWrapperNameSpace("ecl_util")

cfunc.get_num_cpu = cwrapper.prototype("int ecl_util_get_num_cpu( char* )")
cfunc.get_file_type = cwrapper.prototype("ecl_file_enum ecl_util_get_file_type( char* , bool* , int*)")
cfunc.get_type_name = cwrapper.prototype("char* ecl_util_get_type_name( int )")
cfunc.get_start_date = cwrapper.prototype("time_t ecl_util_get_start_date( char* )")



class EclUtil(object):
    @staticmethod
    def get_num_cpu( datafile ):
        """
        Parse ECLIPSE datafile and determine how many CPUs are needed.

        Will look for the "PARALLELL" keyword, and then read off the
        number of CPUs required. Will return one if no PARALLELL keyword
        is found.
Beispiel #29
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 )")
Beispiel #30
0
        p2 = GeometryTools.nearestPointOnPolyline( end2 , target )
            
        d1 = GeometryTools.distance( p1 , end1 )
        d2 = GeometryTools.distance( p2 , end2 )

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




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

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

CPolyline.cNamespace().alloc_new          = cwrapper.prototype("c_void_p        geo_polygon_alloc( char* )")
CPolyline.cNamespace().fread_alloc_irap   = cwrapper.prototype("geo_polygon_obj geo_polygon_fload_alloc_irap( char* )")
CPolyline.cNamespace().add_point          = cwrapper.prototype("void     geo_polygon_add_point( geo_polygon , double , double )")
CPolyline.cNamespace().add_point_front    = cwrapper.prototype("void     geo_polygon_add_point_front( geo_polygon , double , double )")
CPolyline.cNamespace().free               = cwrapper.prototype("void     geo_polygon_free( geo_polygon )")
CPolyline.cNamespace().size               = cwrapper.prototype("int      geo_polygon_get_size( geo_polygon )")
CPolyline.cNamespace().iget_xy            = cwrapper.prototype("void     geo_polygon_iget_xy( geo_polygon , int , double* , double* )")
CPolyline.cNamespace().segment_intersects = cwrapper.prototype("bool     geo_polygon_segment_intersects( geo_polygon , double , double, double , double)")
CPolyline.cNamespace().get_name           = cwrapper.prototype("char*    geo_polygon_get_name( geo_polygon  )")
CPolyline.cNamespace().set_name           = cwrapper.prototype("void     geo_polygon_set_name( geo_polygon , char*  )")
CPolyline.cNamespace().segment_length     = cwrapper.prototype("double   geo_polygon_get_length( geo_polygon)")
CPolyline.cNamespace().equal              = cwrapper.prototype("bool     geo_polygon_equal( geo_polygon , geo_polygon )")
Beispiel #31
0
        @type basename: int
        """
        RunpathList.cNamespace().add(self, realization_number,
                                     iteration_number, runpath, basename)

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

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


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

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

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

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

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

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

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

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

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

EnKFMain.cNamespace().get_ensemble_size = cwrapper.prototype("int enkf_main_get_ensemble_size( enkf_main )")
EnKFMain.cNamespace().get_ens_config = cwrapper.prototype("ens_config_ref enkf_main_get_ensemble_config( enkf_main )")
EnKFMain.cNamespace().get_model_config = cwrapper.prototype("model_config_ref enkf_main_get_model_config( enkf_main )")
EnKFMain.cNamespace().get_local_config = cwrapper.prototype("local_config_ref enkf_main_get_local_config( enkf_main )")
EnKFMain.cNamespace().get_analysis_config = cwrapper.prototype("analysis_config_ref enkf_main_get_analysis_config( enkf_main)")
EnKFMain.cNamespace().get_site_config = cwrapper.prototype("site_config_ref enkf_main_get_site_config( enkf_main)")
EnKFMain.cNamespace().get_ecl_config = cwrapper.prototype("ecl_config_ref enkf_main_get_ecl_config( enkf_main)")
EnKFMain.cNamespace().get_plot_config = cwrapper.prototype("plot_config_ref enkf_main_get_plot_config( enkf_main)")
EnKFMain.cNamespace().set_eclbase = cwrapper.prototype("ui_return_obj enkf_main_set_eclbase( enkf_main, char*)")
EnKFMain.cNamespace().set_datafile = cwrapper.prototype("void enkf_main_set_data_file( enkf_main, char*)")
EnKFMain.cNamespace().get_schedule_prediction_file = cwrapper.prototype("char* enkf_main_get_schedule_prediction_file( enkf_main )")
EnKFMain.cNamespace().set_schedule_prediction_file = cwrapper.prototype("void enkf_main_set_schedule_prediction_file( enkf_main , char*)")
Beispiel #33
0
    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)")






Beispiel #34
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*)")
Beispiel #35
0
    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)")
ModelConfig.cNamespace().select_runpath = cwrapper.prototype("bool model_config_select_runpath(model_config, char*)")

ModelConfig.cNamespace().get_history = cwrapper.prototype("history_ref model_config_get_history(model_config)")
ModelConfig.cNamespace().get_history_source = cwrapper.prototype("history_source_enum model_config_get_history_source(model_config)")
ModelConfig.cNamespace().select_history = cwrapper.prototype("bool model_config_select_history(model_config, history_source_enum, sched_file, ecl_sum)")
ModelConfig.cNamespace().has_history = cwrapper.prototype("bool model_config_has_history(model_config)")

Beispiel #36
0
from ert.cwrap import clib, CWrapper
from ert.job_queue import WorkflowJob
from ert.test import TestAreaContext, ExtendedTestCase
from ert_tests.job_queue.workflow_common import WorkflowCommon

test_lib = clib.ert_load("libjob_queue")  # create a local namespace
cwrapper = CWrapper(test_lib)

alloc_config = cwrapper.prototype("c_void_p workflow_job_alloc_config()")
alloc_from_file = cwrapper.prototype(
    "workflow_job_obj workflow_job_config_alloc(char*, c_void_p, char*)")


class WorkflowJobTest(ExtendedTestCase):
    def test_workflow_job_creation(self):
        workflow_job = WorkflowJob("Test")

        self.assertTrue(workflow_job.isInternal())
        self.assertEqual(workflow_job.name(), "Test")

    def test_read_internal_function(self):
        with TestAreaContext("python/job_queue/workflow_job") as work_area:
            WorkflowCommon.createInternalFunctionJob()
            WorkflowCommon.createErtScriptsJob()

            config = alloc_config()
            workflow_job = alloc_from_file("SELECT_CASE", config,
                                           "select_case_job")

            self.assertEqual(workflow_job.name(), "SELECT_CASE")
            self.assertTrue(workflow_job.isInternal())
Beispiel #37
0
        """ @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, 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)")
Beispiel #38
0

def openEclFile(file_name, flags=0):
    return EclFileContextManager(EclFile(file_name, flags))


# 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_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 )")
cfunc.restart_block_iselect = cwrapper.prototype(
    "bool        ecl_file_iselect_rstblock( ecl_file , int )")
cfunc.select_global = cwrapper.prototype(
Beispiel #39
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 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().set_job_queue = cwrapper.prototype(
    "void site_config_set_job_queue(site_config, char*)")
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(
Beispiel #40
0
            return self.getKeywordModelConfig()
        elif implementation_type == ErtImplType.CUSTOM_KW:
            return self.getCustomKeywordModelConfig()
        elif implementation_type == ErtImplType.SUMMARY:
            return SummaryConfig.createCReference(self.getPointerReference(), parent=self)
        else:
            print("[EnkfConfigNode::getModelConfig()] Unhandled implementation model type: %i" % implementation_type)
            # raise NotImplementedError("Unknown model type: %i" % type)

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


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

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

EnkfConfigNode.cNamespace().get_enkf_outfile = cwrapper.prototype("char* enkf_config_node_get_enkf_outfile(enkf_config_node)")
EnkfConfigNode.cNamespace().get_min_std_file = cwrapper.prototype("char* enkf_config_node_get_min_std_file(enkf_config_node)")
EnkfConfigNode.cNamespace().get_enkf_infile = cwrapper.prototype("char* enkf_config_node_get_enkf_infile(enkf_config_node)")
EnkfConfigNode.cNamespace().get_init_file_fmt = cwrapper.prototype("char* enkf_config_node_get_init_file_fmt(enkf_config_node)")
EnkfConfigNode.cNamespace().get_var_type = cwrapper.prototype("enkf_var_type_enum enkf_config_node_get_var_type(enkf_config_node)") #todo: fix return type as enum
EnkfConfigNode.cNamespace().get_key = cwrapper.prototype("char* enkf_config_node_get_key(enkf_config_node)") 
EnkfConfigNode.cNamespace().get_obs_keys = cwrapper.prototype("stringlist_ref enkf_config_node_get_obs_keys(enkf_config_node)")
EnkfConfigNode.cNamespace().alloc_summary_node = cwrapper.prototype("enkf_config_node_obj enkf_config_node_alloc_summary(char*, load_fail_type)")
EnkfConfigNode.cNamespace().alloc_field_node = cwrapper.prototype("enkf_config_node_obj enkf_config_node_alloc_field(char*, ecl_grid, c_void_p, bool)")
EnkfConfigNode.cNamespace().update_state_field = cwrapper.prototype("void enkf_config_node_update_state_field(enkf_config_node, enkf_truncation_type_enum, double, double)")
Beispiel #41
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* )")
Beispiel #42
0
    def __len__(self):
        """ @rtype: int """
        return WellTimeLine.cNamespace().size(self)

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

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

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

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

    def free(self):
        pass


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

WellTimeLine.cNamespace().size = cwrapper.prototype(
    "int well_ts_get_size(well_time_line)")
WellTimeLine.cNamespace().iget = cwrapper.prototype(
    "well_state_ref well_ts_iget_state(well_time_line, int)")
Beispiel #43
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)")
Beispiel #44
0
        self.__test_name = test_name
        self.__model_config = model_config
        self.__site_config = site_config
        self.__store_area = store_area
        self.__test_context = ErtTest(self.__test_name, self.__model_config, site_config=self.__site_config, store_area=self.__store_area)


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


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


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



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

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

Beispiel #45
0
            else:
                raise Exception("Parsing:%s failed" % config_file)
        else:
            raise IOError("File: %s does not exists" % config_file)


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


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


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

SchemaItem.cNamespace().alloc = cwrapper.prototype("c_void_p config_schema_item_alloc( char* , bool )")
SchemaItem.cNamespace().free = cwrapper.prototype("void config_schema_item_free( schema_item )")
SchemaItem.cNamespace().iget_type = cwrapper.prototype("config_content_type_enum config_schema_item_iget_type( schema_item, int)")
SchemaItem.cNamespace().iset_type = cwrapper.prototype("void config_schema_item_iset_type( schema_item , int , config_content_type_enum)")
SchemaItem.cNamespace().set_argc_minmax = cwrapper.prototype("void config_schema_item_set_argc_minmax( schema_item , int , int)")

    

Beispiel #46
0
    def __len__(self):
        return GenKwConfig.cNamespace().size(self)

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

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


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

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

GenKwConfig.cNamespace().should_use_log_scale = cwrapper.prototype("bool gen_kw_config_should_use_log_scale(gen_kw_config, int)")
GenKwConfig.cNamespace().get_key = cwrapper.prototype("char* gen_kw_config_get_key(gen_kw_config)")
GenKwConfig.cNamespace().size = cwrapper.prototype("int gen_kw_config_get_data_size(gen_kw_config)")
GenKwConfig.cNamespace().iget_name = cwrapper.prototype("char* gen_kw_config_iget_name(gen_kw_config, int)")
Beispiel #47
0
            return MeasBlock.cNamespace().iget_mean(self , iobs)
        else:
            raise IndexError("Invalid observation index:%d  valid range: [0,%d)" % (iobs , self.getObsSize()))

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



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

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


    


Beispiel #48
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)")
Beispiel #49
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)")
Beispiel #50
0
        assert isinstance(obs_data, ObsData)

        EnkfObs.cNamespace().get_obs_and_measure_data(self, fs, local_obsdata,
                                                      state, active_list,
                                                      meas_data, obs_data)

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


cwrapper = CWrapper(ENKF_LIB)
cwrapper.registerType("enkf_obs", EnkfObs)
cwrapper.registerType("enkf_obs_obj", EnkfObs.createPythonObject)
cwrapper.registerType("enkf_obs_ref", EnkfObs.createCReference)

EnkfObs.cNamespace().free = cwrapper.prototype(
    "void enkf_obs_free( enkf_obs )")
EnkfObs.cNamespace().get_size = cwrapper.prototype(
    "int enkf_obs_get_size( enkf_obs )")
EnkfObs.cNamespace().get_config_file = cwrapper.prototype(
    "char* enkf_obs_get_config_file( enkf_obs )")
EnkfObs.cNamespace().alloc_typed_keylist = cwrapper.prototype(
    "stringlist_obj enkf_obs_alloc_typed_keylist(enkf_obs, enkf_obs_impl_type)"
)
EnkfObs.cNamespace().has_key = cwrapper.prototype(
    "bool enkf_obs_has_key(enkf_obs, char*)")
EnkfObs.cNamespace().get_vector = cwrapper.prototype(
    "obs_vector_ref enkf_obs_get_vector(enkf_obs, char*)")
EnkfObs.cNamespace().iget_vector = cwrapper.prototype(
    "obs_vector_ref enkf_obs_iget_vector(enkf_obs, int)")
EnkfObs.cNamespace().iget_obs_time = cwrapper.prototype(
    "time_t enkf_obs_iget_obs_time(enkf_obs, int)")
Beispiel #51
0
        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)")
AnalysisConfig.cNamespace().get_iter_config        = cwrapper.prototype("analysis_iter_config_ref analysis_config_get_iter_config(analysis_config)")
AnalysisConfig.cNamespace().get_min_realisations   = cwrapper.prototype("int analysis_config_get_min_realisations(analysis_config)")
AnalysisConfig.cNamespace().set_min_realisations   = cwrapper.prototype("void analysis_config_set_min_realisations(analysis_config, int)")
AnalysisConfig.cNamespace().get_max_runtime        = cwrapper.prototype("int analysis_config_get_max_runtime(analysis_config)")
Beispiel #52
0
    def get_template_file(self):
        """ @rtype: str """
        return ErtTemplate.cNamespace().get_template_file(self)

    def get_target_file(self):
        """ @rtype: str """
        return ErtTemplate.cNamespace().get_target_file(self)

    def get_args_as_string(self):
        """ @rtype: str """
        return ErtTemplate.cNamespace().get_args_as_string(self)

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


cwrapper = CWrapper(ENKF_LIB)
cwrapper.registerType("ert_template", ErtTemplate)
cwrapper.registerType("ert_template_obj", ErtTemplate.createPythonObject)
cwrapper.registerType("ert_template_ref", ErtTemplate.createCReference)

ErtTemplate.cNamespace().free = cwrapper.prototype(
    "void ert_template_free( ert_template )")
ErtTemplate.cNamespace().get_template_file = cwrapper.prototype(
    "char* ert_template_get_template_file(ert_template)")
ErtTemplate.cNamespace().get_target_file = cwrapper.prototype(
    "char* ert_template_get_target_file(ert_template)")
ErtTemplate.cNamespace().get_args_as_string = cwrapper.prototype(
    "char* ert_template_get_args_as_string(ert_template)")
Beispiel #53
0
                              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 )")
cfunc.in_coarse_group1 = cwrapper.prototype(
    "bool ecl_grid_cell_in_coarse_group1( ecl_grid , int)")
        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 )")
Beispiel #55
0
        return self.__test_context

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

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

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


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

ErtTest.cNamespace().alloc = cwrapper.prototype(
    "c_void_p ert_test_context_alloc_python( char* , char* , char*)")
ErtTest.cNamespace().set_store = cwrapper.prototype(
    "c_void_p ert_test_context_set_store( ert_test , bool)")
ErtTest.cNamespace().free = cwrapper.prototype(
    "void ert_test_context_free( ert_test )")
ErtTest.cNamespace().get_enkf_main = cwrapper.prototype(
    "enkf_main_ref ert_test_context_get_main( ert_test )")
ErtTest.cNamespace().get_cwd = cwrapper.prototype(
    "char* ert_test_context_get_cwd( ert_test )")
Beispiel #56
0
    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*)")
EnKFMain.cNamespace().get_schedule_prediction_file = cwrapper.prototype("char* enkf_main_get_schedule_prediction_file( enkf_main )")
EnKFMain.cNamespace().set_schedule_prediction_file = cwrapper.prototype("void enkf_main_set_schedule_prediction_file( enkf_main , char*)")