How to use ecl - 10 common examples

To help you get started, we’ve selected a few ecl 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 equinor / libecl / python / ecl / grid / ecl_region.py View on Github external
def idiv_kw( self , target_kw , other , force_active = False):
        if isinstance(other , EclKW):
            if target_kw.assert_binary( other):
                self._idiv_kw( target_kw , other )
            else:
                raise TypeError("Type mismatch")
        else:
            if target_kw.data_type.is_int():
                scale = 1 // other
            else:
                scale = 1.0 / other
            self.scale_kw( target_kw , scale , force_active )
github equinor / libecl / python / ecl / summary / ecl_sum.py View on Github external
_check_sim_time                = EclPrototype("bool     ecl_sum_check_sim_time(ecl_sum, time_t)")
    _check_sim_days                = EclPrototype("bool     ecl_sum_check_sim_days(ecl_sum, double)")
    _sim_length                    = EclPrototype("double   ecl_sum_get_sim_length(ecl_sum)")
    _get_first_day                 = EclPrototype("double   ecl_sum_get_first_day(ecl_sum)")
    _get_data_start                = EclPrototype("time_t   ecl_sum_get_data_start(ecl_sum)")
    _get_unit                      = EclPrototype("char*    ecl_sum_get_unit(ecl_sum, char*)")
    _get_restart_case              = EclPrototype("ecl_sum_ref ecl_sum_get_restart_case(ecl_sum)")
    _get_restart_step              = EclPrototype("int      ecl_sum_get_restart_step(ecl_sum)")
    _get_simcase                   = EclPrototype("char*    ecl_sum_get_case(ecl_sum)")
    _get_unit_system               = EclPrototype("ecl_unit_enum ecl_sum_get_unit_system(ecl_sum)")
    _get_base                      = EclPrototype("char*    ecl_sum_get_base(ecl_sum)")
    _get_path                      = EclPrototype("char*    ecl_sum_get_path(ecl_sum)")
    _get_abs_path                  = EclPrototype("char*    ecl_sum_get_abs_path(ecl_sum)")
    _get_report_step_from_time     = EclPrototype("int      ecl_sum_get_report_step_from_time(ecl_sum, time_t)")
    _get_report_step_from_days     = EclPrototype("int      ecl_sum_get_report_step_from_days(ecl_sum, double)")
    _get_report_time               = EclPrototype("time_t   ecl_sum_get_report_time(ecl_sum, int)")
    _fwrite_sum                    = EclPrototype("void     ecl_sum_fwrite(ecl_sum)")
    _can_write                     = EclPrototype("bool     ecl_sum_can_write(ecl_sum)")
    _set_case                      = EclPrototype("void     ecl_sum_set_case(ecl_sum, char*)")
    _alloc_time_vector             = EclPrototype("time_t_vector_obj ecl_sum_alloc_time_vector(ecl_sum, bool)")
    _alloc_data_vector             = EclPrototype("double_vector_obj ecl_sum_alloc_data_vector(ecl_sum, int, bool)")
    _get_var_node                  = EclPrototype("smspec_node_ref ecl_sum_get_general_var_node(ecl_sum, char*)")
    _create_well_list              = EclPrototype("stringlist_obj ecl_sum_alloc_well_list(ecl_sum, char*)")
    _create_group_list             = EclPrototype("stringlist_obj ecl_sum_alloc_group_list(ecl_sum, char*)")
    _add_variable                  = EclPrototype("smspec_node_ref   ecl_sum_add_var(ecl_sum, char*, char*, int, char*, double)")
    _add_tstep                     = EclPrototype("ecl_sum_tstep_ref ecl_sum_add_tstep(ecl_sum, int, double)")
    _export_csv                    = EclPrototype("void ecl_sum_export_csv(ecl_sum, char*, stringlist, char*, char*)")
    _identify_var_type             = EclPrototype("ecl_sum_var_type ecl_sum_identify_var_type(char*)", bind = False)
    _is_rate                       = EclPrototype("bool smspec_node_identify_rate(char*)", bind = False)
    _is_total                      = EclPrototype("bool smspec_node_identify_total(char*, ecl_sum_var_type)", bind = False)
    _get_last_value                = EclPrototype("double ecl_sum_get_last_value_gen_key(ecl_sum, char*)")
    _get_first_value               = EclPrototype("double ecl_sum_get_first_value_gen_key(ecl_sum, char*)")
