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


Python util.IntVector类代码示例

本文整理汇总了Python中ert.util.IntVector的典型用法代码示例。如果您正苦于以下问题:Python IntVector类的具体用法?Python IntVector怎么用?Python IntVector使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: exportFIELD

    def exportFIELD(self, line):
        arguments = splitArguments(line)

        if len(arguments) >= 1:
            ens_config = self.ert().ensembleConfig()
            key = arguments[0]
            if key in self.supportedFIELDKeys():
                config_node = ens_config[key]
                if len(arguments) >= 2:
                    path_fmt = arguments[1]
                else:
                    path_fmt = Export.DEFAULT_EXPORT_PATH % (key, key) + ".grdecl"

                if len(arguments) >= 3:
                    range_string = "".join(arguments[2:])
                    iens_list = IntVector.active_list(range_string)
                else:
                    ens_size = self.ert().getEnsembleSize()
                    iens_list = IntVector.createRange(0, ens_size, 1)

                fs_manager = self.ert().getEnkfFsManager()
                fs = fs_manager.getCurrentFileSystem()
                init_file = self.ert().fieldInitFile(config_node)
                if init_file:
                    print('Using init file: %s' % init_file)

                EnkfNode.exportMany(config_node, path_fmt, fs, iens_list, arg=init_file)
            else:
                self.lastCommandFailed("No such FIELD node: %s" % key)
        else:
            self.lastCommandFailed("Expected at least one argument: <keyword> received: '%s'" % line)
开发者ID:agchitu,项目名称:ert,代码行数:31,代码来源:export.py

示例2: test_grdecl_load

    def test_grdecl_load(self):
        with self.assertRaises(IOError):
            grid = EclGrid.loadFromGrdecl("/file/does/not/exists")

        with TestAreaContext("python/grid-test/grdeclLoad"):
            with open("grid.grdecl","w") as f:
                f.write("Hei ...")
                
            with self.assertRaises(ValueError):
                grid = EclGrid.loadFromGrdecl("grid.grdecl")
        
            actnum = IntVector(default_value = 1 , initial_size = 1000)
            actnum[0] = 0
            g1 = EclGrid.createRectangular((10,10,10) , (1,1,1) , actnum = actnum )
            self.assertEqual( g1.getNumActive() , actnum.elementSum() )
            g1.save_EGRID("G.EGRID")

            with openEclFile("G.EGRID") as f:
                with open("grid.grdecl" , "w") as f2:
                    f2.write("SPECGRID\n")
                    f2.write("  10  10  10  \'F\' /\n")

                    coord_kw = f["COORD"][0]
                    coord_kw.write_grdecl( f2 )
                    
                    zcorn_kw = f["ZCORN"][0]
                    zcorn_kw.write_grdecl( f2 )
                
                    actnum_kw = f["ACTNUM"][0]
                    actnum_kw.write_grdecl( f2 )
            
            g2 = EclGrid.loadFromGrdecl("grid.grdecl")
            self.assertTrue( g1.equal( g2 ))
开发者ID:chflo,项目名称:ert,代码行数:33,代码来源:test_grid_statoil.py

