本文整理汇总了Python中ert.ecl.EclSum.alloc_time_vector方法的典型用法代码示例。如果您正苦于以下问题:Python EclSum.alloc_time_vector方法的具体用法?Python EclSum.alloc_time_vector怎么用?Python EclSum.alloc_time_vector使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ert.ecl.EclSum
的用法示例。
在下文中一共展示了EclSum.alloc_time_vector方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: SumTest
# 需要导入模块: from ert.ecl import EclSum [as 别名]
# 或者: from ert.ecl.EclSum import alloc_time_vector [as 别名]
#.........这里部分代码省略.........
del wells
self.assertTrue(well1 == "OP_1")
def test_stringlist_reference(self):
sum = EclSum(self.case)
wells = sum.wells()
self.assertListEqual([well for well in wells], ['OP_1', 'OP_2', 'OP_3', 'OP_4', 'OP_5', 'WI_1', 'WI_2', 'WI_3'])
self.assertIsInstance(wells, StringList)
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")
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)
def test_return_types(self):
self.assertIsInstance(self.ecl_sum.alloc_time_vector(True), TimeVector)
key_index = self.ecl_sum.get_general_var_index("FOPT")
self.assertIsInstance(self.ecl_sum.alloc_data_vector(key_index, True), DoubleVector)
def test_timeRange(self):
sum = EclSum(self.case)
with self.assertRaises(TypeError):
trange = sum.timeRange(interval = "1")
trange = sum.timeRange(interval = "1X")
trange = sum.timeRange(interval = "YY")
trange = sum.timeRange(interval = "MY")
with self.assertRaises(ValueError):
trange = sum.timeRange( start = datetime.datetime(2000,1,1) , end = datetime.datetime(1999,1,1) )
sim_start = datetime.datetime(2000, 1, 1, 0, 0, 0)
sim_end = datetime.datetime(2004, 12, 31, 0, 0, 0)
trange = sum.timeRange( interval = "1Y")
self.assertTrue( trange[0] == datetime.date( 2000 , 1 , 1 ))
self.assertTrue( trange[1] == datetime.date( 2001 , 1 , 1 ))
self.assertTrue( trange[2] == datetime.date( 2002 , 1 , 1 ))
self.assertTrue( trange[3] == datetime.date( 2003 , 1 , 1 ))
self.assertTrue( trange[4] == datetime.date( 2004 , 1 , 1 ))
self.assertTrue( trange[5] == datetime.date( 2005 , 1 , 1 ))
trange = sum.timeRange( interval = "1M")
self.assertTrue( trange[0] == datetime.date( 2000 , 1 , 1 ))
self.assertTrue( trange[-1] == datetime.date( 2005 , 1 , 1 ))
trange = sum.timeRange( start = datetime.date( 2002 , 1 , 15), interval = "1M")
self.assertTrue( trange[0] == datetime.date( 2002 , 1 , 1 ))
self.assertTrue( trange[-1] == datetime.date( 2005 , 1 , 1 ))
示例2: SumTest
# 需要导入模块: from ert.ecl import EclSum [as 别名]
# 或者: from ert.ecl.EclSum import alloc_time_vector [as 别名]
#.........这里部分代码省略.........
self.assertIsNotNone(base)
self.assertIsNotNone(pred)
def test_case1(self):
self.assertTrue(self.ecl_sum.path == self.createTestPath(path))
self.assertTrue(self.ecl_sum.base == base)
self.assertTrue(self.ecl_sum.case == self.createTestPath(case))
self.assertTrue(self.ecl_sum.abs_path == self.createTestPath(path))
def test_case2(self):
cwd = os.getcwd()
os.chdir(self.createTestPath(path))
sum = EclSum(base)
self.assertIsNone(sum.path)
self.assertTrue(sum.base == base)
self.assertTrue(sum.case == base)
self.assertTrue(sum.abs_path == self.createTestPath(path))
os.chdir(cwd)
def test_var_properties(self):
sum = self.ecl_sum
self.assertRaises(KeyError, sum.smspec_node, "BJARNE")
node = sum.smspec_node("FOPT")
self.assertTrue(node.is_total)
self.assertFalse(node.is_historical)
node = sum.smspec_node("FOPR")
self.assertFalse(node.is_total)
self.assertFalse(node.is_historical)
self.assertTrue(node.keyword == "FOPR")
node = sum.smspec_node("FOPRH")
self.assertFalse(node.is_total)
self.assertTrue(node.is_historical)
self.assertTrue(node.is_rate)
self.assertTrue(node.keyword == "FOPRH")
node = sum.smspec_node("WOPR:OP_1")
self.assertFalse(node.is_total)
self.assertTrue(node.is_rate)
self.assertTrue(node.keyword == "WOPR")
node = sum.smspec_node("WOPT:OP_1")
self.assertTrue(node.is_total)
self.assertFalse(node.is_rate)
self.assertTrue(node.unit == "SM3")
self.assertTrue(node.wgname == "OP_1")
self.assertTrue(node.keyword == "WOPT")
self.assertTrue(sum.unit("FOPR") == "SM3/DAY")
node = sum.smspec_node("FOPTH")
self.assertTrue(node.is_total)
self.assertFalse(node.is_rate)
self.assertIsNone(node.wgname)
node = sum.smspec_node("FOPTH")
self.assertIsNone(node.num)
node = sum.smspec_node("BPR:1095")
self.assertEquals(node.num, 1095)
def test_stringlist_gc(self):
sum = EclSum(self.case)
wells = sum.wells()
well1 = wells[0]
del wells
self.assertTrue(well1 == "OP_1")
def test_stringlist_reference(self):
sum = EclSum(self.case)
wells = sum.wells()
self.assertAlmostEqualList(wells, ["OP_1", "OP_2", "OP_3", "OP_4", "OP_5", "WI_1", "WI_2", "WI_3"])
self.assertIsInstance(wells, StringList)
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")
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)
def test_return_types(self):
self.assertIsInstance(self.ecl_sum.alloc_time_vector(True), TimeVector)
key_index = self.ecl_sum.get_general_var_index("FOPT")
self.assertIsInstance(self.ecl_sum.alloc_data_vector(key_index, True), DoubleVector)