mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#4736 Case.py renames
This commit is contained in:
parent
c6dbc34183
commit
e5987c26d7
@ -31,13 +31,13 @@ class Case (PdmObject):
|
||||
self.id = id
|
||||
info = self.stub.GetCaseInfo(Case_pb2.CaseRequest(id=self.id))
|
||||
self.name = info.name
|
||||
self.groupId = info.group_id
|
||||
self.group_id = info.group_id
|
||||
self.type = info.type
|
||||
self.properties = Properties(self)
|
||||
self.request = Case_pb2.CaseRequest(id=self.id)
|
||||
PdmObject.__init__(self, self.stub.GetPdmObject(self.request), self.channel)
|
||||
|
||||
def gridCount(self):
|
||||
def grid_count(self):
|
||||
"""Get number of grids in the case"""
|
||||
try:
|
||||
return self.stub.GetGridCount(self.request).count
|
||||
@ -47,7 +47,7 @@ class Case (PdmObject):
|
||||
print("ERROR: ", e)
|
||||
return 0
|
||||
|
||||
def gridPath(self):
|
||||
def grid_path(self):
|
||||
return self.getValue("CaseFileName")
|
||||
|
||||
def grid(self, index):
|
||||
@ -62,50 +62,50 @@ class Case (PdmObject):
|
||||
|
||||
def grids(self):
|
||||
"""Get a list of all rips Grid objects in the case"""
|
||||
gridList = []
|
||||
for i in range(0, self.gridCount()):
|
||||
gridList.append(Grid(i, self))
|
||||
return gridList
|
||||
grid_list = []
|
||||
for i in range(0, self.grid_count()):
|
||||
grid_list.append(Grid(i, self))
|
||||
return grid_list
|
||||
|
||||
def cellCount(self, porosityModel='MATRIX_MODEL'):
|
||||
def cell_count(self, porosity_model='MATRIX_MODEL'):
|
||||
"""Get a cell count object containing number of active cells and
|
||||
total number of cells
|
||||
|
||||
Arguments:
|
||||
porosityModel (str): String representing an enum.
|
||||
porosity_model (str): String representing an enum.
|
||||
must be 'MATRIX_MODEL' or 'FRACTURE_MODEL'.
|
||||
Returns:
|
||||
Cell Count object with the following integer attributes:
|
||||
active_cell_count: number of active cells
|
||||
reservoir_cell_count: total number of reservoir cells
|
||||
"""
|
||||
porosityModelEnum = Case_pb2.PorosityModelType.Value(porosityModel)
|
||||
porosity_model_enum = Case_pb2.PorosityModelType.Value(porosity_model)
|
||||
request = Case_pb2.CellInfoRequest(case_request=self.request,
|
||||
porosity_model=porosityModel)
|
||||
porosity_model=porosity_model_enum)
|
||||
return self.stub.GetCellCount(request)
|
||||
|
||||
def cellInfoForActiveCellsAsync(self, porosityModel='MATRIX_MODEL'):
|
||||
def cell_info_for_active_cells_async(self, porosity_model='MATRIX_MODEL'):
|
||||
"""Get Stream of cell info objects for current case
|
||||
|
||||
Arguments:
|
||||
porosityModel(str): String representing an enum.
|
||||
porosity_model(str): String representing an enum.
|
||||
must be 'MATRIX_MODEL' or 'FRACTURE_MODEL'.
|
||||
|
||||
Returns:
|
||||
Stream of **CellInfo** objects
|
||||
|
||||
See cellInfoForActiveCells() for detalis on the **CellInfo** class.
|
||||
See cell_info_for_active_cells() for detalis on the **CellInfo** class.
|
||||
"""
|
||||
porosityModelEnum = Case_pb2.PorosityModelType.Value(porosityModel)
|
||||
porosity_model_enum = Case_pb2.PorosityModelType.Value(porosity_model)
|
||||
request = Case_pb2.CellInfoRequest(case_request=self.request,
|
||||
porosity_model=porosityModel)
|
||||
porosity_model=porosity_model_enum)
|
||||
return self.stub.GetCellInfoForActiveCells(request)
|
||||
|
||||
def cellInfoForActiveCells(self, porosityModel='MATRIX_MODEL'):
|
||||
def cell_info_for_active_cells(self, porosity_model='MATRIX_MODEL'):
|
||||
"""Get list of cell info objects for current case
|
||||
|
||||
Arguments:
|
||||
porosityModel(str): String representing an enum.
|
||||
porosity_model(str): String representing an enum.
|
||||
must be 'MATRIX_MODEL' or 'FRACTURE_MODEL'.
|
||||
|
||||
Returns:
|
||||
@ -130,14 +130,14 @@ class Case (PdmObject):
|
||||
k | K grid index | Integer
|
||||
|
||||
"""
|
||||
activeCellInfoChunks = self.cellInfoForActiveCellsAsync()
|
||||
receivedActiveCells = []
|
||||
for activeCellChunk in activeCellInfoChunks:
|
||||
active_cell_info_chunks = self.cell_info_for_active_cells_async()
|
||||
received_active_cells = []
|
||||
for activeCellChunk in active_cell_info_chunks:
|
||||
for activeCell in activeCellChunk.data:
|
||||
receivedActiveCells.append(activeCell)
|
||||
return receivedActiveCells
|
||||
received_active_cells.append(activeCell)
|
||||
return received_active_cells
|
||||
|
||||
def timeSteps(self):
|
||||
def time_steps(self):
|
||||
"""Get a list containing all time steps
|
||||
|
||||
The time steps are defined by the class **TimeStepDate** :
|
||||
@ -155,16 +155,16 @@ class Case (PdmObject):
|
||||
"""
|
||||
return self.stub.GetTimeSteps(self.request).dates
|
||||
|
||||
def daysSinceStart(self):
|
||||
def days_since_start(self):
|
||||
"""Get a list of decimal values representing days since the start of the simulation"""
|
||||
return self.stub.GetDaysSinceStart(self.request).day_decimals
|
||||
|
||||
def views(self):
|
||||
"""Get a list of views belonging to a case"""
|
||||
pbmObjects = self.children("ReservoirViews")
|
||||
pdm_objects = self.children("ReservoirViews")
|
||||
viewList = []
|
||||
for pbmObject in pbmObjects:
|
||||
viewList.append(View(pbmObject))
|
||||
for pdm_object in pdm_objects:
|
||||
viewList.append(View(pdm_object))
|
||||
return viewList
|
||||
|
||||
def view(self, id):
|
||||
@ -176,13 +176,13 @@ class Case (PdmObject):
|
||||
|
||||
"""
|
||||
views = self.views()
|
||||
for viewObject in views:
|
||||
if viewObject.id == id:
|
||||
return viewObject
|
||||
for view_object in views:
|
||||
if view_object.id == id:
|
||||
return view_object
|
||||
return None
|
||||
|
||||
def createView(self):
|
||||
def create_view(self):
|
||||
"""Create a new view in the current case"""
|
||||
viewId = Commands(self.channel).createView(self.id)
|
||||
return self.view(viewId)
|
||||
view_id = Commands(self.channel).create_view(self.id)
|
||||
return self.view(view_id)
|
||||
|
||||
|
@ -289,7 +289,7 @@ class Commands:
|
||||
minimumCommunication = minimumCommunication,
|
||||
aquiferCellThreshold = aquiferCellThreshold))
|
||||
|
||||
def createView(self, caseId):
|
||||
def create_view(self, caseId):
|
||||
return self.__execute(createView=Cmd.CreateViewRequest(caseId=caseId)).createViewResult.viewId
|
||||
|
||||
def cloneView(self, viewId):
|
||||
|
@ -15,9 +15,9 @@ if resInsight is not None:
|
||||
print ("Got " + str(len(cases)) + " cases: ")
|
||||
for case in cases:
|
||||
print("Case name: " + case.name)
|
||||
print("Case grid path: " + case.gridPath())
|
||||
print("Case grid path: " + case.grid_path())
|
||||
|
||||
timesteps = case.timeSteps()
|
||||
timesteps = case.time_steps()
|
||||
for t in timesteps:
|
||||
print("Year: " + str(t.year))
|
||||
print("Month: " + str(t.month))
|
||||
|
@ -12,12 +12,12 @@ resInsight = rips.Instance.find()
|
||||
case = resInsight.project.case(id = 0)
|
||||
|
||||
# Get the cell count object
|
||||
cellCounts = case.cellCount()
|
||||
cellCounts = case.cell_count()
|
||||
print("Number of active cells: " + str(cellCounts.active_cell_count))
|
||||
print("Total number of reservoir cells: " + str(cellCounts.reservoir_cell_count))
|
||||
|
||||
# Get information for all active cells
|
||||
activeCellInfos = case.cellInfoForActiveCells()
|
||||
activeCellInfos = case.cell_info_for_active_cells()
|
||||
|
||||
# A simple check on the size of the cell info
|
||||
assert(cellCounts.active_cell_count == len(activeCellInfos))
|
||||
|
@ -18,7 +18,7 @@ property_list = ['SOIL', 'PRESSURE'] # list of parameter for snapshot
|
||||
print ("Looping through cases")
|
||||
for case in cases:
|
||||
# Get grid path and its folder name
|
||||
casepath = case.gridPath()
|
||||
casepath = case.grid_path()
|
||||
foldername = os.path.dirname(casepath)
|
||||
|
||||
# create a folder to hold the snapshots
|
||||
@ -30,7 +30,7 @@ for case in cases:
|
||||
print ("Exporting to folder: " + dirname)
|
||||
resInsight.commands.setExportFolder(type='SNAPSHOTS', path=dirname)
|
||||
|
||||
timeSteps = case.timeSteps()
|
||||
timeSteps = case.time_steps()
|
||||
tss_snapshot = range(0, len(timeSteps), n)
|
||||
print(case.name, case.id, 'Number of timesteps: ' + str(len(timeSteps)))
|
||||
print('Number of timesteps for snapshoting: ' + str(len(tss_snapshot)))
|
||||
|
@ -8,4 +8,4 @@ cases = resInsight.project.cases()
|
||||
print ("Got " + str(len(cases)) + " cases: ")
|
||||
for case in cases:
|
||||
print("Case name: " + case.name)
|
||||
print("Case grid path: " + case.gridPath())
|
||||
print("Case grid path: " + case.grid_path())
|
||||
|
@ -6,7 +6,7 @@ import rips
|
||||
resInsight = rips.Instance.find()
|
||||
|
||||
case = resInsight.project.case(id=0)
|
||||
totalCellCount = case.cellCount().reservoir_cell_count
|
||||
totalCellCount = case.cell_count().reservoir_cell_count
|
||||
|
||||
values = []
|
||||
for i in range(0, totalCellCount):
|
||||
|
@ -14,7 +14,7 @@ start = time.time()
|
||||
case = resInsight.project.case(id=0)
|
||||
|
||||
# Get a list of all time steps
|
||||
timeSteps = case.timeSteps()
|
||||
timeSteps = case.time_steps()
|
||||
|
||||
averages = []
|
||||
for i in range(0, len(timeSteps)):
|
||||
|
@ -14,7 +14,7 @@ case = resInsight.project.case(id=0)
|
||||
case = resInsight.project.case(id=0)
|
||||
|
||||
# Get a list of all time steps
|
||||
timeSteps = case.timeSteps()
|
||||
timeSteps = case.time_steps()
|
||||
|
||||
averages = []
|
||||
for i in range(0, len(timeSteps)):
|
||||
|
@ -19,7 +19,7 @@ def createResult(soilChunks, porvChunks):
|
||||
resInsight = rips.Instance.find()
|
||||
start = time.time()
|
||||
case = resInsight.project.case(id=0)
|
||||
timeStepInfo = case.timeSteps()
|
||||
timeStepInfo = case.time_steps()
|
||||
|
||||
# Get a generator for the porv results. The generator will provide a chunk each time it is iterated
|
||||
porvChunks = case.properties.activeCellPropertyAsync('STATIC_NATIVE', 'PORV', 0)
|
||||
|
@ -11,7 +11,7 @@ case = resInsight.project.case(id=0)
|
||||
|
||||
# Read the full porv result
|
||||
porvResults = case.properties.activeCellProperty('STATIC_NATIVE', 'PORV', 0)
|
||||
timeStepInfo = case.timeSteps()
|
||||
timeStepInfo = case.time_steps()
|
||||
|
||||
for i in range (0, len(timeStepInfo)):
|
||||
# Read the full SOIl result for time step i
|
||||
|
@ -41,13 +41,13 @@ def test_MultipleCases(rips_instance, initializeTest):
|
||||
def test_10k(rips_instance, initializeTest):
|
||||
casePath = dataroot.PATH + "/TEST10K_FLT_LGR_NNC/TEST10K_FLT_LGR_NNC.EGRID"
|
||||
case = rips_instance.project.loadCase(path=casePath)
|
||||
assert(case.gridCount() == 2)
|
||||
cellCountInfo = case.cellCount()
|
||||
assert(case.grid_count() == 2)
|
||||
cellCountInfo = case.cell_count()
|
||||
assert(cellCountInfo.active_cell_count == 11125)
|
||||
assert(cellCountInfo.reservoir_cell_count == 316224)
|
||||
timeSteps = case.timeSteps()
|
||||
timeSteps = case.time_steps()
|
||||
assert(len(timeSteps) == 9)
|
||||
daysSinceStart = case.daysSinceStart()
|
||||
daysSinceStart = case.days_since_start()
|
||||
assert(len(daysSinceStart) == 9)
|
||||
|
||||
def test_PdmObject(rips_instance, initializeTest):
|
||||
@ -63,13 +63,13 @@ def test_PdmObject(rips_instance, initializeTest):
|
||||
def test_brugge_0010(rips_instance, initializeTest):
|
||||
casePath = dataroot.PATH + "/Case_with_10_timesteps/Real10/BRUGGE_0010.EGRID"
|
||||
case = rips_instance.project.loadCase(path=casePath)
|
||||
assert(case.gridCount() == 1)
|
||||
cellCountInfo = case.cellCount()
|
||||
assert(case.grid_count() == 1)
|
||||
cellCountInfo = case.cell_count()
|
||||
assert(cellCountInfo.active_cell_count == 43374)
|
||||
assert(cellCountInfo.reservoir_cell_count == 60048)
|
||||
timeSteps = case.timeSteps()
|
||||
timeSteps = case.time_steps()
|
||||
assert(len(timeSteps) == 11)
|
||||
daysSinceStart = case.daysSinceStart()
|
||||
daysSinceStart = case.days_since_start()
|
||||
assert(len(daysSinceStart) == 11)
|
||||
|
||||
@pytest.mark.skipif(sys.platform.startswith('linux'), reason="Brugge is currently exceptionally slow on Linux")
|
||||
|
@ -9,7 +9,7 @@ import dataroot
|
||||
def test_10k(rips_instance, initializeTest):
|
||||
casePath = dataroot.PATH + "/TEST10K_FLT_LGR_NNC/TEST10K_FLT_LGR_NNC.EGRID"
|
||||
case = rips_instance.project.loadCase(path=casePath)
|
||||
assert(case.gridCount() == 2)
|
||||
assert(case.grid_count() == 2)
|
||||
grid = case.grid(index=0)
|
||||
dimensions = grid.dimensions()
|
||||
assert(dimensions.i == 90)
|
||||
|
Loading…
Reference in New Issue
Block a user