本文整理汇总了Python中ert.ecl.EclSum类的典型用法代码示例。如果您正苦于以下问题:Python EclSum类的具体用法?Python EclSum怎么用?Python EclSum使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了EclSum类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: 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)
示例2: test_identify_var_type
def test_identify_var_type(self):
self.assertEnumIsFullyDefined( EclSumVarType , "ecl_smspec_var_type" , "libecl/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 )
case = createEclSum("CSV" , [("FOPT", None , 0) , ("FOPR" , None , 0)])
node = case.smspec_node( "FOPT" )
self.assertEqual( node.varType( ) , EclSumVarType.ECL_SMSPEC_FIELD_VAR )
示例3: 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.get_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 )
示例4: 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")
示例5: 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 loadSummary(self):
self.summary = EclSum( self.case )
def startTimeEqual(self , other):
if self.summary.getDataStartTime() == other.summary.getDataStartTime():
return True
else:
return False
def endTimeEqual(self , other):
if self.summary.getEndTime() == other.summary.getEndTime():
return True
else:
return False
def cmpSummaryVector(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)
示例6: EclSumTest
class EclSumTest(ExtendedTestCase):
def setUp(self):
self.test_file = self.createTestPath("Statoil/ECLIPSE/Gurbat/ECLIPSE.SMSPEC")
self.ecl_sum = EclSum(self.test_file)
def test_time_range_year(self):
real_range = self.ecl_sum.timeRange(interval="1y", extend_end = False)
extended_range = self.ecl_sum.timeRange(interval="1y", extend_end = True)
assert real_range[-1] < extended_range[-1]
def test_time_range_day(self):
real_range = self.ecl_sum.timeRange(interval = "1d", extend_end = False)
extended_range = self.ecl_sum.timeRange(interval = "1d", extend_end = True)
assert real_range[-1] == extended_range[-1]
def test_time_range_month(self):
real_range = self.ecl_sum.timeRange(interval = "1m", extend_end = False)
extended_range = self.ecl_sum.timeRange(interval = "1m", extend_end = True)
assert real_range[-1] < extended_range[-1]
def test_dump_csv_line(self):
ecl_sum_vector = EclSumKeyWordVector(self.ecl_sum)
ecl_sum_vector.addKeywords("F*")
with self.assertRaises(KeyError):
ecl_sum_vector.addKeyword("MISSING")
dtime = datetime.datetime( 2002 , 01 , 01 , 0 , 0 , 0 )
with TestAreaContext("EclSum/csv_dump"):
test_file_name = self.createTestPath("dump.csv")
outputH = open(test_file_name , "w")
self.ecl_sum.dumpCSVLine( dtime, ecl_sum_vector, outputH)
assert os.path.isfile(test_file_name)
示例7: test_creation
def test_creation(self):
ecl_sum = EclSum.writer("TEST", datetime(2010, 1, 1), 10, 10, 10)
ecl_sum.addVariable("FOPT")
ecl_sum.addVariable("FOPR")
smspec = ecl_sum.cNamespace().get_smspec(ecl_sum)
test_data = [(1, 0, 10), (1, 1, 20), (1, 2, 30), (2, 0, 40)]
for report_step, mini_step, sim_days in test_data:
ecl_sum_tstep = EclSumTStep(report_step, mini_step, sim_days, smspec)
self.assertEqual(ecl_sum_tstep.getSimDays(), sim_days)
self.assertEqual(ecl_sum_tstep.getReport(), report_step)
self.assertEqual(ecl_sum_tstep.getMiniStep(), mini_step)
self.assertTrue("FOPT" in ecl_sum_tstep)
self.assertTrue("FOPR" in ecl_sum_tstep)
self.assertFalse("WWCT" in ecl_sum_tstep)
random_float = random.random()
ecl_sum_tstep["FOPT"] = random_float
ecl_sum_tstep["FOPR"] = random_float + 1
self.assertAlmostEqual(random_float, ecl_sum_tstep["FOPT"], places=5)
self.assertAlmostEqual(random_float + 1, ecl_sum_tstep["FOPR"], places=5)
with self.assertRaises(KeyError):
ecl_sum_tstep["FROPR"] = 2
with self.assertRaises(KeyError):
value = ecl_sum_tstep["FROPR"]
示例8: 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)
示例9: 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 )
示例10: test_timeRange
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))
trange = sum.timeRange(start=datetime.date(2002, 1, 15), end=datetime.date(2003, 1, 15), interval="1M")
self.assertTrue(trange[0] == datetime.date(2002, 1, 1))
self.assertTrue(trange[-1] == datetime.date(2003, 2, 1))
trange = sum.timeRange(
start=datetime.date(2002, 1, 15), end=datetime.datetime(2003, 1, 15, 0, 0, 0), interval="1M"
)
self.assertTrue(trange[0] == datetime.date(2002, 1, 1))
self.assertTrue(trange[-1] == datetime.date(2003, 2, 1))
示例11: 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.get_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 )
with TestAreaContext("csv/export"):
sum.exportCSV("file.csv")
input_file = csv.DictReader( open("file.csv"))
for row in input_file:
keys = sum.keys( pattern = "W*")
keys |= sum.keys( pattern = "G")
for key in keys:
self.assertTrue( key in row )
break
示例12: test_restart_mapping
def test_restart_mapping(self):
history = EclSum( self.createTestPath( "Statoil/ECLIPSE/SummaryRestart/iter-1/NOR-2013A_R007-0") )
total = EclSum( self.createTestPath( "Statoil/ECLIPSE/SummaryRestart/Prediction/NOR-2013A_R007_PRED-0") , include_restart = True)
history_dates = history.get_dates( )
total_dates = total.get_dates( )
for i in range(len(history_dates)):
self.assertEqual( history_dates[i] , total_dates[i] )
keys = history.keys( pattern = "W*")
for key in keys:
if key in total:
self.assertEqual( history.iget( key , 5 ) , total.iget( key , 5 ))
self.assertFalse( "WGPR:NOT_21_D" in history )
self.assertTrue( "WGPR:NOT_21_D" in total )
self.assertEqual( total.iget( "WGPR:NOT_21_D", 5) , 0) # Default value
示例13: createEclSum
def createEclSum( case , keys , start = datetime.date(2010 , 1, 1) , sim_length_days = 5 * 365 , num_report_step = 5, num_mini_step = 10, dims = (20,10,5) , func_table = {}):
ecl_sum = EclSum.writer(case , start , dims[0] , dims[1] , dims[2])
var_list = []
for (kw,wgname,num) in keys:
var_list.append( ecl_sum.addVariable( kw , wgname = wgname , num = num) )
report_step_length = sim_length_days / num_report_step
mini_step_length = report_step_length / num_mini_step
for report_step in range(num_report_step):
for mini_step in range(num_mini_step):
days = report_step * report_step_length + mini_step * mini_step_length
t_step = ecl_sum.addTStep( report_step + 1 , sim_days = days )
for var in var_list:
key = var.getKey1( )
if key in func_table:
t_step[key] = func( days )
else:
t_step[key] = mock_func( ecl_sum , key , days)
return ecl_sum
示例14: EclSumVectorTest
class EclSumVectorTest(ExtendedTestCase):
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
self.assertEqual(63, len(t))
self.assertEqual("BARSA", t.unit)
pfx = "EclSumVector(key = "
self.assertEqual(pfx, repr(t)[: len(pfx)])
示例15: EclSumTest
class EclSumTest(ExtendedTestCase):
def setUp(self):
self.test_file = self.createTestPath("Statoil/ECLIPSE/Gurbat/ECLIPSE.SMSPEC")
self.ecl_sum = EclSum(self.test_file)
def test_time_range_year(self):
real_range = self.ecl_sum.timeRange(interval="1y", extend_end = False)
extended_range = self.ecl_sum.timeRange(interval="1y", extend_end = True)
assert real_range[-1] < extended_range[-1]
def test_time_range_day(self):
real_range = self.ecl_sum.timeRange(interval = "1d", extend_end = False)
extended_range = self.ecl_sum.timeRange(interval = "1d", extend_end = True)
assert real_range[-1] == extended_range[-1]
def test_time_range_month(self):
real_range = self.ecl_sum.timeRange(interval = "1m", extend_end = False)
extended_range = self.ecl_sum.timeRange(interval = "1m", extend_end = True)
assert real_range[-1] < extended_range[-1]