本文整理汇总了Python中ecl.eclfile.EclKW.safe_div方法的典型用法代码示例。如果您正苦于以下问题:Python EclKW.safe_div方法的具体用法?Python EclKW.safe_div怎么用?Python EclKW.safe_div使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ecl.eclfile.EclKW
的用法示例。
在下文中一共展示了EclKW.safe_div方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_fmu_stat_workflow
# 需要导入模块: from ecl.eclfile import EclKW [as 别名]
# 或者: from ecl.eclfile.EclKW import safe_div [as 别名]
def test_fmu_stat_workflow(self):
N = 100
global_size = 100
active_size = 50
with TestAreaContext("FMU_FILES"):
for i in range(N):
permx = EclKW("PERMX", active_size, EclDataType.ECL_FLOAT)
poro = EclKW("PORO", active_size, EclDataType.ECL_FLOAT)
porv = EclKW("PORV", global_size, EclDataType.ECL_FLOAT)
porv.assign(0)
for g in random.sample( range(global_size), active_size):
porv[g] = 1
permx.assign(random.random())
poro.assign(random.random())
with openFortIO("TEST%d.INIT" % i, FortIO.WRITE_MODE) as f:
permx.fwrite(f)
poro.fwrite(f)
porv.fwrite(f)
mean_permx = EclKW("PERMX", global_size, EclDataType.ECL_FLOAT)
std_permx = EclKW("PERMX", global_size, EclDataType.ECL_FLOAT)
mean_poro = EclKW("PORO", global_size, EclDataType.ECL_FLOAT)
std_poro = EclKW("PORO", global_size, EclDataType.ECL_FLOAT)
count = EclKW("COUNT", global_size, EclDataType.ECL_INT)
for i in range(N):
f = EclFile("TEST%d.INIT" % i)
porv = f["PORV"][0]
permx = f["PERMX"][0]
poro = f["PORO"][0]
actnum = porv.create_actnum()
global_permx = permx.scatter_copy( actnum )
mean_permx += global_permx
std_permx.add_squared( global_permx)
global_poro = poro.scatter_copy( actnum )
mean_poro += global_poro
std_poro.add_squared( global_poro)
count += actnum
mean_permx.safe_div(count)
std_permx.safe_div(count)
std_permx -= mean_permx * mean_permx
std_permx.isqrt()
mean_poro.safe_div(count)
std_poro.safe_div(count)
std_poro -= mean_poro * mean_poro
std_poro.isqrt()
示例2: test_safe_div
# 需要导入模块: from ecl.eclfile import EclKW [as 别名]
# 或者: from ecl.eclfile.EclKW import safe_div [as 别名]
def test_safe_div(self):
kw1 = EclKW("SOURCE", 10, EclDataType.ECL_INT)
kw2 = EclKW("XXX", 11, EclDataType.ECL_INT)
with self.assertRaises(ValueError):
kw1.safe_div(kw2)
kw1 = EclKW("SOURCE", 2, EclDataType.ECL_FLOAT)
kw1.assign(10)
kw2 = EclKW("DIV", 2, EclDataType.ECL_INT)
kw2[0] = 0
kw2[1] = 2
kw1.safe_div( kw2 )
self.assertEqual(kw1[0], 10)
self.assertEqual(kw1[1], 5)