github OPM / ResInsight / ThirdParty / Ert / python / python / ecl / util / matrix.py View on Github external
_copy              = UtilPrototype("matrix_obj  matrix_alloc_copy(matrix)" )
    _sub_copy          = UtilPrototype("matrix_obj  matrix_alloc_sub_copy(matrix, int , int , int , int)" )
    _free              = UtilPrototype("void   matrix_free(matrix)")
    _iget              = UtilPrototype("double matrix_iget( matrix , int , int )")
    _iset              = UtilPrototype("void   matrix_iset( matrix , int , int , double)")
    _set_all           = UtilPrototype("void   matrix_scalar_set( matrix , double)")
    _scale_column      = UtilPrototype("void matrix_scale_column(matrix , int , double)")
    _scale_row         = UtilPrototype("void matrix_scale_row(matrix , int , double)")
    _copy_column       = UtilPrototype("void matrix_copy_column(matrix , matrix , int , int)" , bind = False)
    _rows              = UtilPrototype("int matrix_get_rows(matrix)")
    _columns           = UtilPrototype("int matrix_get_columns(matrix)")
    _equal             = UtilPrototype("bool matrix_equal(matrix, matrix)")
    _pretty_print      = UtilPrototype("void matrix_pretty_print(matrix, char*, char*)")
    _fprint            = UtilPrototype("void matrix_fprintf(matrix, char*, FILE)")
    _random_init       = UtilPrototype("void matrix_random_init(matrix, rng)")
    _dump_csv          = UtilPrototype("void matrix_dump_csv(matrix, char*)")

    # Requires BLAS. If the library does not have the
    # matrix_alloc_matmul() function the prototype will have _func =
    # None, and NotImplementedError( ) will be raised int the
    # __call__() method if we try to use this function.
    _alloc_matmul      = UtilPrototype("matrix_obj  matrix_alloc_matmul(matrix, matrix)" , bind = False, allow_attribute_error = True)

    # Requires BLAS!
    @classmethod
    def matmul(cls, m1,m2):
        """
        Will return a new matrix which is matrix product of m1 and m2.
        """
        if m1.columns( ) == m2.rows( ):
            return cls._alloc_matmul( m1, m2)
        else:
github OPM / ResInsight / ThirdParty / Ert / python / python / ecl / util / version.py View on Github external
return self.build_time

    def getGitCommit(self, short=False):
        if self.git_commit is None:
            return "???????"
        else:
            if short:
                return self.git_commit[0:8]
            else:
                return self.git_commit


class EclVersion(Version):
    _build_time = UtilPrototype("char* ecl_version_get_build_time()")
    _git_commit = UtilPrototype("char* ecl_version_get_git_commit()")
    _major_version = UtilPrototype("int ecl_version_get_major_version()")
    _minor_version = UtilPrototype("int ecl_version_get_minor_version()")
    _micro_version = UtilPrototype("char* ecl_version_get_micro_version()")
    _is_devel = UtilPrototype("bool ecl_version_is_devel_version()")

    def __init__(self):
        major = self._major_version( )
        minor = self._minor_version( )
        micro = self._micro_version( )
        git_commit = self._git_commit( )
        build_time = self._build_time( )
        super( EclVersion, self).__init__( major, minor , micro , git_commit, build_time)
github OPM / ResInsight / ThirdParty / Ert / python / python / ecl / util / matrix.py View on Github external
from cwrap import BaseCClass,CFILE
from ecl.util import UtilPrototype


class Matrix(BaseCClass):
    _matrix_alloc      = UtilPrototype("void*  matrix_alloc(int, int )" , bind = False)
    _matrix_alloc_identity = UtilPrototype("matrix_obj  matrix_alloc_identity( int )" , bind = False)
    _alloc_transpose   = UtilPrototype("matrix_obj  matrix_alloc_transpose(matrix)")
    _inplace_transpose = UtilPrototype("void        matrix_inplace_transpose(matrix)")
    _copy              = UtilPrototype("matrix_obj  matrix_alloc_copy(matrix)" )
    _sub_copy          = UtilPrototype("matrix_obj  matrix_alloc_sub_copy(matrix, int , int , int , int)" )
    _free              = UtilPrototype("void   matrix_free(matrix)")
    _iget              = UtilPrototype("double matrix_iget( matrix , int , int )")
    _iset              = UtilPrototype("void   matrix_iset( matrix , int , int , double)")
    _set_all           = UtilPrototype("void   matrix_scalar_set( matrix , double)")
    _scale_column      = UtilPrototype("void matrix_scale_column(matrix , int , double)")
    _scale_row         = UtilPrototype("void matrix_scale_row(matrix , int , double)")
    _copy_column       = UtilPrototype("void matrix_copy_column(matrix , matrix , int , int)" , bind = False)
    _rows              = UtilPrototype("int matrix_get_rows(matrix)")
    _columns           = UtilPrototype("int matrix_get_columns(matrix)")
    _equal             = UtilPrototype("bool matrix_equal(matrix, matrix)")
    _pretty_print      = UtilPrototype("void matrix_pretty_print(matrix, char*, char*)")
    _fprint            = UtilPrototype("void matrix_fprintf(matrix, char*, FILE)")
    _random_init       = UtilPrototype("void matrix_random_init(matrix, rng)")
    _dump_csv          = UtilPrototype("void matrix_dump_csv(matrix, char*)")

    # Requires BLAS. If the library does not have the
    # matrix_alloc_matmul() function the prototype will have _func =
    # None, and NotImplementedError( ) will be raised int the
    # __call__() method if we try to use this function.
    _alloc_matmul      = UtilPrototype("matrix_obj  matrix_alloc_matmul(matrix, matrix)" , bind = False, allow_attribute_error = True)
