mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Python: return time step arrays directly rather than struct containing time step arrays
This commit is contained in:
parent
4701ea5134
commit
57e282eb7e
@ -14,7 +14,7 @@ grid = case.grid(index = 0)
|
|||||||
timeSteps = case.timeSteps()
|
timeSteps = case.timeSteps()
|
||||||
|
|
||||||
averages = []
|
averages = []
|
||||||
for i in range(0, len(timeSteps.dates)):
|
for i in range(0, len(timeSteps)):
|
||||||
resultChunks = case.properties.activeCellProperty('DYNAMIC_NATIVE', 'SOIL', i)
|
resultChunks = case.properties.activeCellProperty('DYNAMIC_NATIVE', 'SOIL', i)
|
||||||
mysum = 0.0
|
mysum = 0.0
|
||||||
count = 0
|
count = 0
|
||||||
|
@ -23,7 +23,7 @@ porvArray = []
|
|||||||
for porvChunk in porvChunks:
|
for porvChunk in porvChunks:
|
||||||
porvArray.append(porvChunk)
|
porvArray.append(porvChunk)
|
||||||
|
|
||||||
for i in range (0, len(timeStepInfo.dates)):
|
for i in range (0, len(timeStepInfo)):
|
||||||
soilChunks = case.properties.activeCellProperty('DYNAMIC_NATIVE', 'SOIL', i)
|
soilChunks = case.properties.activeCellProperty('DYNAMIC_NATIVE', 'SOIL', i)
|
||||||
input_iterator = createResult(soilChunks, iter(porvArray))
|
input_iterator = createResult(soilChunks, iter(porvArray))
|
||||||
case.properties.setActiveCellPropertyAsync(input_iterator, 'GENERATED', 'SOILPORVAsync', i)
|
case.properties.setActiveCellPropertyAsync(input_iterator, 'GENERATED', 'SOILPORVAsync', i)
|
||||||
|
@ -14,7 +14,7 @@ for porvChunk in porvChunks:
|
|||||||
|
|
||||||
timeStepInfo = case.timeSteps()
|
timeStepInfo = case.timeSteps()
|
||||||
|
|
||||||
for i in range (0, len(timeStepInfo.dates)):
|
for i in range (0, len(timeStepInfo)):
|
||||||
soilChunks = case.properties.activeCellProperty('DYNAMIC_NATIVE', 'SOIL', i)
|
soilChunks = case.properties.activeCellProperty('DYNAMIC_NATIVE', 'SOIL', i)
|
||||||
soilResults = []
|
soilResults = []
|
||||||
for soilChunk in soilChunks:
|
for soilChunk in soilChunks:
|
||||||
|
@ -21,6 +21,7 @@ class Case:
|
|||||||
self.properties = Properties(self)
|
self.properties = Properties(self)
|
||||||
self.request = Case_pb2.CaseRequest(id=self.id)
|
self.request = Case_pb2.CaseRequest(id=self.id)
|
||||||
|
|
||||||
|
# Get number of grids in the case
|
||||||
def gridCount(self):
|
def gridCount(self):
|
||||||
try:
|
try:
|
||||||
return self.stub.GetGridCount(self.request).count
|
return self.stub.GetGridCount(self.request).count
|
||||||
@ -30,9 +31,11 @@ class Case:
|
|||||||
print("ERROR: ", e)
|
print("ERROR: ", e)
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
# Get Grid of a given index. Returns a rips Grid object
|
||||||
def grid(self, index):
|
def grid(self, index):
|
||||||
return Grid(index, self)
|
return Grid(index, self)
|
||||||
|
|
||||||
|
# Get a list of all rips Grid objects in the case
|
||||||
def grids(self):
|
def grids(self):
|
||||||
gridList = []
|
gridList = []
|
||||||
for i in range(0, self.gridCount()):
|
for i in range(0, self.gridCount()):
|
||||||
@ -52,5 +55,8 @@ class Case:
|
|||||||
return self.stub.GetCellInfoForActiveCells(request)
|
return self.stub.GetCellInfoForActiveCells(request)
|
||||||
|
|
||||||
def timeSteps(self):
|
def timeSteps(self):
|
||||||
return self.stub.GetTimeSteps(self.request)
|
return self.stub.GetTimeSteps(self.request).dates
|
||||||
|
|
||||||
|
def daysSinceStart(self):
|
||||||
|
return self.stub.GetDaysSinceStart(self.request).day_decimals
|
||||||
|
|
@ -26,9 +26,10 @@ def pytest_configure(config):
|
|||||||
if config.getoption('--existing'):
|
if config.getoption('--existing'):
|
||||||
print("Looking for existing ResInsight")
|
print("Looking for existing ResInsight")
|
||||||
_rips_instance = rips.Instance.find()
|
_rips_instance = rips.Instance.find()
|
||||||
elif config.getoption('--console'):
|
else:
|
||||||
print("Should run as console app")
|
if config.getoption('--console'):
|
||||||
console = True
|
print("Should run as console app")
|
||||||
|
console = True
|
||||||
_rips_instance = rips.Instance.launch(console=console)
|
_rips_instance = rips.Instance.launch(console=console)
|
||||||
if not _rips_instance:
|
if not _rips_instance:
|
||||||
print("Need a valid ResInsight executable to launch tests")
|
print("Need a valid ResInsight executable to launch tests")
|
||||||
|
@ -45,7 +45,9 @@ def test_10k(rips_instance, initializeTest):
|
|||||||
assert(cellCountInfo.active_cell_count == 11125)
|
assert(cellCountInfo.active_cell_count == 11125)
|
||||||
assert(cellCountInfo.reservoir_cell_count == 316224)
|
assert(cellCountInfo.reservoir_cell_count == 316224)
|
||||||
timeSteps = case.timeSteps()
|
timeSteps = case.timeSteps()
|
||||||
assert(len(timeSteps.dates) == 9)
|
assert(len(timeSteps) == 9)
|
||||||
|
daysSinceStart = case.daysSinceStart()
|
||||||
|
assert(len(daysSinceStart) == 9)
|
||||||
|
|
||||||
def test_brugge_0010(rips_instance, initializeTest):
|
def test_brugge_0010(rips_instance, initializeTest):
|
||||||
casePath = dataroot.PATH + "/Case_with_10_timesteps/Real10/BRUGGE_0010.EGRID"
|
casePath = dataroot.PATH + "/Case_with_10_timesteps/Real10/BRUGGE_0010.EGRID"
|
||||||
@ -55,4 +57,6 @@ def test_brugge_0010(rips_instance, initializeTest):
|
|||||||
assert(cellCountInfo.active_cell_count == 43374)
|
assert(cellCountInfo.active_cell_count == 43374)
|
||||||
assert(cellCountInfo.reservoir_cell_count == 60048)
|
assert(cellCountInfo.reservoir_cell_count == 60048)
|
||||||
timeSteps = case.timeSteps()
|
timeSteps = case.timeSteps()
|
||||||
assert(len(timeSteps.dates) == 11)
|
assert(len(timeSteps) == 11)
|
||||||
|
daysSinceStart = case.daysSinceStart()
|
||||||
|
assert(len(daysSinceStart) == 11)
|
||||||
|
Loading…
Reference in New Issue
Block a user