当前位置: 首页>>代码示例>>Python>>正文


Python EclKW.copy方法代码示例

本文整理汇总了Python中ecl.eclfile.EclKW.copy方法的典型用法代码示例。如果您正苦于以下问题:Python EclKW.copy方法的具体用法?Python EclKW.copy怎么用?Python EclKW.copy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ecl.eclfile.EclKW的用法示例。


在下文中一共展示了EclKW.copy方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: replace_kw

# 需要导入模块: from ecl.eclfile import EclKW [as 别名]
# 或者: from ecl.eclfile.EclKW import copy [as 别名]
    def replace_kw( self , old_kw , new_kw):
        """
        Will replace @old_kw with @new_kw in current EclFile instance.

        This method can be used to replace one of the EclKW instances
        in the current EclFile. The @old_kw reference must be to the
        actual EclKW instance in the current EclFile instance (the
        final comparison is based on C pointer equality!), i.e. it
        must be a reference (not a copy) from one of the ??get_kw??
        methods of the EclFile class. In the example below we replace
        the SWAT keyword from a restart file:

           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 )
开发者ID:OPM,项目名称:ResInsight,代码行数:35,代码来源:ecl_file.py

示例2: test_missing_smspec_keyword

# 需要导入模块: from ecl.eclfile import EclKW [as 别名]
# 或者: from ecl.eclfile.EclKW import copy [as 别名]
    def test_missing_smspec_keyword(self):
        with TestAreaContext("EclSum/truncated_data") as ta:
            ta.copy_file(self.test_file)
            ta.copy_file(self.createTestPath("Statoil/ECLIPSE/Gurbat/ECLIPSE.UNSMRY"))

            with openEclFile("ECLIPSE.SMSPEC") as f:
                kw_list = []
                for kw in f:
                    kw_list.append(EclKW.copy(kw))

            with openFortIO("ECLIPSE.SMSPEC", mode=FortIO.WRITE_MODE) as f:
                for kw in kw_list:
                    if kw.getName() == "KEYWORDS":
                        continue
                    kw.fwrite(f)

            with self.assertRaises(IOError):
                EclSum("ECLIPSE")
开发者ID:OPM,项目名称:ResInsight,代码行数:20,代码来源:test_ecl_sum.py

示例3: iget_kw

# 需要导入模块: from ecl.eclfile import EclKW [as 别名]
# 或者: from ecl.eclfile.EclKW import copy [as 别名]
    def iget_kw( self , index , copy = False):
        """
        Will return EclKW instance nr @index.

        In the files loaded with the EclFile implementation the
        ECLIPSE keywords come sequentially in a long series, an INIT
        file might have the following keywords:

          INTEHEAD
          LOGIHEAD
          DOUBHEAD
          PORV
          DX
          DY
          DZ
          PERMX
          PERMY
          PERMZ
          MULTX
          MULTY
          .....

        The iget_kw() method will give you a EclKW reference to
        keyword nr @index. This functionality is also available
        through the index operator []:

           file = EclFile( "ECLIPSE.INIT" )
           permx = file.iget_kw( 7 )
           permz = file[ 9 ]

        Observe that the returned EclKW instance is only a reference
        to the data owned by the EclFile instance.

        The method iget_named_kw() which lets you specify the name of
        the keyword you are interested in is in general more useful
        than this method.
        """
        kw = self[index]
        if copy:
            return EclKW.copy( kw )
        else:
            return kw
开发者ID:OPM,项目名称:ResInsight,代码行数:44,代码来源:ecl_file.py

示例4: restart_get_kw

# 需要导入模块: from ecl.eclfile import EclKW [as 别名]
# 或者: from ecl.eclfile.EclKW import copy [as 别名]
    def restart_get_kw( self , kw_name , dtime , copy = False):
        """Will return EclKW @kw_name from restart file at time @dtime.

        This function assumes that the current EclFile instance
        represents a restart file. It will then look for keyword
        @kw_name exactly at the time @dtime; @dtime is a datetime
        instance:

            file = EclFile( "ECLIPSE.UNRST" )
            swat2010 = file.restart_get_kw( "SWAT" , datetime.datetime( 2000 , 1 , 1 ))

        By default the returned kw instance is a reference to the
        ecl_kw still contained in the EclFile instance; i.e. the kw
        will become a dangling reference if the EclFile instance goes
        out of scope. If the optional argument @copy is True the
        returned kw will be a true copy.

        If the file does not have the keyword at the specified time
        the function will raise IndexError(); if the file does not
        have the keyword at all - KeyError will be raised.
        """
        index = self._get_restart_index( CTime( dtime ) )
        if index >= 0:
            if self.num_named_kw(kw_name) > index:
                kw = self.iget_named_kw( kw_name , index )
                if copy:
                    return EclKW.copy( kw )
                else:
                    return kw
            else:
                if self.has_kw(kw_name):
                    raise IndexError('Does not have keyword "%s" at time:%s.' % (kw_name , dtime))
                else:
                    raise KeyError('Keyword "%s" not recognized.' % kw_name)
        else:
            raise IndexError('Does not have keyword "%s" at time:%s.' % (kw_name , dtime))
开发者ID:OPM,项目名称:ResInsight,代码行数:38,代码来源:ecl_file.py


注:本文中的ecl.eclfile.EclKW.copy方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。