How to use the ecl.eclfile.EclKW function in ecl

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 / grid / ecl_grid.py View on Github external
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]

                kw = EclKW(kw_name, size, type)
                active_index = 0
                global_index = 0
                for k in range(self.getNZ()):
                    for j in range(self.getNY()):
                        for i in range(self.getNX()):
                            if pack:
                                if self.active(global_index=global_index):
                                    kw[active_index] = array[i,j,k]
                                    active_index += 1
                            else:
                                if dtype == numpy.int32:
                                    kw[global_index] = int(array[i,j,k])
                                else:
                                    kw[global_index] = array[i,j,k]

                            global_index += 1
github equinor / libecl / python / ecl / grid / ecl_grid_generator.py View on Github external
def construct_floatKW(name, values):
    kw = EclKW(name, len(values), EclDataType.ECL_FLOAT)
    for i, value in enumerate(values):
        kw[i] = value
    return kw
github OPM / ResInsight / ThirdParty / Ert / python / ecl / grid / ecl_grid.py View on Github external
def global_kw_copy(self, kw, default_value):
        if len(kw) == self.getGlobalSize():
            return kw.copy()
        elif len(kw) == self.getNumActive():
            kw_copy = EclKW(kw.getName(), self.getGlobalSize(), kw.data_type)
            kw_copy.assign(default_value)
            self._global_kw_copy(kw_copy, kw)
            return kw_copy
        else:
            raise ValueError("The input keyword must have nx*n*nz or nactive elements. Size:%d invalid" % len(kw))
github equinor / libecl / python / ecl / eclfile / ecl_file.py View on Github external
swat = file.iget_named_kw( "SWAT" , 0 )
           new_swat = swat * 0.25
           file.replace_kw( swat , new_swat )


        The C-level ecl_file_type structure takes full ownership of
        all installed ecl_kw instances; mixing the garbage collector
        into it means that this is quite low level - and potentially
        dangerous!
        """

        # We ensure that this scope owns the new_kw instance; the
        # new_kw will be handed over to the ecl_file instance, and we
        # can not give away something we do not alreeady own.
        if not new_kw.data_owner:
            new_kw = EclKW.copy( new_kw )

        # The ecl_file instance will take responsability for freeing
        # this ecl_kw instance.
        new_kw.data_owner = False
        self._replace_kw( old_kw , new_kw , False )
github OPM / ResInsight / ThirdParty / Ert / python / ecl / grid / ecl_grid.py View on Github external
def compressed_kw_copy(self, kw):
        if len(kw) == self.getNumActive():
            return kw.copy()
        elif len(kw) == self.getGlobalSize():
            kw_copy = EclKW(kw.getName(), self.getNumActive(), kw.data_type)
            self._compressed_kw_copy(kw_copy, kw)
            return kw_copy
        else:
            raise ValueError("The input keyword must have nx*n*nz or nactive elements. Size:%d invalid" % len(kw))
github equinor / libecl / python / ecl / grid / ecl_grid.py View on Github external
def global_kw_copy(self, kw, default_value):
        if len(kw) == self.getGlobalSize():
            return kw.copy()
        elif len(kw) == self.getNumActive():
            kw_copy = EclKW(kw.getName(), self.getGlobalSize(), kw.data_type)
            kw_copy.assign(default_value)
            self._global_kw_copy(kw_copy, kw)
            return kw_copy
        else:
            raise ValueError("The input keyword must have nx*n*nz or nactive elements. Size:%d invalid" % len(kw))
github equinor / libecl / python / ecl / grid / ecl_grid_generator.py View on Github external
def construct_floatKW(name, values):
            kw = EclKW(name, len(values), EclDataType.ECL_FLOAT)
            for i in range(len(values)):
                kw[i] = values[i]
            return kw