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


Python summary.EclSum类代码示例

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


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

示例1: test_invalid

    def test_invalid(self):
        case = create_case()
        with TestAreaContext("sum_invalid"):
            case.fwrite( )
            with open("CASE.txt", "w") as f:
                f.write("No - this is not EclKW file ....")

            with self.assertRaises( IOError ):
                case2 = EclSum.load( "CSV.SMSPEC" , "CASE.txt" )

            with self.assertRaises( IOError ):
                case2 = EclSum.load( "CASE.txt" , "CSV.UNSMRY" )

            kw1 = EclKW("TEST1", 30, EclDataType.ECL_INT)
            kw2 = EclKW("TEST2", 30, EclDataType.ECL_INT)

            with openFortIO( "CASE.KW" , FortIO.WRITE_MODE) as f:
                kw1.fwrite( f )
                kw2.fwrite( f )

            with self.assertRaises( IOError ):
                case2 = EclSum.load( "CSV.SMSPEC" , "CASE.KW")

            with self.assertRaises( IOError ):
                case2 = EclSum.load( "CASE.KW" , "CSV.UNSMRY" )
开发者ID:,项目名称:,代码行数:25,代码来源:

示例2: test_identify_var_type

    def test_identify_var_type(self):
        self.assertEnumIsFullyDefined( EclSumVarType , "ecl_smspec_var_type" , "lib/include/ert/ecl/smspec_node.h")
        self.assertEqual( EclSum.varType( "WWCT:OP_X") , EclSumVarType.ECL_SMSPEC_WELL_VAR )
        self.assertEqual( EclSum.varType( "RPR") , EclSumVarType.ECL_SMSPEC_REGION_VAR )
        self.assertEqual( EclSum.varType( "WNEWTON") , EclSumVarType.ECL_SMSPEC_MISC_VAR )
        self.assertEqual( EclSum.varType( "AARQ:4") , EclSumVarType.ECL_SMSPEC_AQUIFER_VAR )

        case = createEclSum("CSV" , [("FOPT", None , 0, "SM3") ,
                                     ("FOPR" , None , 0, "SM3/DAY"),
                                     ("AARQ" , None , 10, "???"),
                                    ("RGPT" , None  ,1, "SM3")])

        node1 = case.smspec_node( "FOPT" )
        self.assertEqual( node1.varType( ) , EclSumVarType.ECL_SMSPEC_FIELD_VAR )

        node2 = case.smspec_node( "AARQ:10" )
        self.assertEqual( node2.varType( ) , EclSumVarType.ECL_SMSPEC_AQUIFER_VAR )
        self.assertEqual( node2.getNum( ) , 10 )

        node3 = case.smspec_node("RGPT:1")
        self.assertEqual( node3.varType( ) , EclSumVarType.ECL_SMSPEC_REGION_VAR )
        self.assertEqual( node3.getNum( ) , 1 )
        self.assertTrue( node3.isTotal( ))

        self.assertLess( node1, node3 )
        self.assertGreater( node2, node3 )
        self.assertEqual( node1, node1 )
        self.assertNotEqual( node1, node2 )

        with self.assertRaises(TypeError):
            a = node1 < 1
开发者ID:,项目名称:,代码行数:31,代码来源:

示例3: test_segment

 def test_segment(self):
     sum = EclSum(self.createTestPath("Statoil/ECLIPSE/Oseberg/F8MLT/F8MLT-F4"))
     segment_vars = sum.keys("SOFR:F-8:*")
     self.assertIn("SOFR:F-8:1", segment_vars)
     for var in segment_vars:
         tmp = var.split(":")
         nr = int(tmp[2])
         self.assertTrue(nr >= 0)
开发者ID:OPM,项目名称:ResInsight,代码行数:8,代码来源:test_sum_statoil.py

示例4: test_load_case

    def test_load_case(self):
        path = os.path.join(self.TESTDATA_ROOT, "local/ECLIPSE/cp_simple3/SIMPLE_SUMMARY3")
        case = EclSum( path )
        self.assertFloatEqual(case.sim_length, 545.0)

        fopr = case.numpy_vector("FOPR")
        for time_index,value in enumerate(fopr):
            self.assertEqual(fopr[time_index], value)
开发者ID:OPM,项目名称:ResInsight,代码行数:8,代码来源:test_sum.py

示例5: test_Heidrun

    def test_Heidrun(self):
        sum = EclSum( self.createTestPath("Statoil/ECLIPSE/Heidrun/Summary/FF12_2013B3_CLEAN_RS"))
        self.assertEqual( 452 , len(sum))
        self.assertFloatEqual( 1.8533144e+8 , sum.last_value("FOPT"))

        trange = sum.timeRange( start = datetime.date( 2015 , 1 , 1), interval = "1M")
        self.assertTrue( trange[0] == datetime.date( 2016 , 2 , 1 ))
        for t in trange:
            sum.get_interp( "FOPT" , date = t )