示例3: test_scale_obs

    def test_scale_obs(self):
        with ErtTestContext("obs_test", self.config_file) as test_context:
            ert = test_context.getErt()
            obs = ert.getObservations()

            obs1 = obs["WWCT:OP_1"].getNode( 50 )
            obs2 = obs["WWCT:OP_1_50"].getNode( 50 )
            
            self.assertEqual( obs1.getStandardDeviation( ) , obs2.getStandardDeviation( ))
            std0 = obs1.getStandardDeviation( )

            local_obsdata = LocalObsdata("obs" , obs)
            node1 = LocalObsdataNode( "WWCT:OP_1" )
            node1.addRange( 50 , 50 )
            node2 = LocalObsdataNode( "WWCT:OP_1_50" )
            node2.addRange( 50 , 50 )
            local_obsdata.addNode( node1 )
            local_obsdata.addNode( node2 )

            mask = BoolVector( default_value = True )
            mask[2] = True
            meas_data = MeasData(mask)
            obs_data = ObsData( )
            fs = ert.getEnkfFsManager().getCurrentFileSystem()
            active_list = IntVector()
            active_list.initRange(0,2,1)
            obs.getObservationAndMeasureData( fs , local_obsdata , EnkfStateType.FORECAST , active_list , meas_data , obs_data )
            self.assertEqual( 2 , len(obs_data) )

            v1 = obs_data[0]
            v2 = obs_data[1]

            self.assertEqual( v1[1] , std0 )
            self.assertEqual( v2[1] , std0 )

            meas_data = MeasData(mask)
            obs_data = ObsData( 10 )
            obs.getObservationAndMeasureData( fs , local_obsdata , EnkfStateType.FORECAST , active_list , meas_data , obs_data )
            self.assertEqual( 2 , len(obs_data) )
            
            v1 = obs_data[0]
            v2 = obs_data[1]
            
            self.assertEqual( v1[1] , std0*10)
            self.assertEqual( v2[1] , std0*10 )

            actl = ActiveList()
            obs1.updateStdScaling( 10 , actl)
            obs2.updateStdScaling( 20 , actl)
            meas_data = MeasData(mask)
            obs_data = ObsData( )
            obs.getObservationAndMeasureData( fs , local_obsdata , EnkfStateType.FORECAST , active_list , meas_data , obs_data )
            self.assertEqual( 2 , len(obs_data) )
            
            v1 = obs_data[0]
            v2 = obs_data[1]
            
            self.assertEqual( v1[1] , std0*10)
            self.assertEqual( v2[1] , std0*20)
开发者ID:atgeirr,项目名称:ResInsight,代码行数:59,代码来源:test_enkf_obs.py

示例4: test_asList

    def test_asList(self):
        v = IntVector()
        v[0] = 100
        v[1] = 10
        v[2] = 1

        l = v.asList()
        self.assertListEqual( l , [100,10,1] )
开发者ID:YingfangZhou,项目名称:ert,代码行数:8,代码来源:test_vectors.py

示例5: test_element_sum

    def test_element_sum(self):
        dv = DoubleVector()
        iv = IntVector()
        for i in range(10):
            dv.append(i+1)
            iv.append(i+1)

        self.assertEqual( dv.elementSum() , 55 )
        self.assertEqual( iv.elementSum() , 55 )
开发者ID:YingfangZhou,项目名称:ert,代码行数:9,代码来源:test_vectors.py

示例6: test_activeList

    def test_activeList(self):
        active_list = IntVector.active_list("1,10,100-105")
        self.assertTrue(len(active_list) == 8)
        self.assertTrue(active_list[0] == 1)
        self.assertTrue(active_list[2] == 100)
        self.assertTrue(active_list[7] == 105)

        active_list = IntVector.active_list("1,10,100-105X")
        self.assertFalse(active_list)
开发者ID:blattms,项目名称:ert,代码行数:9,代码来源:test_vectors.py

示例7: test_range

    def test_range(self):
        v = IntVector( )
        v[10] = 99

        with self.assertRaises(ValueError):
            v.initRange(1,2,0)

        self.range_test(v , 0 , 5 , 1)
        self.range_test(v , 0,100,3)
        self.range_test(v,0,100,-3)
开发者ID:eoia,项目名称:ert,代码行数:10,代码来源:test_vectors.py

示例8: report_index_list

 def report_index_list( self ):
     """
     Internal function for working with report_steps.
     """
     first_report = self.first_report
     last_report  = self.last_report
     index_list = IntVector()
     for report_step in range( first_report , last_report + 1):
         time_index = EclSum.cNamespace().get_report_end( self , report_step )
         index_list.append( time_index )
     return index_list
开发者ID:shulNN,项目名称:ert,代码行数:11,代码来源:ecl_sum.py

示例9: test_count_equal

    def test_count_equal(self):
        v = IntVector(default_value=77)
        v[0] = 1
        v[10] = 1
        v[20] = 1
        self.assertEqual(v.countEqual(1), 3)

        v = DoubleVector(default_value=77)
        v[0] = 1
        v[10] = 1
        v[20] = 1
        self.assertEqual(v.countEqual(1), 3)
开发者ID:Thif,项目名称:ert-1,代码行数:12,代码来源:test_vectors.py