github OPM / ResInsight / ThirdParty / Ert / python / python / ecl / util / version.py View on Github external
if self.git_commit is None:
            return "???????"
        else:
            if short:
                return self.git_commit[0:8]
            else:
                return self.git_commit


class EclVersion(Version):
    _build_time = UtilPrototype("char* ecl_version_get_build_time()")
    _git_commit = UtilPrototype("char* ecl_version_get_git_commit()")
    _major_version = UtilPrototype("int ecl_version_get_major_version()")
    _minor_version = UtilPrototype("int ecl_version_get_minor_version()")
    _micro_version = UtilPrototype("char* ecl_version_get_micro_version()")
    _is_devel = UtilPrototype("bool ecl_version_is_devel_version()")

    def __init__(self):
        major = self._major_version( )
        minor = self._minor_version( )
        micro = self._micro_version( )
        git_commit = self._git_commit( )
        build_time = self._build_time( )
        super( EclVersion, self).__init__( major, minor , micro , git_commit, build_time)
github OPM / ResInsight / ThirdParty / Ert / python / python / ecl / util / version.py View on Github external
return "?????"
        else:
            return self.build_time

    def getGitCommit(self, short=False):
        if self.git_commit is None:
            return "???????"
        else:
            if short:
                return self.git_commit[0:8]
            else:
                return self.git_commit


class EclVersion(Version):
    _build_time = UtilPrototype("char* ecl_version_get_build_time()")
    _git_commit = UtilPrototype("char* ecl_version_get_git_commit()")
    _major_version = UtilPrototype("int ecl_version_get_major_version()")
    _minor_version = UtilPrototype("int ecl_version_get_minor_version()")
    _micro_version = UtilPrototype("char* ecl_version_get_micro_version()")
    _is_devel = UtilPrototype("bool ecl_version_is_devel_version()")

    def __init__(self):
        major = self._major_version( )
        minor = self._minor_version( )
        micro = self._micro_version( )
        git_commit = self._git_commit( )
        build_time = self._build_time( )
        super( EclVersion, self).__init__( major, minor , micro , git_commit, build_time)
github OPM / ResInsight / ThirdParty / Ert / python / python / ecl / util / matrix.py View on Github external
# expect a matrix instance as input (i.e. the LARS estimator). For
# general linear algebra in Python the numpy library is a natural
# choice.


from cwrap import BaseCClass,CFILE
from ecl.util import UtilPrototype


class Matrix(BaseCClass):
    _matrix_alloc      = UtilPrototype("void*  matrix_alloc(int, int )" , bind = False)
    _matrix_alloc_identity = UtilPrototype("matrix_obj  matrix_alloc_identity( int )" , bind = False)
    _alloc_transpose   = UtilPrototype("matrix_obj  matrix_alloc_transpose(matrix)")
    _inplace_transpose = UtilPrototype("void        matrix_inplace_transpose(matrix)")
    _copy              = UtilPrototype("matrix_obj  matrix_alloc_copy(matrix)" )
    _sub_copy          = UtilPrototype("matrix_obj  matrix_alloc_sub_copy(matrix, int , int , int , int)" )
    _free              = UtilPrototype("void   matrix_free(matrix)")
    _iget              = UtilPrototype("double matrix_iget( matrix , int , int )")
    _iset              = UtilPrototype("void   matrix_iset( matrix , int , int , double)")
    _set_all           = UtilPrototype("void   matrix_scalar_set( matrix , double)")
    _scale_column      = UtilPrototype("void matrix_scale_column(matrix , int , double)")
    _scale_row         = UtilPrototype("void matrix_scale_row(matrix , int , double)")
    _copy_column       = UtilPrototype("void matrix_copy_column(matrix , matrix , int , int)" , bind = False)
    _rows              = UtilPrototype("int matrix_get_rows(matrix)")
    _columns           = UtilPrototype("int matrix_get_columns(matrix)")
    _equal             = UtilPrototype("bool matrix_equal(matrix, matrix)")
    _pretty_print      = UtilPrototype("void matrix_pretty_print(matrix, char*, char*)")
    _fprint            = UtilPrototype("void matrix_fprintf(matrix, char*, FILE)")
    _random_init       = UtilPrototype("void matrix_random_init(matrix, rng)")
    _dump_csv          = UtilPrototype("void matrix_dump_csv(matrix, char*)")

    # Requires BLAS. If the library does not have the