开发者ID:OPM,项目名称:ResInsight,代码行数:9,代码来源:test_sum_statoil.py

示例6: EclCase

class EclCase(object):

    def __init__(self, case):
        self.case = case

        self.grid = None
        self.restart = None
        self.init = None
        self.summary = None

        self.loadSummary()


    def __contains__(self, key):
        return key in self.summary


    def keys(self):
        return self.summary.keys()


    def wells(self):
        return self.summary.wells()

    def load_summary(self):
        self.summary = EclSum(self.case)


    def start_time_equal(self, other):
        if self.summary.getDataStartTime() == other.summary.getDataStartTime():
            return True
        else:
            return False

    def end_time_equal(self, other):
        if self.summary.getEndTime() == other.summary.getEndTime():
            return True
        else:
            return False


    def cmp_summary_vector(self, other, key, sample=100):
        if key in self and key in other:
            days_total = min(self.summary.getSimulationLength(), other.summary.getSimulationLength())
            dt = days_total / (sample - 1)
            days = [ x * dt for x in range(sample) ]

            ref_data = self.summary.get_interp_vector(key, days_list=days)
            test_data = other.summary.get_interp_vector(key, days_list=days)
            diff_data = ref_data - test_data

            ref_sum = sum(ref_data)
            diff_sum = sum(abs(diff_data))
            return (diff_sum, ref_sum)
        else:
            raise KeyError("Key:%s was not present in both cases" % key)
开发者ID:OPM,项目名称:ResInsight,代码行数:56,代码来源:ecl_cmp.py

示例7: test_stringlist_setitem

 def test_stringlist_setitem(self):
     sum = EclSum(self.case)
     wells = sum.wells()
     wells[0] = "Bjarne"
     well0 = wells[0]
     self.assertTrue(well0 == "Bjarne")
     self.assertTrue(wells[0] == "Bjarne")
     wells[0] = "XXX"
     self.assertTrue(well0 == "Bjarne")
     self.assertTrue(wells[0] == "XXX")
开发者ID:OPM,项目名称:ResInsight,代码行数:10,代码来源:test_sum_statoil.py

示例8: test_different_names

    def test_different_names(self):
        case = create_case()
        with TestAreaContext("sum_different"):
            case.fwrite( )
            shutil.move("CSV.SMSPEC" , "CSVX.SMSPEC")
            with self.assertRaises(IOError):
                case2 = EclSum.load( "Does/not/exist" , "CSV.UNSMRY")

            with self.assertRaises(IOError):
                case2 = EclSum.load( "CSVX.SMSPEC" , "CSVX.UNSMRY")

            case2 = EclSum.load( "CSVX.SMSPEC" , "CSV.UNSMRY" )
            self.assert_solve( case2 )
            self.assertEqual(case.unit("FOPR"), "SM3/DAY")
开发者ID:,项目名称:,代码行数:14,代码来源:

示例9: test_run_default

    def test_run_default(self):
        with TestAreaContext(""):
            self.case.fwrite()

            # Too few arguments
            with self.assertRaises(CallError):
                subprocess.check_call([self.script])

            # Too few arguments
            with self.assertRaises(CallError):
                subprocess.check_call([self.script, "CSV"])

            # Invalid first arguments
            with self.assertRaises(CallError):
                subprocess.check_call([self.script, "DOES_NOT_EXIST", "OUTPUT"])

            # Should run OK:
            subprocess.check_call([self.script, "CSV", "OUTPUT"])
            output_case = EclSum("OUTPUT")
            self.assertEqual( output_case.get_data_start_time(), self.case.get_data_start_time())
            self.assertEqual( output_case.get_end_time(), self.case.get_end_time())

            with self.assertRaises(CallError):
                subprocess.check_call([self.script, "CSV", "OUTPUT", "--refcase=does/not/exist"])

            refcase = create_case( num_mini_step = 7, case = "REFCASE")
            refcase.fwrite()
            subprocess.check_call([self.script, "CSV", "OUTPUT", "--refcase=REFCASE"])
            output_case = EclSum("OUTPUT")
            self.assertEqual( output_case.get_data_start_time(), refcase.get_data_start_time())
            self.assertEqual( output_case.get_end_time(), refcase.get_end_time())
            time_points = output_case.alloc_time_vector(False)
            t1 = output_case.alloc_time_vector(False)
            t2 = refcase.alloc_time_vector(False)
            self.assertEqual(t1,t2)
开发者ID:OPM,项目名称:ResInsight,代码行数:35,代码来源:test_summary_resample.py

示例10: EclSumVectorTest