示例10: test_activeList

    def test_activeList(self):
        active_list = IntVector.active_list("1,10,100-105")
        self.assertTrue(len(active_list) == 8)
        self.assertTrue(active_list[0] == 1)
        self.assertTrue(active_list[2] == 100)
        self.assertTrue(active_list[7] == 105)
        self.assertEqual( active_list.count(100) , 1)
        active_list.append(100)
        active_list.append(100)
        self.assertEqual( active_list.count(100) , 3)

        active_list = IntVector.active_list("1,10,100-105X")
        self.assertFalse(active_list)
开发者ID:YingfangZhou,项目名称:ert,代码行数:13,代码来源:test_vectors.py

示例11: test_vector_operations_with_exceptions

    def test_vector_operations_with_exceptions(self):
        iv1 = IntVector()
        iv1.append(1)
        iv1.append(2)
        iv1.append(3)

        iv2 = IntVector()
        iv2.append(4)
        iv2.append(5)

        dv1 = DoubleVector()
        dv1.append(0.5)
        dv1.append(0.75)
        dv1.append(0.25)

        #Size mismatch
        with self.assertRaises(ValueError):
            iv3 = iv1 + iv2

        #Size mismatch
        with self.assertRaises(ValueError):
            iv3 = iv1 * iv2

        #Type mismatch
        with self.assertRaises(TypeError):
            iv1 += dv1

        #Type mismatch
        with self.assertRaises(TypeError):
            iv1 *= dv1
开发者ID:YingfangZhou,项目名称:ert,代码行数:30,代码来源:test_vectors.py

示例12: test_obs_block_scale_std

    def test_obs_block_scale_std(self):
        with ErtTestContext("obs_test_scale", self.config_file) as test_context:
            ert = test_context.getErt()
            fs = ert.getEnkfFsManager().getCurrentFileSystem()
            active_list = IntVector( )
            active_list.initRange(0 , ert.getEnsembleSize() , 1 )

            obs = ert.getObservations()
            obs_data = LocalObsdata( "OBSxx" , obs )
            obs_vector = obs["WWCT:OP_1"]
            obs_data.addObsVector( obs_vector )
            scale_factor = obs.scaleCorrelatedStd( fs , obs_data , active_list )

            for obs_node in obs_vector:
                for index in range(len(obs_node)):
                    self.assertEqual( scale_factor , obs_node.getStdScaling( index ))
开发者ID:Ensembles,项目名称:ert,代码行数:16,代码来源:test_enkf_obs.py

示例13: active_list

 def active_list(self):
     """
     IntVector instance with active indices in the region.
     """
     c_ptr = cfunc.get_active_list( self )
     active_list = IntVector.asPythonReference( c_ptr , self )
     return active_list
开发者ID:JacobStoren,项目名称:ert,代码行数:7,代码来源:ecl_region.py

示例14: create_range_test

    def create_range_test(self,v,a,b,d):
        v = IntVector.createRange( a,b,d )
        r = range(a,b,d)

        self.assertEqual(len(v) , len(r))
        for a,b in zip(v,r):
            self.assertEqual(a,b)
开发者ID:jonerduarte,项目名称:ert,代码行数:7,代码来源:test_vectors.py

示例15: __init__

    def __init__(self , obs_key , data_config , scalar_value = None , obs_file = None , data_index = None):
        c_pointer = GenObservation.cNamespace().alloc( data_config , obs_key )
        super(GenObservation, self).__init__(c_pointer)

        if scalar_value is None and obs_file is None:
            raise ValueError("Exactly one the scalar_value and obs_file arguments must be present")

        if scalar_value is not None and obs_file is not None:
            raise ValueError("Exactly one the scalar_value and obs_file arguments must be present")

        if obs_file is not None:
            if not os.path.isfile( obs_file ):
                raise IOError("The file with observation data:%s does not exist" % obs_file )
            else:
                GenObservation.cNamespace().load( self , obs_file )
        else:
            obs_value , obs_std = scalar_value
            GenObservation.cNamespace().scalar_set( self , obs_value , obs_std )

        if not data_index is None:
            if os.path.isfile( data_index ):
                GenObservation.cNamespace().load_data_index( self , data_index )
            else:
                index_list = IntVector.active_list( data_index )
                GenObservation.cNamespace().add_data_index( self , index_list )
开发者ID:agchitu,项目名称:ert,代码行数:25,代码来源:gen_observation.py


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