How to use the ert.ecl.EclTypeEnum function in ert

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

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

github Ensembles / ert / devel / python / python / ert / ecl / ecl_grid.py View on Github external
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 = EclTypeEnum.ECL_INT_TYPE
                elif dtype == numpy.float32:
                    type = EclTypeEnum.ECL_FLOAT_TYPE
                elif dtype == numpy.float64:
                    type = EclTypeEnum.ECL_DOUBLE_TYPE
                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]  

                kw = EclKW( kw_name , size , type )
                active_index = 0
                global_index = 0
                for k in range( self.nz ):
github OPM / ResInsight / ThirdParty / Ert / devel / python / python / ert / ecl / ecl_grid.py View on Github external
"""
        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 = EclTypeEnum.ECL_INT_TYPE
                elif dtype == numpy.float32:
                    type = EclTypeEnum.ECL_FLOAT_TYPE
                elif dtype == numpy.float64:
                    type = EclTypeEnum.ECL_DOUBLE_TYPE
                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]  

                kw = EclKW( kw_name , size , type )
                active_index = 0
github Ensembles / ert / devel / python / python / ert_gui / viewer / slice_viewer.py View on Github external
def loadGrid(path, load_actnum=True):
    """ @rtype: EclGrid """
    with open(path, "r") as f:
        specgrid = EclKW.read_grdecl(f, "SPECGRID", ecl_type=EclTypeEnum.ECL_INT_TYPE, strict=False)
        zcorn = EclKW.read_grdecl(f, "ZCORN")
        coord = EclKW.read_grdecl(f, "COORD")

        actnum = None
        if load_actnum:
            actnum = EclKW.read_grdecl(f, "ACTNUM", ecl_type=EclTypeEnum.ECL_INT_TYPE)

        mapaxes = EclKW.read_grdecl(f, "MAPAXES")
        grid = EclGrid.create(specgrid, zcorn, coord, actnum, mapaxes=mapaxes)

    return grid
github Ensembles / ert / devel / python / python / ert / ecl / ecl_kw.py View on Github external
self.data_ptr = self._int_ptr( )
            self.dtype    = numpy.int32        
            self.str_fmt  = "%8d"
        elif ecl_type == EclTypeEnum.ECL_FLOAT_TYPE:
            self.data_ptr = self._float_ptr( )
            self.dtype    = numpy.float32
            self.str_fmt  = "%13.4f"
        elif ecl_type == EclTypeEnum.ECL_DOUBLE_TYPE:
            self.data_ptr = self._double_ptr( )
            self.dtype    = numpy.float64        
            self.str_fmt  = "%13.4f"
        else:
            # Iteration not supported for CHAR / BOOL
            self.data_ptr = None
            self.dtype    = None
            if ecl_type == EclTypeEnum.ECL_CHAR_TYPE:
                self.str_fmt  = "%8s"
            elif ecl_type == EclTypeEnum.ECL_BOOL_TYPE:
                self.str_fmt  = "%d"
            else:
                self.str_fmt = "%s"  #"Message type"
github OPM / ResInsight / ThirdParty / Ert / devel / python / python / ert / ecl / ecl_region.py View on Github external
def scale_kw( self , ecl_kw , scale , force_active = False):
        """
        See usage documentation on iadd_kw().
        """
        self.scalar_apply_kw( ecl_kw , scale , {EclTypeEnum.ECL_INT_TYPE    : self._scale_kw_int,
                                                EclTypeEnum.ECL_FLOAT_TYPE  : self._scale_kw_float ,
                                                EclTypeEnum.ECL_DOUBLE_TYPE : self._scale_kw_double} , force_active)
github Ensembles / ert / devel / python / python / ert / ecl / ecl_kw.py View on Github external
def __IMUL__(self , factor , mul = True):
        if cfunc.assert_numeric( self ):
            if hasattr( factor , "ecl_kw_instance"):
                if cfunc.assert_binary( self, factor ):
                    if mul:
                        cfunc.imul( self , factor )
                    else:
                        cfunc.idiv( self , factor )
                else:
                    raise TypeError("Type mismatch")
            else:
                if not mul:
                    factor = 1.0 / factor
                    
                if self.ecl_type == EclTypeEnum.ECL_INT_TYPE:
                    if isinstance( factor , int ):
                        cfunc.scale_int( self , factor )
                    else:
                        raise TypeError("Type mismatch")
                else:
                    if isinstance( factor , int ) or isinstance( factor , float):
                        cfunc.scale_float( self , factor )
                    else:
                        raise TypeError("Only muliplication with scalar supported")
        else:
            raise TypeError("Not numeric type")
        
        return self
github Ensembles / ert / devel / python / python / ert / ecl / ecl_region.py View on Github external
def scale_kw( self , ecl_kw , scale , force_active = False):
        """
        See usage documentation on iadd_kw().
        """
        self.scalar_apply_kw( ecl_kw , scale , {EclTypeEnum.ECL_INT_TYPE    : cfunc.scale_kw_int,
                                                EclTypeEnum.ECL_FLOAT_TYPE  : cfunc.scale_kw_float ,
                                                EclTypeEnum.ECL_DOUBLE_TYPE : cfunc.scale_kw_double} , force_active)
github Ensembles / ert / devel / python / python / ert / ecl / ecl_region.py View on Github external
def shift_kw( self , ecl_kw , shift , force_active = False):
        """
        See usage documentation on iadd_kw().
        """
        self.scalar_apply_kw( ecl_kw , shift , {EclTypeEnum.ECL_INT_TYPE    : cfunc.shift_kw_int,
                                                EclTypeEnum.ECL_FLOAT_TYPE  : cfunc.shift_kw_float ,
                                                EclTypeEnum.ECL_DOUBLE_TYPE : cfunc.shift_kw_double} , force_active)
github OPM / ResInsight / ThirdParty / Ert / devel / python / python / ert / ecl / faults / fault_block_layer.py View on Github external
def exportKeyword(self , kw):
        if len(kw) != self.grid_ref.getGlobalSize():
            raise ValueError("The size of the target keyword must be equal to the size of the grid. Got:%d Expected:%d" % (len(kw) , self.grid_ref.getGlobalSize()))

        if kw.getEclType() != EclTypeEnum.ECL_INT_TYPE:
            raise TypeError("The target kewyord must be of integer type")
            
        self.cNamespace().export_kw( self , kw )
github Ensembles / ert / devel / python / python / ert / ecl / ecl_kw.py View on Github external
def type( self ):
        # enum ecl_type_enum from ecl_util.h
        if self.ecl_type == EclTypeEnum.ECL_CHAR_TYPE:
            return "CHAR"
        if self.ecl_type == EclTypeEnum.ECL_FLOAT_TYPE:
            return "REAL"
        if self.ecl_type == EclTypeEnum.ECL_DOUBLE_TYPE:
            return "DOUB"
        if self.ecl_type == EclTypeEnum.ECL_INT_TYPE:
            return "INTE"
        if self.ecl_type == EclTypeEnum.ECL_BOOL_TYPE:
            return "BOOL"
        if self.ecl_type == EclTypeEnum.ECL_MESS_TYPE:
            return "MESS"