class EclSumVectorTest(EclTest):


    def setUp(self):
        self.test_file = self.createTestPath("Statoil/ECLIPSE/Gurbat/ECLIPSE.SMSPEC")
        self.ecl_sum = EclSum(self.test_file)

    def test_reportOnly_warns(self):
        with warnings.catch_warnings(record=True) as w:
            warnings.simplefilter("always")

            vector = EclSumVector(self.ecl_sum, "FOPT", True)
            assert len(w) == 1
            assert issubclass(w[-1].category, DeprecationWarning)


    def test_basic(self):
        self.assertEqual(512, len(self.ecl_sum.keys()))
        pfx = 'EclSum(name'
        self.assertEqual(pfx, repr(self.ecl_sum)[:len(pfx)])
        it = iter(self.ecl_sum)
        #t = self.ecl_sum[it.next()] # EclSumVector
        t = self.ecl_sum[next(it)] # EclSumVector
        self.assertEqual(63, len(t))
        self.assertEqual('BARSA', t.unit)
        pfx = 'EclSumVector(key = '
        self.assertEqual(pfx, repr(t)[:len(pfx)])
开发者ID:,项目名称:,代码行数:27,代码来源:

示例11: test_writer

    def test_writer(self):
        writer = EclSum.writer("CASE" , datetime.date( 2000 , 1 , 1) , 10 , 10 , 5)
        self.assertIsInstance(self.ecl_sum, EclSum)


        writer.addVariable( "FOPT" )
        self.assertTrue( writer.has_key( "FOPT" ))

        writer.addTStep( 1 , 100 )
开发者ID:OPM,项目名称:ResInsight,代码行数:9,代码来源:test_sum_statoil.py

示例12: test_labscale

    def test_labscale(self):
        case = self.createTestPath("Statoil/ECLIPSE/LabScale/HDMODEL")
        sum = EclSum(case, lazy_load=True)
        self.assertEqual(sum.getStartTime(), datetime.datetime(2013,1,1,0,0,0))
        self.assertEqual(sum.getEndTime()  , datetime.datetime(2013,1,1,19,30,0))
        self.assertFloatEqual(sum.getSimulationLength(), 19.50)

        sum = EclSum(case, lazy_load=False)
        self.assertEqual(sum.getStartTime(), datetime.datetime(2013,1,1,0,0,0))
        self.assertEqual(sum.getEndTime()  , datetime.datetime(2013,1,1,19,30,0))
        self.assertFloatEqual(sum.getSimulationLength(), 19.50)
开发者ID:OPM,项目名称:ResInsight,代码行数:11,代码来源:test_ecl_sum.py

示例13: test_eval

    def test_eval(self):
        npv = EclNPV(self.case)
        npv.compile("[FOPT]")
        npv1 = npv.evalNPV()

        npv2 = 0
        sum = EclSum(self.case)
        trange = sum.timeRange()
        fopr = sum.blockedProduction("FOPT" , trange)
        for v in fopr:
            npv2 += v
        self.assertAlmostEqual( npv1 , npv2 )
        
        npv.compile("[FOPT] - 0.5*[FOPT] - 0.5*[FOPT]")
        npv1 = npv.evalNPV()
        self.assertTrue( abs(npv1) < 1e-2 )

        npv.compile("[WOPT:OP_1] - 0.5*[WOPT:OP_1] - 0.5*[WOPT:OP_1]")
        npv1 = npv.evalNPV()
        self.assertTrue( abs(npv1) < 1e-2 )
开发者ID:OPM,项目名称:ResInsight,代码行数:20,代码来源:test_npv.py

示例14: test_total_and_rate

    def test_total_and_rate(self):
        self.assertTrue( EclSum.is_total("FOPT"))
        self.assertTrue( EclSum.is_total("WWPT:OP_3"))
        self.assertFalse( EclSum.is_total("RPR:2"))

        self.assertTrue( EclSum.is_rate("WOPR:OP_4"))
        self.assertFalse( EclSum.is_rate("BPR:123"))
        self.assertTrue(EclSum.is_rate("FWIR"))
开发者ID:OPM,项目名称:ResInsight,代码行数:8,代码来源:test_sum.py

示例15: test_restart_abs_path

    def test_restart_abs_path(self):
        with TestAreaContext("restart_test"):
           history = create_case(case = "HISTORY")
           history.fwrite()

           pred_path = "prediction"
           create_prediction(history, pred_path)

           pred = EclSum(os.path.join(pred_path, "PREDICTION"))
           # The restart case has a maximum length of 72 characters, depending
           # on the path used for $TMP and so on we do not really know here if
           # the restart_case has been set or not.
           if pred.restart_case:
               self.assertTrue(isinstance(pred.restart_case, EclSum))
               self.assertEqual(pred.restart_case.case, os.path.join(os.getcwd(), history.case))
               self.assertEqual(pred.restart_step, history.last_report)

               length = pred.sim_length
               pred_times = pred.alloc_time_vector(False)
               hist_times = history.alloc_time_vector(False)

               for index in range(len(hist_times)):
                   self.assertEqual(hist_times[index], pred_times[index])
开发者ID:,项目名称:,代码行数:23,代码来源:


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