mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#4463 Added command for creating grid statistics
This commit is contained in:
@@ -111,6 +111,12 @@ class Commands:
|
||||
assert(commandReply.HasField("createGridCaseGroupResult"))
|
||||
return (commandReply.createGridCaseGroupResult.groupId, commandReply.createGridCaseGroupResult.groupName)
|
||||
|
||||
def createStatisticsCase(self, caseGroupId):
|
||||
commandReply = self.__execute(createStatisticsCase=Cmd.CreateStatisticsCaseRequest(caseGroupId=caseGroupId))
|
||||
assert(commandReply is not None)
|
||||
assert(commandReply.HasField("createStatisticsCaseResult"))
|
||||
return commandReply.createStatisticsCaseResult.caseId;
|
||||
|
||||
##################
|
||||
# Export Commands
|
||||
##################
|
||||
|
||||
@@ -81,15 +81,15 @@ class PdmObject:
|
||||
self.pb2Object.parameters[keyword] = self.__fromValue(value)
|
||||
|
||||
def descendants(self, classKeyword):
|
||||
request = PdmObject_pb2.PdmChildObjectRequest(object=self.pb2Object, child_keyword=classKeyword)
|
||||
request = PdmObject_pb2.PdmDescendantObjectRequest(object=self.pb2Object, child_keyword=classKeyword)
|
||||
objectList = self.pdmObjectStub.GetDescendantPdmObjects(request).objects
|
||||
childList = []
|
||||
for object in objectList:
|
||||
childList.append(PdmObject(object, self.channel))
|
||||
return childList
|
||||
|
||||
def children(self, classKeyword):
|
||||
request = PdmObject_pb2.PdmChildObjectRequest(object=self.pb2Object, child_keyword=classKeyword)
|
||||
def children(self, childField):
|
||||
request = PdmObject_pb2.PdmChildObjectRequest(object=self.pb2Object, child_field=childField)
|
||||
objectList = self.pdmObjectStub.GetChildPdmObjects(request).objects
|
||||
childList = []
|
||||
for object in objectList:
|
||||
@@ -102,3 +102,7 @@ class PdmObject:
|
||||
|
||||
def update(self):
|
||||
self.pdmObjectStub.UpdateExistingPdmObject(self.pb2Object)
|
||||
|
||||
# def createChild(self, childField, childClassKeyword):
|
||||
# childRequest = PdmObject_pb2.CreatePdmChildObjectRequest(object=self.pb2Object, child_field=childField, child_class=childClassKeyword)
|
||||
# return PdmObject(self.pdmObjectStub.CreateChildPdmObject(childRequest), self.channel)
|
||||
|
||||
@@ -13,15 +13,28 @@ groupId, groupName = resInsight.commands.createGridCaseGroup(casePaths=casePaths
|
||||
print("Group id = " + str(groupId))
|
||||
print("Group name = " + groupName)
|
||||
|
||||
caseId = resInsight.commands.createStatisticsCase(caseGroupId=groupId)
|
||||
|
||||
caseGroups = resInsight.project.descendants("RimIdenticalGridCaseGroup");
|
||||
|
||||
caseIds = []
|
||||
for caseGroup in caseGroups:
|
||||
print ("#### Case Group ####")
|
||||
for kw in caseGroup.keywords():
|
||||
print (kw, caseGroup.getValue(kw))
|
||||
statCases = caseGroup.descendants("RimStatisticalCalculation")
|
||||
for statCase in statCases:
|
||||
print(" ## Stat Case ##")
|
||||
for skw in statCase.keywords():
|
||||
print(" ", skw, statCase.getValue(skw))
|
||||
statCase.setValue("DynamicPropertiesToCalculate", statCase.getValue("DynamicPropertiesToCalculate") + ["SWAT"])
|
||||
statCase.update()
|
||||
|
||||
for caseCollection in caseGroup.children("StatisticsCaseCollection"):
|
||||
print (" ### Case Collection ###")
|
||||
statCases = caseCollection.children("Reservoirs")
|
||||
|
||||
for statCase in statCases:
|
||||
print(" ## Stat Case ##")
|
||||
for skw in statCase.keywords():
|
||||
print(" ", skw, statCase.getValue(skw))
|
||||
statCase.setValue("DynamicPropertiesToCalculate", statCase.getValue("DynamicPropertiesToCalculate") + ["SWAT"])
|
||||
statCase.update()
|
||||
caseIds.append(statCase.getValue("CaseId"))
|
||||
|
||||
print(caseIds)
|
||||
resInsight.commands.computeCaseGroupStatistics(caseIds=caseIds)
|
||||
|
||||
Reference in New Issue
Block a user