github OPM / ResInsight / ThirdParty / Ert / python / python / ecl / util / matrix.py View on Github external
_matrix_alloc_identity = UtilPrototype("matrix_obj  matrix_alloc_identity( int )" , bind = False)
    _alloc_transpose   = UtilPrototype("matrix_obj  matrix_alloc_transpose(matrix)")
    _inplace_transpose = UtilPrototype("void        matrix_inplace_transpose(matrix)")
    _copy              = UtilPrototype("matrix_obj  matrix_alloc_copy(matrix)" )
    _sub_copy          = UtilPrototype("matrix_obj  matrix_alloc_sub_copy(matrix, int , int , int , int)" )
    _free              = UtilPrototype("void   matrix_free(matrix)")
    _iget              = UtilPrototype("double matrix_iget( matrix , int , int )")
    _iset              = UtilPrototype("void   matrix_iset( matrix , int , int , double)")
    _set_all           = UtilPrototype("void   matrix_scalar_set( matrix , double)")
    _scale_column      = UtilPrototype("void matrix_scale_column(matrix , int , double)")
    _scale_row         = UtilPrototype("void matrix_scale_row(matrix , int , double)")
    _copy_column       = UtilPrototype("void matrix_copy_column(matrix , matrix , int , int)" , bind = False)
    _rows              = UtilPrototype("int matrix_get_rows(matrix)")
    _columns           = UtilPrototype("int matrix_get_columns(matrix)")
    _equal             = UtilPrototype("bool matrix_equal(matrix, matrix)")
    _pretty_print      = UtilPrototype("void matrix_pretty_print(matrix, char*, char*)")
    _fprint            = UtilPrototype("void matrix_fprintf(matrix, char*, FILE)")
    _random_init       = UtilPrototype("void matrix_random_init(matrix, rng)")
    _dump_csv          = UtilPrototype("void matrix_dump_csv(matrix, char*)")

    # Requires BLAS. If the library does not have the
    # matrix_alloc_matmul() function the prototype will have _func =
    # None, and NotImplementedError( ) will be raised int the
    # __call__() method if we try to use this function.
    _alloc_matmul      = UtilPrototype("matrix_obj  matrix_alloc_matmul(matrix, matrix)" , bind = False, allow_attribute_error = True)

    # Requires BLAS!
    @classmethod
    def matmul(cls, m1,m2):
        """
        Will return a new matrix which is matrix product of m1 and m2.
        """
github OPM / ResInsight / ThirdParty / Ert / python / ecl / grid / ecl_grid.py View on Github external
def create_kw(self, array, kw_name, pack):
        """
        Creates an EclKW instance based on existing 3D numpy object.

        The method create3D() does the inverse operation; creating a
        3D numpy object from an EclKW instance. If the argument @pack
        is true the resulting keyword will have length 'nactive',
        otherwise the element will have length nx*ny*nz.
        """
        if array.ndim == 3:
            dims = array.shape
            if dims[0] == self.getNX() and dims[1] == self.getNY() and dims[2] == self.getNZ():
                dtype = array.dtype
                if dtype == numpy.int32:
                    type = EclDataType.ECL_INT
                elif dtype == numpy.float32:
                    type = EclDataType.ECL_FLOAT
                elif dtype == numpy.float64:
                    type = EclDataType.ECL_DOUBLE
                else:
                    sys.exit("Do not know how to create ecl_kw from type:%s" % dtype)

                if pack:
                    size = self.getNumActive()
                else:
                    size = self.getGlobalSize()

                if len(kw_name) > 8:
                    # Silently truncate to length 8 - ECLIPSE has it's challenges.
                    kw_name = kw_name[0:8]