mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#4736 Commands.py renames
This commit is contained in:
@@ -23,14 +23,14 @@ class Commands:
|
||||
self.channel = channel
|
||||
self.commands = CmdRpc.CommandsStub(channel)
|
||||
|
||||
def __execute(self, **commandParams):
|
||||
return self.commands.Execute(Cmd.CommandParams(**commandParams))
|
||||
def __execute(self, **command_params):
|
||||
return self.commands.Execute(Cmd.CommandParams(**command_params))
|
||||
|
||||
########################
|
||||
# Case Control Commands
|
||||
########################
|
||||
|
||||
def openProject(self, path):
|
||||
def open_project(self, path):
|
||||
"""Open a project
|
||||
|
||||
Arguments:
|
||||
@@ -40,11 +40,11 @@ class Commands:
|
||||
"""
|
||||
return self.__execute(openProject=Cmd.FilePathRequest(path=path))
|
||||
|
||||
def closeProject(self):
|
||||
def close_project(self):
|
||||
"""Close the current project (and reopen empty one)"""
|
||||
return self.__execute(closeProject=Empty())
|
||||
|
||||
def setStartDir(self, path):
|
||||
def set_start_dir(self, path):
|
||||
"""Set current start directory
|
||||
|
||||
Arguments:
|
||||
@@ -53,7 +53,7 @@ class Commands:
|
||||
"""
|
||||
return self.__execute(setStartDir=Cmd.FilePathRequest(path=path))
|
||||
|
||||
def loadCase(self, path):
|
||||
def load_case(self, path):
|
||||
"""Load a case
|
||||
|
||||
Arguments:
|
||||
@@ -63,234 +63,249 @@ class Commands:
|
||||
A Case object
|
||||
|
||||
"""
|
||||
commandReply = self.__execute(loadCase=Cmd.FilePathRequest(path=path))
|
||||
return rips.Case(self.channel, commandReply.loadCaseResult.id)
|
||||
command_reply = self.__execute(loadCase=Cmd.FilePathRequest(path=path))
|
||||
return rips.Case(self.channel, command_reply.loadCaseResult.id)
|
||||
|
||||
def replaceCase(self, newGridFile, caseId=0):
|
||||
def replace_case(self, new_grid_file, case_id=0):
|
||||
"""Replace the given case with a new case loaded from file
|
||||
|
||||
Arguments:
|
||||
newGridFile (str): path to EGRID file
|
||||
caseId (int): case Id to replace
|
||||
new_grid_file (str): path to EGRID file
|
||||
case_id (int): case Id to replace
|
||||
|
||||
"""
|
||||
return self.__execute(replaceCase=Cmd.ReplaceCaseRequest(newGridFile=newGridFile,
|
||||
caseId=caseId))
|
||||
return self.__execute(replaceCase=Cmd.ReplaceCaseRequest(newGridFile=new_grid_file,
|
||||
caseId=case_id))
|
||||
|
||||
def replaceSourceCases(self, gridListFile, caseGroupId=0):
|
||||
def replace_source_cases(self, grid_list_file, case_group_id=0):
|
||||
"""Replace all source cases within a case group
|
||||
|
||||
Arguments:
|
||||
gridListFile (str): path to file containing a list of cases
|
||||
caseGroupId (int): id of the case group to replace
|
||||
grid_list_file (str): path to file containing a list of cases
|
||||
case_group_id (int): id of the case group to replace
|
||||
|
||||
"""
|
||||
return self.__execute(replaceSourceCases=Cmd.ReplaceSourceCasesRequest(gridListFile=gridListFile,
|
||||
caseGroupId=caseGroupId))
|
||||
return self.__execute(replaceSourceCases=Cmd.ReplaceSourceCasesRequest(gridListFile=grid_list_file,
|
||||
caseGroupId=case_group_id))
|
||||
|
||||
def createGridCaseGroup(self, casePaths):
|
||||
def create_grid_case_group(self, case_paths):
|
||||
"""Create a Grid Case Group from a list of cases
|
||||
|
||||
Arguments:
|
||||
casePaths (list): list of file path strings
|
||||
case_paths (list): list of file path strings
|
||||
|
||||
Returns:
|
||||
A case group id and name
|
||||
"""
|
||||
commandReply = self.__execute(createGridCaseGroup=Cmd.CreateGridCaseGroupRequest(casePaths=casePaths))
|
||||
commandReply = self.__execute(createGridCaseGroup=Cmd.CreateGridCaseGroupRequest(casePaths=case_paths))
|
||||
return (commandReply.createGridCaseGroupResult.groupId, commandReply.createGridCaseGroupResult.groupName)
|
||||
|
||||
def createStatisticsCase(self, caseGroupId):
|
||||
commandReply = self.__execute(createStatisticsCase=Cmd.CreateStatisticsCaseRequest(caseGroupId=caseGroupId))
|
||||
return commandReply.createStatisticsCaseResult.caseId;
|
||||
def create_statistics_case(self, case_group_id):
|
||||
"""Create a Statistics case in a Grid Case Group
|
||||
|
||||
Arguments:
|
||||
case_group_id (int): id of the case group
|
||||
|
||||
Returns:
|
||||
A case id for the new case
|
||||
"""
|
||||
commandReply = self.__execute(createStatisticsCase=Cmd.CreateStatisticsCaseRequest(caseGroupId=case_group_id))
|
||||
return commandReply.createStatisticsCaseResult.caseId
|
||||
|
||||
##################
|
||||
# Export Commands
|
||||
##################
|
||||
|
||||
def exportMultiCaseSnapshots(self, gridListFile):
|
||||
def export_multi_case_snapshots(self, grid_list_file):
|
||||
"""Export snapshots for a set of cases
|
||||
|
||||
Arguments:
|
||||
gridListFile (str): Path to a file containing a list of grids to export snapshot for
|
||||
grid_list_file (str): Path to a file containing a list of grids to export snapshot for
|
||||
|
||||
"""
|
||||
return self.__execute(exportMultiCaseSnapshot=Cmd.ExportMultiCaseRequest(gridListFile=gridListFile))
|
||||
return self.__execute(exportMultiCaseSnapshot=Cmd.ExportMultiCaseRequest(gridListFile=grid_list_file))
|
||||
|
||||
def exportSnapshots(self, type = 'ALL', prefix='', caseId = -1):
|
||||
def export_snapshots(self, type = 'ALL', prefix='', case_id = -1):
|
||||
""" Export snapshots of a given type
|
||||
|
||||
Arguments:
|
||||
type (str): Enum string ('ALL', 'VIEWS' or 'PLOTS')
|
||||
prefix (str): Exported file name prefix
|
||||
caseId (int): the case Id to export for. The default of -1 will export all cases
|
||||
case_id (int): the case Id to export for. The default of -1 will export all cases
|
||||
|
||||
"""
|
||||
return self.__execute(exportSnapshots=Cmd.ExportSnapshotsRequest(type=type,
|
||||
prefix=prefix,
|
||||
caseId=caseId))
|
||||
caseId=case_id))
|
||||
|
||||
def exportProperty(self, caseId, timeStep, property, eclipseKeyword=property, undefinedValue=0.0, exportFile=property):
|
||||
def export_property(self, case_id, time_step, property, eclipse_keyword=property, undefined_value=0.0, export_file=property):
|
||||
""" Export an Eclipse property
|
||||
|
||||
Arguments:
|
||||
caseId (int): case id
|
||||
timeStep (int): time step index
|
||||
case_id (int): case id
|
||||
time_step (int): time step index
|
||||
property (str): property to export
|
||||
eclipseKeyword (str): Eclipse keyword used as text in export header. Defaults to the value of property parameter.
|
||||
undefinedValue (double): Value to use for undefined values. Defaults to 0.0
|
||||
exportFile (str): Filename for export. Defaults to the value of property parameter
|
||||
eclipse_keyword (str): Eclipse keyword used as text in export header. Defaults to the value of property parameter.
|
||||
undefined_value (double): Value to use for undefined values. Defaults to 0.0
|
||||
export_file (str): File name for export. Defaults to the value of property parameter
|
||||
"""
|
||||
return self.__execute(exportProperty=Cmd.ExportPropertyRequest(caseId=caseId,
|
||||
timeStep=timeStep,
|
||||
return self.__execute(exportProperty=Cmd.ExportPropertyRequest(caseId=case_id,
|
||||
timeStep=time_step,
|
||||
property=property,
|
||||
eclipseKeyword=eclipseKeyword,
|
||||
undefinedValue=undefinedValue,
|
||||
exportFile=exportFile))
|
||||
eclipseKeyword=eclipse_keyword,
|
||||
undefinedValue=undefined_value,
|
||||
exportFile=export_file))
|
||||
|
||||
def exportPropertyInViews(self, caseId, viewNames, undefinedValue):
|
||||
if isinstance(viewNames, str):
|
||||
viewNames = [viewNames]
|
||||
def export_property_in_views(self, case_id, view_names, undefined_value):
|
||||
""" Export the current Eclipse property from the given views
|
||||
|
||||
return self.__execute(exportPropertyInViews=Cmd.ExportPropertyInViewsRequest(caseId=caseId,
|
||||
viewNames=viewNames,
|
||||
undefinedValue=undefinedValue))
|
||||
Arguments:
|
||||
case_id (int): case id
|
||||
view_names (list): list of views
|
||||
undefined_value (double): Value to use for undefined values. Defaults to 0.0
|
||||
"""
|
||||
if isinstance(view_names, str):
|
||||
view_names = [view_names]
|
||||
|
||||
def exportWellPathCompletions(self, caseId, timeStep, wellPathNames, fileSplit,
|
||||
compdatExport, includePerforations, includeFishbones,
|
||||
excludeMainBoreForFishbones, combinationMode):
|
||||
if (isinstance(wellPathNames, str)):
|
||||
wellPathNames = [wellPathNames]
|
||||
return self.__execute(exportWellPathCompletions=Cmd.ExportWellPathCompRequest(caseId=caseId,
|
||||
timeStep=timeStep,
|
||||
wellPathNames=wellPathNames,
|
||||
fileSplit=fileSplit,
|
||||
compdatExport=compdatExport,
|
||||
includePerforations=includePerforations,
|
||||
includeFishbones=includeFishbones,
|
||||
excludeMainBoreForFishbones=excludeMainBoreForFishbones,
|
||||
combinationMode=combinationMode))
|
||||
return self.__execute(exportPropertyInViews=Cmd.ExportPropertyInViewsRequest(caseId=case_id,
|
||||
viewNames=view_names,
|
||||
undefinedValue=undefined_value))
|
||||
|
||||
def exportSimWellFractureCompletions(self, caseId, viewName, timeStep, simulationWellNames, fileSplit, compdatExport):
|
||||
if(isinstance(simulationWellNames, str)):
|
||||
simulationWellNames = [simulationWellNames]
|
||||
return self.__execute(exportSimWellFractureCompletions=Cmd.ExportSimWellPathFraqRequest(caseId=caseId,
|
||||
viewName=viewName,
|
||||
timeStep=timeStep,
|
||||
simulationWellNames=simulationWellNames,
|
||||
fileSplit=fileSplit,
|
||||
compdatExport=compdatExport))
|
||||
def export_well_path_completions(self, case_id, time_step, well_path_names, file_split,
|
||||
compdat_export, include_perforations, include_fishbones,
|
||||
exclude_main_bore_for_fishbones, combination_mode):
|
||||
if (isinstance(well_path_names, str)):
|
||||
well_path_names = [well_path_names]
|
||||
return self.__execute(exportWellPathCompletions=Cmd.ExportWellPathCompRequest(caseId=case_id,
|
||||
timeStep=time_step,
|
||||
wellPathNames=well_path_names,
|
||||
fileSplit=file_split,
|
||||
compdatExport=compdat_export,
|
||||
includePerforations=include_perforations,
|
||||
includeFishbones=include_fishbones,
|
||||
excludeMainBoreForFishbones=exclude_main_bore_for_fishbones,
|
||||
combinationMode=combination_mode))
|
||||
|
||||
def exportMsw(self, caseId, wellPath):
|
||||
return self.__execute(exportMsw=Cmd.ExportMswRequest(caseId=caseId,
|
||||
wellPath=wellPath))
|
||||
def export_sim_well_fracture_completions(self, case_id, view_name, time_step, simulation_well_names, file_split, compdat_export):
|
||||
if(isinstance(simulation_well_names, str)):
|
||||
simulation_well_names = [simulation_well_names]
|
||||
return self.__execute(exportSimWellFractureCompletions=Cmd.ExportSimWellPathFraqRequest(caseId=case_id,
|
||||
viewName=view_name,
|
||||
timeStep=time_step,
|
||||
simulationWellNames=simulation_well_names,
|
||||
fileSplit=file_split,
|
||||
compdatExport=compdat_export))
|
||||
|
||||
def exportWellPaths(self, wellPaths=[], mdStepSize=5.0):
|
||||
if isinstance(wellPaths, str):
|
||||
wellPaths = [wellPaths]
|
||||
return self.__execute(exportWellPaths=Cmd.ExportWellPathRequest(wellPathNames=wellPaths, mdStepSize=mdStepSize))
|
||||
def export_msw(self, case_id, well_path):
|
||||
return self.__execute(exportMsw=Cmd.ExportMswRequest(caseId=case_id,
|
||||
wellPath=well_path))
|
||||
|
||||
def exportVisibleCells(self, caseId, viewName, exportKeyword='FLUXNUM', visibleActiveCellsValue=1, hiddenActiveCellsValue=0, inactiveCellsValue=0):
|
||||
return self.__execute(exportVisibleCells=Cmd.ExportVisibleCellsRequest(caseId=caseId,
|
||||
viewName=viewName,
|
||||
exportKeyword=exportKeyword,
|
||||
visibleActiveCellsValue=visibleActiveCellsValue,
|
||||
hiddenActiveCellsValue=hiddenActiveCellsValue,
|
||||
inactiveCellsValue=inactiveCellsValue))
|
||||
def setExportFolder(self, type, path, createFolder=False):
|
||||
def export_well_paths(self, well_paths=[], md_step_size=5.0):
|
||||
if isinstance(well_paths, str):
|
||||
well_paths = [well_paths]
|
||||
return self.__execute(exportWellPaths=Cmd.ExportWellPathRequest(wellPathNames=well_paths, mdStepSize=md_step_size))
|
||||
|
||||
def export_visible_cells(self, case_id, view_name, export_keyword='FLUXNUM', visible_active_cells_value=1, hidden_active_cells_value=0, inactive_cells_value=0):
|
||||
return self.__execute(exportVisibleCells=Cmd.ExportVisibleCellsRequest(caseId=case_id,
|
||||
viewName=view_name,
|
||||
exportKeyword=export_keyword,
|
||||
visibleActiveCellsValue=visible_active_cells_value,
|
||||
hiddenActiveCellsValue=hidden_active_cells_value,
|
||||
inactiveCellsValue=inactive_cells_value))
|
||||
def set_export_folder(self, type, path, create_folder=False):
|
||||
return self.__execute(setExportFolder=Cmd.SetExportFolderRequest(type=type,
|
||||
path=path,
|
||||
createFolder=createFolder))
|
||||
createFolder=create_folder))
|
||||
|
||||
def runOctaveScript(self, path, cases):
|
||||
def run_octave_script(self, path, cases):
|
||||
caseIds = []
|
||||
for case in cases:
|
||||
caseIds.append(case.id)
|
||||
return self.__execute(runOctaveScript=Cmd.RunOctaveScriptRequest(path=path,
|
||||
caseIds=caseIds))
|
||||
|
||||
def setMainWindowSize(self, width, height):
|
||||
def set_main_window_size(self, width, height):
|
||||
return self.__execute(setMainWindowSize=Cmd.SetMainWindowSizeParams(width=width, height=height))
|
||||
|
||||
def computeCaseGroupStatistics(self, caseIds = [], caseGroupId = -1):
|
||||
return self.__execute(computeCaseGroupStatistics=Cmd.ComputeCaseGroupStatRequest(caseIds=caseIds,
|
||||
caseGroupId=caseGroupId))
|
||||
def compute_case_group_statistics(self, case_ids = [], case_group_id = -1):
|
||||
return self.__execute(computeCaseGroupStatistics=Cmd.ComputeCaseGroupStatRequest(caseIds=case_ids,
|
||||
caseGroupId=case_group_id))
|
||||
|
||||
def setTimeStep(self, caseId, timeStep):
|
||||
return self.__execute(setTimeStep=Cmd.SetTimeStepParams(caseId=caseId, timeStep=timeStep))
|
||||
def set_time_step(self, case_id, time_step):
|
||||
return self.__execute(setTimeStep=Cmd.SetTimeStepParams(caseId=case_id, timeStep=time_step))
|
||||
|
||||
def scaleFractureTemplate(self, id, halfLength, height, dFactor, conductivity):
|
||||
def scale_fracture_template(self, id, half_length, height, dfactor, conductivity):
|
||||
return self.__execute(scaleFractureTemplate=Cmd.ScaleFractureTemplateRequest(id=id,
|
||||
halfLength=halfLength,
|
||||
halfLength=half_length,
|
||||
height=height,
|
||||
dFactor=dFactor,
|
||||
dFactor=dfactor,
|
||||
conductivity=conductivity))
|
||||
|
||||
def setFractureContainment(self, id, topLayer, baseLayer):
|
||||
def set_fracture_containment(self, id, top_layer, base_layer):
|
||||
return self.__execute(setFractureContainment=Cmd.SetFracContainmentRequest(id=id,
|
||||
topLayer=topLayer,
|
||||
baseLayer=baseLayer))
|
||||
topLayer=top_layer,
|
||||
baseLayer=base_layer))
|
||||
|
||||
def createMultipleFractures(self, caseId, templateId, wellPathNames, minDistFromWellTd,
|
||||
maxFracturesPerWell, topLayer, baseLayer, spacing, action):
|
||||
if isinstance(wellPathNames, str):
|
||||
wellPathNames = [wellPathNames]
|
||||
return self.__execute(createMultipleFractures=Cmd.MultipleFracAction(caseId=caseId,
|
||||
templateId=templateId,
|
||||
wellPathNames=wellPathNames,
|
||||
minDistFromWellTd=minDistFromWellTd,
|
||||
maxFracturesPerWell=maxFracturesPerWell,
|
||||
topLayer=topLayer,
|
||||
baseLayer=baseLayer,
|
||||
def create_multiple_fractures(self, case_id, template_id, well_path_names, min_dist_from_well_td,
|
||||
max_fractures_per_well, top_layer, base_layer, spacing, action):
|
||||
if isinstance(well_path_names, str):
|
||||
well_path_names = [well_path_names]
|
||||
return self.__execute(createMultipleFractures=Cmd.MultipleFracAction(caseId=case_id,
|
||||
templateId=template_id,
|
||||
wellPathNames=well_path_names,
|
||||
minDistFromWellTd=min_dist_from_well_td,
|
||||
maxFracturesPerWell=max_fractures_per_well,
|
||||
topLayer=top_layer,
|
||||
baseLayer=base_layer,
|
||||
spacing=spacing,
|
||||
action=action))
|
||||
|
||||
def createLgrForCompletions(self, caseId, timeStep, wellPathNames, refinementI, refinementJ, refinementK, splitType):
|
||||
if isinstance(wellPathNames, str):
|
||||
wellPathNames = [wellPathNames]
|
||||
return self.__execute(createLgrForCompletions=Cmd.CreateLgrForCompRequest(caseId=caseId,
|
||||
timeStep=timeStep,
|
||||
wellPathNames=wellPathNames,
|
||||
refinementI=refinementI,
|
||||
refinementJ=refinementJ,
|
||||
refinementK=refinementK,
|
||||
splitType=splitType))
|
||||
def create_lgr_for_completion(self, case_id, time_step, well_path_names, refinement_i, refinement_j, refinement_k, split_type):
|
||||
if isinstance(well_path_names, str):
|
||||
well_path_names = [well_path_names]
|
||||
return self.__execute(createLgrForCompletions=Cmd.CreateLgrForCompRequest(caseId=case_id,
|
||||
timeStep=time_step,
|
||||
wellPathNames=well_path_names,
|
||||
refinementI=refinement_i,
|
||||
refinementJ=refinement_j,
|
||||
refinementK=refinement_k,
|
||||
splitType=split_type))
|
||||
|
||||
def createSaturationPressurePlots(self, caseIds):
|
||||
if isinstance(caseIds, int):
|
||||
caseIds = [caseIds]
|
||||
return self.__execute(createSaturationPressurePlots=Cmd.CreateSatPressPlotRequest(caseIds=caseIds))
|
||||
def create_saturation_pressure_plots(self, case_ids):
|
||||
if isinstance(case_ids, int):
|
||||
case_ids = [case_ids]
|
||||
return self.__execute(createSaturationPressurePlots=Cmd.CreateSatPressPlotRequest(caseIds=case_ids))
|
||||
|
||||
def exportFlowCharacteristics(self, caseId, timeSteps, injectors, producers, fileName, minimumCommunication=0.0, aquiferCellThreshold=0.1):
|
||||
def export_flow_characteristics(self, case_id, time_steps, injectors, producers, file_name, minimum_communication=0.0, aquifer_cell_threshold=0.1):
|
||||
""" Export Flow Characteristics data to text file in CSV format
|
||||
|
||||
Parameter | Description | Type
|
||||
------------------------- | --------------------------------------------- | -----
|
||||
caseId | ID of case | Integer
|
||||
timeSteps | Time step indices | List of Integer
|
||||
case_id | ID of case | Integer
|
||||
time_steps | Time step indices | List of Integer
|
||||
injectors | Injector names | List of Strings
|
||||
producers | Producer names | List of Strings
|
||||
fileName | Export file name | Integer
|
||||
minimumCommunication | Minimum Communication, defaults to 0.0 | Integer
|
||||
aquiferCellThreshold | Aquifer Cell Threshold, defaults to 0.1 | Integer
|
||||
file_name | Export file name | Integer
|
||||
minimum_communication | Minimum Communication, defaults to 0.0 | Integer
|
||||
aquifer_cell_threshold | Aquifer Cell Threshold, defaults to 0.1 | Integer
|
||||
|
||||
"""
|
||||
if isinstance(timeSteps, int):
|
||||
timeSteps = [timeSteps]
|
||||
if isinstance(time_steps, int):
|
||||
time_steps = [time_steps]
|
||||
if isinstance(injectors, str):
|
||||
injectors = [injectors]
|
||||
if isinstance(producers, str):
|
||||
producers = [producers]
|
||||
return self.__execute(exportFlowCharacteristics=Cmd.ExportFlowInfoRequest(caseId=caseId,
|
||||
timeSteps=timeSteps,
|
||||
return self.__execute(exportFlowCharacteristics=Cmd.ExportFlowInfoRequest(caseId=case_id,
|
||||
timeSteps=time_steps,
|
||||
injectors=injectors,
|
||||
producers=producers,
|
||||
fileName=fileName,
|
||||
minimumCommunication = minimumCommunication,
|
||||
aquiferCellThreshold = aquiferCellThreshold))
|
||||
fileName=file_name,
|
||||
minimumCommunication = minimum_communication,
|
||||
aquiferCellThreshold = aquifer_cell_threshold))
|
||||
|
||||
def create_view(self, caseId):
|
||||
return self.__execute(createView=Cmd.CreateViewRequest(caseId=caseId)).createViewResult.viewId
|
||||
def create_view(self, case_id):
|
||||
return self.__execute(createView=Cmd.CreateViewRequest(caseId=case_id)).createViewResult.viewId
|
||||
|
||||
def cloneView(self, viewId):
|
||||
return self.__execute(cloneView=Cmd.CloneViewRequest(viewId=viewId)).createViewResult.viewId
|
||||
def clone_view(self, view_id):
|
||||
return self.__execute(cloneView=Cmd.CloneViewRequest(viewId=view_id)).createViewResult.viewId
|
||||
@@ -161,7 +161,7 @@ class Instance:
|
||||
self.project = Project(self.channel)
|
||||
|
||||
path = os.getcwd()
|
||||
self.commands.setStartDir(path=path)
|
||||
self.commands.set_start_dir(path=path)
|
||||
|
||||
def __versionMessage(self):
|
||||
return self.app.GetVersion(Empty())
|
||||
|
||||
@@ -31,12 +31,12 @@ class Project (PdmObject):
|
||||
path(str): path to project file
|
||||
|
||||
"""
|
||||
Commands(self.channel).openProject(path)
|
||||
Commands(self.channel).open_project(path)
|
||||
return self
|
||||
|
||||
def close(self):
|
||||
"""Close the current project (and open new blank project)"""
|
||||
Commands(self.channel).closeProject()
|
||||
Commands(self.channel).close_project()
|
||||
|
||||
def selectedCases(self):
|
||||
"""Get a list of all cases selected in the project tree
|
||||
@@ -84,7 +84,7 @@ class Project (PdmObject):
|
||||
except grpc.RpcError as e:
|
||||
return None
|
||||
|
||||
def loadCase(self, path):
|
||||
def load_case(self, path):
|
||||
"""Load a new case from the given file path
|
||||
|
||||
Arguments:
|
||||
@@ -92,7 +92,7 @@ class Project (PdmObject):
|
||||
Returns:
|
||||
A rips Case object
|
||||
"""
|
||||
return Commands(self.channel).loadCase(path)
|
||||
return Commands(self.channel).load_case(path)
|
||||
|
||||
def views(self):
|
||||
"""Get a list of views belonging to a project"""
|
||||
@@ -138,12 +138,12 @@ class Project (PdmObject):
|
||||
return caseGroup
|
||||
return None
|
||||
|
||||
def createGridCaseGroup(self, casePaths):
|
||||
def create_grid_case_group(self, casePaths):
|
||||
"""Create a new grid case group from the provided case paths
|
||||
Arguments:
|
||||
casePaths(list): a list of paths to the cases to be loaded and included in the group
|
||||
Returns:
|
||||
A new grid case group object
|
||||
"""
|
||||
groupId, groupName = Commands(self.channel).createGridCaseGroup(casePaths)
|
||||
groupId, groupName = Commands(self.channel).create_grid_case_group(casePaths)
|
||||
return self.gridCaseGroup(groupId)
|
||||
@@ -7,10 +7,10 @@
|
||||
import rips
|
||||
|
||||
# Connect to ResInsight
|
||||
resInsight = rips.Instance.find()
|
||||
if resInsight is not None:
|
||||
resinsight = rips.Instance.find()
|
||||
if resinsight is not None:
|
||||
# Get a list of all cases
|
||||
cases = resInsight.project.cases()
|
||||
cases = resinsight.project.cases()
|
||||
|
||||
print ("Got " + str(len(cases)) + " cases: ")
|
||||
for case in cases:
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import rips
|
||||
|
||||
resInsight = rips.Instance.find()
|
||||
if resInsight is not None:
|
||||
print(resInsight.versionString())
|
||||
print("Is this a console run?", resInsight.isConsole())
|
||||
resinsight = rips.Instance.find()
|
||||
if resinsight is not None:
|
||||
print(resinsight.versionString())
|
||||
print("Is this a console run?", resinsight.isConsole())
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import os
|
||||
import rips
|
||||
|
||||
resInsight = rips.Instance.find()
|
||||
resinsight = rips.Instance.find()
|
||||
|
||||
casePaths = []
|
||||
casePaths.append("C:/Users/lindk/source/repos/ResInsight/TestModels/Case_with_10_timesteps/Real0/BRUGGE_0000.EGRID")
|
||||
@@ -9,7 +9,7 @@ casePaths.append("C:/Users/lindk/source/repos/ResInsight/TestModels/Case_with_10
|
||||
for casePath in casePaths:
|
||||
assert os.path.exists(casePath), "You need to set valid case paths for this script to work"
|
||||
|
||||
caseGroup = resInsight.project.createGridCaseGroup(casePaths=casePaths)
|
||||
caseGroup = resinsight.project.create_grid_case_group(casePaths=casePaths)
|
||||
|
||||
caseGroup.printObjectInfo()
|
||||
|
||||
@@ -20,7 +20,7 @@ caseGroup.printObjectInfo()
|
||||
# statCase.update()
|
||||
# caseIds.append(statCase.getValue("CaseId"))
|
||||
|
||||
resInsight.commands.computeCaseGroupStatistics(caseGroupId=caseGroup.groupId)
|
||||
resinsight.commands.compute_case_group_statistics(caseGroupId=caseGroup.groupId)
|
||||
|
||||
view = caseGroup.views()[0]
|
||||
cellResult = view.cellResult()
|
||||
|
||||
@@ -6,10 +6,10 @@
|
||||
import rips
|
||||
|
||||
# Connect to ResInsight
|
||||
resInsight = rips.Instance.find()
|
||||
resinsight = rips.Instance.find()
|
||||
|
||||
# Get the case with id == 0. This will fail if your project doesn't have a case with id == 0
|
||||
case = resInsight.project.case(id = 0)
|
||||
case = resinsight.project.case(id = 0)
|
||||
|
||||
# Get the cell count object
|
||||
cellCounts = case.cell_count()
|
||||
|
||||
@@ -8,11 +8,11 @@ import tempfile
|
||||
import rips
|
||||
|
||||
# Load instance
|
||||
resInsight = rips.Instance.find()
|
||||
resinsight = rips.Instance.find()
|
||||
|
||||
# Run a couple of commands
|
||||
resInsight.commands.setTimeStep(caseId=0, timeStep=3)
|
||||
resInsight.commands.setMainWindowSize(width=800, height=500)
|
||||
resinsight.commands.set_time_step(case_id=0, time_step=3)
|
||||
resinsight.commands.set_main_window_size(width=800, height=500)
|
||||
|
||||
# Create a temporary directory which will disappear at the end of this script
|
||||
# If you want to keep the files, provide a good path name instead of tmpdirname
|
||||
@@ -20,20 +20,20 @@ with tempfile.TemporaryDirectory(prefix="rips") as tmpdirname:
|
||||
print("Temporary folder: ", tmpdirname)
|
||||
|
||||
# Set export folder for snapshots and properties
|
||||
resInsight.commands.setExportFolder(type='SNAPSHOTS', path=tmpdirname)
|
||||
resInsight.commands.setExportFolder(type='PROPERTIES', path=tmpdirname)
|
||||
resinsight.commands.set_export_folder(type='SNAPSHOTS', path=tmpdirname)
|
||||
resinsight.commands.set_export_folder(type='PROPERTIES', path=tmpdirname)
|
||||
|
||||
# Export snapshots
|
||||
resInsight.commands.exportSnapshots()
|
||||
resinsight.commands.export_snapshots()
|
||||
|
||||
# Print contents of temporary folder
|
||||
print(os.listdir(tmpdirname))
|
||||
|
||||
assert(len(os.listdir(tmpdirname)) > 0)
|
||||
case = resInsight.project.case(id=0)
|
||||
case = resinsight.project.case(id=0)
|
||||
|
||||
# Export properties in the view
|
||||
resInsight.commands.exportPropertyInViews(0, "3D View", 0)
|
||||
resinsight.commands.export_property_in_views(0, "3D View", 0)
|
||||
|
||||
# Check that the exported file exists
|
||||
expectedFileName = case.name + "-" + str("3D_View") + "-" + "T3" + "-SOIL"
|
||||
|
||||
@@ -6,17 +6,17 @@
|
||||
import rips
|
||||
import grpc
|
||||
|
||||
resInsight = rips.Instance.find()
|
||||
resinsight = rips.Instance.find()
|
||||
|
||||
case = None
|
||||
|
||||
# Try loading a non-existing case. We should get a grpc.RpcError exception from the server
|
||||
try:
|
||||
case = resInsight.project.loadCase("Nonsense")
|
||||
case = resinsight.project.load_case("Nonsense")
|
||||
except grpc.RpcError as e:
|
||||
print("Expected Server Exception Received: ", e)
|
||||
|
||||
case = resInsight.project.case(id=0)
|
||||
case = resinsight.project.case(id=0)
|
||||
if case is not None:
|
||||
results = case.properties.activeCellProperty('STATIC_NATIVE', 'PORO', 0)
|
||||
activeCellCount = len(results)
|
||||
|
||||
@@ -6,38 +6,38 @@ import os
|
||||
import rips
|
||||
|
||||
# Load instance
|
||||
resInsight = rips.Instance.find()
|
||||
cases = resInsight.project.cases()
|
||||
resinsight = rips.Instance.find()
|
||||
cases = resinsight.project.cases()
|
||||
|
||||
# Set main window size
|
||||
resInsight.commands.setMainWindowSize(width=800, height=500)
|
||||
resinsight.commands.set_main_window_size(width=800, height=500)
|
||||
|
||||
n = 5 # every n-th timestep for snapshot
|
||||
n = 5 # every n-th time_step for snapshot
|
||||
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.grid_path()
|
||||
foldername = os.path.dirname(casepath)
|
||||
case_path = case.grid_path()
|
||||
folder_name = os.path.dirname(case_path)
|
||||
|
||||
# create a folder to hold the snapshots
|
||||
dirname = os.path.join(foldername, 'snapshots')
|
||||
dirname = os.path.join(folder_name, 'snapshots')
|
||||
|
||||
if os.path.exists(dirname) is False:
|
||||
os.mkdir(dirname)
|
||||
|
||||
print ("Exporting to folder: " + dirname)
|
||||
resInsight.commands.setExportFolder(type='SNAPSHOTS', path=dirname)
|
||||
resinsight.commands.set_export_folder(type='SNAPSHOTS', path=dirname)
|
||||
|
||||
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)))
|
||||
time_steps = case.time_steps()
|
||||
tss_snapshot = range(0, len(time_steps), n)
|
||||
print(case.name, case.id, 'Number of time_steps: ' + str(len(time_steps)))
|
||||
print('Number of time_steps for snapshoting: ' + str(len(tss_snapshot)))
|
||||
|
||||
view = case.views()[0]
|
||||
for property in property_list:
|
||||
view.applyCellResult(resultType='DYNAMIC_NATIVE', resultVariable=property)
|
||||
for ts_snapshot in tss_snapshot:
|
||||
resInsight.commands.setTimeStep(caseId = case.id, timeStep = ts_snapshot)
|
||||
resInsight.commands.exportSnapshots(type='VIEWS', caseId=case.id) # ‘ALL’, ‘VIEWS’ or ‘PLOTS’ default is 'ALL'
|
||||
resinsight.commands.set_time_step(case_id = case.id, time_step = ts_snapshot)
|
||||
resinsight.commands.export_snapshots(type='VIEWS', case_id=case.id) # ‘ALL’, ‘VIEWS’ or ‘PLOTS’ default is 'ALL'
|
||||
|
||||
@@ -4,9 +4,9 @@
|
||||
|
||||
import rips
|
||||
|
||||
resInsight = rips.Instance.find()
|
||||
resinsight = rips.Instance.find()
|
||||
|
||||
cases = resInsight.project.cases()
|
||||
cases = resinsight.project.cases()
|
||||
print("Number of cases found: ", len(cases))
|
||||
for case in cases:
|
||||
print(case.name)
|
||||
|
||||
@@ -17,9 +17,9 @@ def createResult(poroChunks, permxChunks):
|
||||
# Return a generator object that behaves like a Python iterator
|
||||
yield resultChunk
|
||||
|
||||
resInsight = rips.Instance.find()
|
||||
resinsight = rips.Instance.find()
|
||||
start = time.time()
|
||||
case = resInsight.project.case(id=0)
|
||||
case = resinsight.project.case(id=0)
|
||||
|
||||
# Get a generator for the poro results. The generator will provide a chunk each time it is iterated
|
||||
poroChunks = case.properties.activeCellPropertyAsync('STATIC_NATIVE', 'PORO', 0)
|
||||
|
||||
@@ -7,9 +7,9 @@ import rips
|
||||
import time
|
||||
import grpc
|
||||
|
||||
resInsight = rips.Instance.find()
|
||||
resinsight = rips.Instance.find()
|
||||
start = time.time()
|
||||
case = resInsight.project.case(id=0)
|
||||
case = resinsight.project.case(id=0)
|
||||
|
||||
# Read poro result into list
|
||||
poroResults = case.properties.activeCellProperty('STATIC_NATIVE', 'PORO', 0)
|
||||
|
||||
@@ -3,9 +3,9 @@
|
||||
#######################################
|
||||
import rips
|
||||
|
||||
resInsight = rips.Instance.find()
|
||||
resinsight = rips.Instance.find()
|
||||
|
||||
if resInsight is None:
|
||||
if resinsight is None:
|
||||
print('ERROR: could not find ResInsight')
|
||||
else:
|
||||
print('Successfully connected to ResInsight')
|
||||
@@ -1,9 +1,9 @@
|
||||
# Load ResInsight Processing Server Client Library
|
||||
import rips
|
||||
# Launch ResInsight with last project file and a Window size of 600x1000 pixels
|
||||
resInsight = rips.Instance.launch(commandLineParameters=['--last', '--size', 600, 1000])
|
||||
resinsight = rips.Instance.launch(commandLineParameters=['--last', '--size', 600, 1000])
|
||||
# Get a list of all cases
|
||||
cases = resInsight.project.cases()
|
||||
cases = resinsight.project.cases()
|
||||
|
||||
print ("Got " + str(len(cases)) + " cases: ")
|
||||
for case in cases:
|
||||
|
||||
@@ -7,9 +7,9 @@
|
||||
|
||||
import rips
|
||||
|
||||
resInsight = rips.Instance.find()
|
||||
if resInsight is not None:
|
||||
cases = resInsight.project.selectedCases()
|
||||
resinsight = rips.Instance.find()
|
||||
if resinsight is not None:
|
||||
cases = resinsight.project.selectedCases()
|
||||
|
||||
print ("Got " + str(len(cases)) + " cases: ")
|
||||
for case in cases:
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
######################################################################
|
||||
import rips
|
||||
|
||||
resInsight = rips.Instance.find()
|
||||
resinsight = rips.Instance.find()
|
||||
|
||||
view = resInsight.project.view(0)
|
||||
view = resinsight.project.view(0)
|
||||
view.applyCellResult(resultType='STATIC_NATIVE', resultVariable='DX')
|
||||
|
||||
@@ -5,9 +5,9 @@
|
||||
# Load ResInsight Processing Server Client Library
|
||||
import rips
|
||||
# Connect to ResInsight instance
|
||||
resInsight = rips.Instance.find()
|
||||
resinsight = rips.Instance.find()
|
||||
|
||||
view = resInsight.project.view(0)
|
||||
view = resinsight.project.view(0)
|
||||
#view.applyFlowDiagnosticsCellResult(resultVariable='Fraction',
|
||||
# selectionMode='FLOW_TR_INJ_AND_PROD')
|
||||
|
||||
|
||||
@@ -3,9 +3,9 @@
|
||||
######################################################################
|
||||
import rips
|
||||
|
||||
resInsight = rips.Instance.find()
|
||||
resinsight = rips.Instance.find()
|
||||
|
||||
case = resInsight.project.case(id=0)
|
||||
case = resinsight.project.case(id=0)
|
||||
totalCellCount = case.cell_count().reservoir_cell_count
|
||||
|
||||
values = []
|
||||
|
||||
@@ -6,12 +6,12 @@ import rips
|
||||
import itertools
|
||||
import time
|
||||
|
||||
resInsight = rips.Instance.find()
|
||||
resinsight = rips.Instance.find()
|
||||
|
||||
start = time.time()
|
||||
|
||||
# Get the case with case id 0
|
||||
case = resInsight.project.case(id=0)
|
||||
case = resinsight.project.case(id=0)
|
||||
|
||||
# Get a list of all time steps
|
||||
timeSteps = case.time_steps()
|
||||
|
||||
@@ -5,13 +5,13 @@ import rips
|
||||
import itertools
|
||||
import time
|
||||
|
||||
resInsight = rips.Instance.find()
|
||||
resinsight = rips.Instance.find()
|
||||
|
||||
start = time.time()
|
||||
case = resInsight.project.case(id=0)
|
||||
case = resinsight.project.case(id=0)
|
||||
|
||||
# Get the case with case id 0
|
||||
case = resInsight.project.case(id=0)
|
||||
case = resinsight.project.case(id=0)
|
||||
|
||||
# Get a list of all time steps
|
||||
timeSteps = case.time_steps()
|
||||
|
||||
@@ -16,9 +16,9 @@ def createResult(soilChunks, porvChunks):
|
||||
# Return a Python generator
|
||||
yield resultChunk
|
||||
|
||||
resInsight = rips.Instance.find()
|
||||
resinsight = rips.Instance.find()
|
||||
start = time.time()
|
||||
case = resInsight.project.case(id=0)
|
||||
case = resinsight.project.case(id=0)
|
||||
timeStepInfo = case.time_steps()
|
||||
|
||||
# Get a generator for the porv results. The generator will provide a chunk each time it is iterated
|
||||
|
||||
@@ -5,9 +5,9 @@
|
||||
import rips
|
||||
import time
|
||||
|
||||
resInsight = rips.Instance.find()
|
||||
resinsight = rips.Instance.find()
|
||||
start = time.time()
|
||||
case = resInsight.project.case(id=0)
|
||||
case = resinsight.project.case(id=0)
|
||||
|
||||
# Read the full porv result
|
||||
porvResults = case.properties.activeCellProperty('STATIC_NATIVE', 'PORV', 0)
|
||||
|
||||
@@ -5,12 +5,12 @@
|
||||
#############################################################
|
||||
import rips
|
||||
# Connect to ResInsight instance
|
||||
resInsight = rips.Instance.find()
|
||||
resinsight = rips.Instance.find()
|
||||
|
||||
# Check if connection worked
|
||||
if resInsight is not None:
|
||||
if resinsight is not None:
|
||||
# Get a list of all cases
|
||||
cases = resInsight.project.cases()
|
||||
cases = resinsight.project.cases()
|
||||
for case in cases:
|
||||
# Get a list of all views
|
||||
views = case.views()
|
||||
|
||||
@@ -96,5 +96,5 @@ class View (PdmObject):
|
||||
|
||||
def clone(self):
|
||||
"""Clone the current view"""
|
||||
viewId = Commands(self.channel).cloneView(self.id)
|
||||
viewId = Commands(self.channel).clone_view(self.id)
|
||||
return self.case().view(viewId)
|
||||
@@ -13,9 +13,9 @@ def rips_instance():
|
||||
return _rips_instance
|
||||
|
||||
@pytest.fixture
|
||||
def initializeTest():
|
||||
def initialize_test():
|
||||
_rips_instance.project.close() # make sure ResInsight is clean before execution of test
|
||||
yield initializeTest
|
||||
yield initialize_test
|
||||
_rips_instance.project.close() # make sure ResInsight is clean after test
|
||||
|
||||
def pytest_addoption(parser):
|
||||
|
||||
@@ -7,21 +7,21 @@ import rips
|
||||
|
||||
import dataroot
|
||||
|
||||
def test_Launch(rips_instance, initializeTest):
|
||||
def test_Launch(rips_instance, initialize_test):
|
||||
assert(rips_instance is not None)
|
||||
|
||||
def test_EmptyProject(rips_instance, initializeTest):
|
||||
def test_EmptyProject(rips_instance, initialize_test):
|
||||
cases = rips_instance.project.cases()
|
||||
assert(len(cases) is 0)
|
||||
|
||||
def test_OneCase(rips_instance, initializeTest):
|
||||
case = rips_instance.project.loadCase(dataroot.PATH + "/TEST10K_FLT_LGR_NNC/TEST10K_FLT_LGR_NNC.EGRID")
|
||||
def test_OneCase(rips_instance, initialize_test):
|
||||
case = rips_instance.project.load_case(dataroot.PATH + "/TEST10K_FLT_LGR_NNC/TEST10K_FLT_LGR_NNC.EGRID")
|
||||
assert(case.name == "TEST10K_FLT_LGR_NNC")
|
||||
assert(case.id == 0)
|
||||
cases = rips_instance.project.cases()
|
||||
assert(len(cases) is 1)
|
||||
|
||||
def test_MultipleCases(rips_instance, initializeTest):
|
||||
def test_MultipleCases(rips_instance, initialize_test):
|
||||
casePaths = []
|
||||
casePaths.append(dataroot.PATH + "/TEST10K_FLT_LGR_NNC/TEST10K_FLT_LGR_NNC.EGRID")
|
||||
casePaths.append(dataroot.PATH + "/TEST10K_FLT_LGR_NNC/TEST10K_FLT_LGR_NNC.EGRID")
|
||||
@@ -31,16 +31,16 @@ def test_MultipleCases(rips_instance, initializeTest):
|
||||
for casePath in casePaths:
|
||||
caseName = os.path.splitext(os.path.basename(casePath))[0]
|
||||
caseNames.append(caseName)
|
||||
rips_instance.project.loadCase(path=casePath)
|
||||
rips_instance.project.load_case(path=casePath)
|
||||
|
||||
cases = rips_instance.project.cases()
|
||||
assert(len(cases) == len(caseNames))
|
||||
for i, caseName in enumerate(caseNames):
|
||||
assert(caseName == cases[i].name)
|
||||
|
||||
def test_10k(rips_instance, initializeTest):
|
||||
def test_10k(rips_instance, initialize_test):
|
||||
casePath = dataroot.PATH + "/TEST10K_FLT_LGR_NNC/TEST10K_FLT_LGR_NNC.EGRID"
|
||||
case = rips_instance.project.loadCase(path=casePath)
|
||||
case = rips_instance.project.load_case(path=casePath)
|
||||
assert(case.grid_count() == 2)
|
||||
cellCountInfo = case.cell_count()
|
||||
assert(cellCountInfo.active_cell_count == 11125)
|
||||
@@ -50,9 +50,9 @@ def test_10k(rips_instance, initializeTest):
|
||||
daysSinceStart = case.days_since_start()
|
||||
assert(len(daysSinceStart) == 9)
|
||||
|
||||
def test_PdmObject(rips_instance, initializeTest):
|
||||
def test_PdmObject(rips_instance, initialize_test):
|
||||
casePath = dataroot.PATH + "/TEST10K_FLT_LGR_NNC/TEST10K_FLT_LGR_NNC.EGRID"
|
||||
case = rips_instance.project.loadCase(path=casePath)
|
||||
case = rips_instance.project.load_case(path=casePath)
|
||||
assert(case.id == 0)
|
||||
assert(case.address() is not 0)
|
||||
assert(case.classKeyword() == "EclipseCase")
|
||||
@@ -60,9 +60,9 @@ def test_PdmObject(rips_instance, initializeTest):
|
||||
assert(caseId == case.id)
|
||||
|
||||
@pytest.mark.skipif(sys.platform.startswith('linux'), reason="Brugge is currently exceptionally slow on Linux")
|
||||
def test_brugge_0010(rips_instance, initializeTest):
|
||||
def test_brugge_0010(rips_instance, initialize_test):
|
||||
casePath = dataroot.PATH + "/Case_with_10_timesteps/Real10/BRUGGE_0010.EGRID"
|
||||
case = rips_instance.project.loadCase(path=casePath)
|
||||
case = rips_instance.project.load_case(path=casePath)
|
||||
assert(case.grid_count() == 1)
|
||||
cellCountInfo = case.cell_count()
|
||||
assert(cellCountInfo.active_cell_count == 43374)
|
||||
@@ -73,7 +73,7 @@ def test_brugge_0010(rips_instance, initializeTest):
|
||||
assert(len(daysSinceStart) == 11)
|
||||
|
||||
@pytest.mark.skipif(sys.platform.startswith('linux'), reason="Brugge is currently exceptionally slow on Linux")
|
||||
def test_replaceCase(rips_instance, initializeTest):
|
||||
def test_replaceCase(rips_instance, initialize_test):
|
||||
project = rips_instance.project.open(dataroot.PATH + "/TEST10K_FLT_LGR_NNC/10KWithWellLog.rsp")
|
||||
casePath = dataroot.PATH + "/Case_with_10_timesteps/Real0/BRUGGE_0000.EGRID"
|
||||
case = project.case(id=0)
|
||||
@@ -83,7 +83,7 @@ def test_replaceCase(rips_instance, initializeTest):
|
||||
cases = rips_instance.project.cases()
|
||||
assert(len(cases) is 1)
|
||||
|
||||
rips_instance.commands.replaceCase(newGridFile=casePath, caseId=case.id)
|
||||
rips_instance.commands.replace_case(newGridFile=casePath, caseId=case.id)
|
||||
cases = rips_instance.project.cases()
|
||||
assert(len(cases) is 1)
|
||||
case = project.case(id=0)
|
||||
|
||||
@@ -9,50 +9,50 @@ import rips
|
||||
|
||||
import dataroot
|
||||
|
||||
def test_exportSnapshots(rips_instance, initializeTest):
|
||||
def test_exportSnapshots(rips_instance, initialize_test):
|
||||
if not rips_instance.isGui():
|
||||
pytest.skip("Cannot run test without a GUI")
|
||||
|
||||
casePath = dataroot.PATH + "/TEST10K_FLT_LGR_NNC/TEST10K_FLT_LGR_NNC.EGRID"
|
||||
rips_instance.project.loadCase(casePath)
|
||||
case_path = dataroot.PATH + "/TEST10K_FLT_LGR_NNC/TEST10K_FLT_LGR_NNC.EGRID"
|
||||
rips_instance.project.load_case(case_path)
|
||||
with tempfile.TemporaryDirectory(prefix="rips") as tmpdirname:
|
||||
print("Temporary folder: ", tmpdirname)
|
||||
rips_instance.commands.setExportFolder(type='SNAPSHOTS', path=tmpdirname)
|
||||
rips_instance.commands.exportSnapshots()
|
||||
rips_instance.commands.set_export_folder(type='SNAPSHOTS', path=tmpdirname)
|
||||
rips_instance.commands.export_snapshots()
|
||||
print(os.listdir(tmpdirname))
|
||||
assert(len(os.listdir(tmpdirname)) > 0)
|
||||
for fileName in os.listdir(tmpdirname):
|
||||
assert(os.path.splitext(fileName)[1] == '.png')
|
||||
|
||||
def test_exportPropertyInView(rips_instance, initializeTest):
|
||||
casePath = dataroot.PATH + "/TEST10K_FLT_LGR_NNC/TEST10K_FLT_LGR_NNC.EGRID"
|
||||
rips_instance.project.loadCase(casePath)
|
||||
def test_exportPropertyInView(rips_instance, initialize_test):
|
||||
case_path = dataroot.PATH + "/TEST10K_FLT_LGR_NNC/TEST10K_FLT_LGR_NNC.EGRID"
|
||||
rips_instance.project.load_case(case_path)
|
||||
with tempfile.TemporaryDirectory(prefix="rips") as tmpdirname:
|
||||
print("Temporary folder: ", tmpdirname)
|
||||
rips_instance.commands.setExportFolder(type='PROPERTIES', path=tmpdirname)
|
||||
rips_instance.commands.set_export_folder(type='PROPERTIES', path=tmpdirname)
|
||||
case = rips_instance.project.case(id=0)
|
||||
rips_instance.commands.exportPropertyInViews(0, "3D View", 0)
|
||||
expectedFileName = case.name + "-" + str("3D_View") + "-" + "T0" + "-SOIL"
|
||||
fullPath = tmpdirname + "/" + expectedFileName
|
||||
assert(os.path.exists(fullPath))
|
||||
rips_instance.commands.export_property_in_views(0, "3D View", 0)
|
||||
expected_file_name = case.name + "-" + str("3D_View") + "-" + "T0" + "-SOIL"
|
||||
full_path = tmpdirname + "/" + expected_file_name
|
||||
assert(os.path.exists(full_path))
|
||||
|
||||
@pytest.mark.skipif(sys.platform.startswith('linux'), reason="Brugge is currently exceptionally slow on Linux")
|
||||
def test_loadGridCaseGroup(rips_instance, initializeTest):
|
||||
casePaths = []
|
||||
casePaths.append(dataroot.PATH + "/Case_with_10_timesteps/Real0/BRUGGE_0000.EGRID")
|
||||
casePaths.append(dataroot.PATH + "/Case_with_10_timesteps/Real10/BRUGGE_0010.EGRID")
|
||||
groupId, groupName = rips_instance.commands.createGridCaseGroup(casePaths=casePaths)
|
||||
print(groupId, groupName)
|
||||
def test_loadGridCaseGroup(rips_instance, initialize_test):
|
||||
case_paths = []
|
||||
case_paths.append(dataroot.PATH + "/Case_with_10_timesteps/Real0/BRUGGE_0000.EGRID")
|
||||
case_paths.append(dataroot.PATH + "/Case_with_10_timesteps/Real10/BRUGGE_0010.EGRID")
|
||||
group_id, group_name = rips_instance.commands.create_grid_case_group(case_paths=case_paths)
|
||||
print(group_id, group_name)
|
||||
|
||||
def test_exportFlowCharacteristics(rips_instance, initializeTest):
|
||||
casePath = dataroot.PATH + "/Case_with_10_timesteps/Real0/BRUGGE_0000.EGRID"
|
||||
rips_instance.project.loadCase(casePath)
|
||||
def test_exportFlowCharacteristics(rips_instance, initialize_test):
|
||||
case_path = dataroot.PATH + "/Case_with_10_timesteps/Real0/BRUGGE_0000.EGRID"
|
||||
rips_instance.project.load_case(case_path)
|
||||
with tempfile.TemporaryDirectory(prefix="rips") as tmpdirname:
|
||||
print("Temporary folder: ", tmpdirname)
|
||||
fileName = tmpdirname + "/exportFlowChar.txt"
|
||||
rips_instance.commands.exportFlowCharacteristics(caseId=0, timeSteps=8, producers=[], injectors = "I01", fileName = fileName)
|
||||
file_name = tmpdirname + "/exportFlowChar.txt"
|
||||
rips_instance.commands.export_flow_characteristics(case_id=0, time_steps=8, producers=[], injectors = "I01", file_name = file_name)
|
||||
|
||||
def test_loadNonExistingCase(rips_instance, initializeTest):
|
||||
casePath = "Nonsense/Nonsense/Nonsense"
|
||||
def test_loadNonExistingCase(rips_instance, initialize_test):
|
||||
case_path = "Nonsense/Nonsense/Nonsense"
|
||||
with pytest.raises(grpc.RpcError):
|
||||
assert rips_instance.project.loadCase(casePath)
|
||||
assert rips_instance.project.load_case(case_path)
|
||||
|
||||
@@ -6,9 +6,9 @@ import rips
|
||||
|
||||
import dataroot
|
||||
|
||||
def test_10k(rips_instance, initializeTest):
|
||||
def test_10k(rips_instance, initialize_test):
|
||||
casePath = dataroot.PATH + "/TEST10K_FLT_LGR_NNC/TEST10K_FLT_LGR_NNC.EGRID"
|
||||
case = rips_instance.project.loadCase(path=casePath)
|
||||
case = rips_instance.project.load_case(path=casePath)
|
||||
assert(case.grid_count() == 2)
|
||||
grid = case.grid(index=0)
|
||||
dimensions = grid.dimensions()
|
||||
|
||||
@@ -7,7 +7,7 @@ import rips
|
||||
|
||||
import dataroot
|
||||
|
||||
def test_loadProject(rips_instance, initializeTest):
|
||||
def test_loadProject(rips_instance, initialize_test):
|
||||
project = rips_instance.project.open(dataroot.PATH + "/TEST10K_FLT_LGR_NNC/10KWithWellLog.rsp")
|
||||
case = project.case(id=0)
|
||||
assert(case is not None)
|
||||
|
||||
@@ -8,9 +8,9 @@ import rips
|
||||
|
||||
import dataroot
|
||||
|
||||
def test_10kAsync(rips_instance, initializeTest):
|
||||
def test_10kAsync(rips_instance, initialize_test):
|
||||
casePath = dataroot.PATH + "/TEST10K_FLT_LGR_NNC/TEST10K_FLT_LGR_NNC.EGRID"
|
||||
case = rips_instance.project.loadCase(path=casePath)
|
||||
case = rips_instance.project.load_case(path=casePath)
|
||||
|
||||
resultChunks = case.properties.activeCellPropertyAsync('DYNAMIC_NATIVE', 'SOIL', 1)
|
||||
mysum = 0.0
|
||||
@@ -23,9 +23,9 @@ def test_10kAsync(rips_instance, initializeTest):
|
||||
assert(average != pytest.approx(0.0158893, abs=0.0000001))
|
||||
assert(average == pytest.approx(0.0558893, abs=0.0000001))
|
||||
|
||||
def test_10kSync(rips_instance, initializeTest):
|
||||
def test_10kSync(rips_instance, initialize_test):
|
||||
casePath = dataroot.PATH + "/TEST10K_FLT_LGR_NNC/TEST10K_FLT_LGR_NNC.EGRID"
|
||||
case = rips_instance.project.loadCase(path=casePath)
|
||||
case = rips_instance.project.load_case(path=casePath)
|
||||
|
||||
results = case.properties.activeCellProperty('DYNAMIC_NATIVE', 'SOIL', 1)
|
||||
mysum = sum(results)
|
||||
@@ -34,25 +34,25 @@ def test_10kSync(rips_instance, initializeTest):
|
||||
assert(average != pytest.approx(0.0158893, abs=0.0000001))
|
||||
assert(average == pytest.approx(0.0558893, abs=0.0000001))
|
||||
|
||||
def test_10k_set(rips_instance, initializeTest):
|
||||
def test_10k_set(rips_instance, initialize_test):
|
||||
casePath = dataroot.PATH + "/TEST10K_FLT_LGR_NNC/TEST10K_FLT_LGR_NNC.EGRID"
|
||||
case = rips_instance.project.loadCase(path=casePath)
|
||||
case = rips_instance.project.load_case(path=casePath)
|
||||
|
||||
results = case.properties.activeCellProperty('DYNAMIC_NATIVE', 'SOIL', 1)
|
||||
case.properties.setActiveCellProperty(results, 'GENERATED', 'SOIL', 1)
|
||||
|
||||
def test_10k_set_out_of_bounds(rips_instance, initializeTest):
|
||||
def test_10k_set_out_of_bounds(rips_instance, initialize_test):
|
||||
casePath = dataroot.PATH + "/TEST10K_FLT_LGR_NNC/TEST10K_FLT_LGR_NNC.EGRID"
|
||||
case = rips_instance.project.loadCase(path=casePath)
|
||||
case = rips_instance.project.load_case(path=casePath)
|
||||
|
||||
results = case.properties.activeCellProperty('DYNAMIC_NATIVE', 'SOIL', 1)
|
||||
results.append(5.0)
|
||||
with pytest.raises(grpc.RpcError):
|
||||
assert case.properties.setActiveCellProperty(results, 'GENERATED', 'SOIL', 1)
|
||||
|
||||
def test_10k_set_out_of_bounds_client(rips_instance, initializeTest):
|
||||
def test_10k_set_out_of_bounds_client(rips_instance, initialize_test):
|
||||
casePath = dataroot.PATH + "/TEST10K_FLT_LGR_NNC/TEST10K_FLT_LGR_NNC.EGRID"
|
||||
case = rips_instance.project.loadCase(path=casePath)
|
||||
case = rips_instance.project.load_case(path=casePath)
|
||||
|
||||
results = case.properties.activeCellProperty('DYNAMIC_NATIVE', 'SOIL', 1)
|
||||
case.properties.chunkSize = len(results)
|
||||
@@ -72,9 +72,9 @@ def checkResults(poroValues, permxValues, poropermxValues):
|
||||
recalc = poro * permx
|
||||
assert(recalc == pytest.approx(poropermx, rel=1.0e-10))
|
||||
|
||||
def test_10k_PoroPermX(rips_instance, initializeTest):
|
||||
def test_10k_PoroPermX(rips_instance, initialize_test):
|
||||
casePath = dataroot.PATH + "/TEST10K_FLT_LGR_NNC/TEST10K_FLT_LGR_NNC.EGRID"
|
||||
case = rips_instance.project.loadCase(path=casePath)
|
||||
case = rips_instance.project.load_case(path=casePath)
|
||||
|
||||
poroChunks = case.properties.activeCellPropertyAsync('STATIC_NATIVE', 'PORO', 0)
|
||||
permxChunks = case.properties.activeCellPropertyAsync('STATIC_NATIVE', 'PERMX', 0)
|
||||
|
||||
Reference in New Issue
Block a user