2019-08-19 13:46:14 +02:00
|
|
|
|
############################################################################
|
|
|
|
|
|
# This script will export snapshots for two properties in every loaded case
|
|
|
|
|
|
# And put them in a snapshots folder in the same folder as the case grid
|
|
|
|
|
|
############################################################################
|
|
|
|
|
|
import os
|
|
|
|
|
|
import rips
|
|
|
|
|
|
|
|
|
|
|
|
# Load instance
|
2019-09-19 13:25:04 +02:00
|
|
|
|
resinsight = rips.Instance.find()
|
|
|
|
|
|
cases = resinsight.project.cases()
|
2019-08-19 13:46:14 +02:00
|
|
|
|
|
|
|
|
|
|
# Set main window size
|
2019-09-19 13:25:04 +02:00
|
|
|
|
resinsight.commands.set_main_window_size(width=800, height=500)
|
2019-08-19 13:46:14 +02:00
|
|
|
|
|
2019-09-19 13:25:04 +02:00
|
|
|
|
n = 5 # every n-th time_step for snapshot
|
2019-08-19 13:46:14 +02:00
|
|
|
|
property_list = ['SOIL', 'PRESSURE'] # list of parameter for snapshot
|
|
|
|
|
|
|
|
|
|
|
|
print ("Looping through cases")
|
|
|
|
|
|
for case in cases:
|
|
|
|
|
|
# Get grid path and its folder name
|
2019-09-19 13:25:04 +02:00
|
|
|
|
case_path = case.grid_path()
|
|
|
|
|
|
folder_name = os.path.dirname(case_path)
|
2019-08-19 13:46:14 +02:00
|
|
|
|
|
|
|
|
|
|
# create a folder to hold the snapshots
|
2019-09-19 13:25:04 +02:00
|
|
|
|
dirname = os.path.join(folder_name, 'snapshots')
|
2019-08-19 13:46:14 +02:00
|
|
|
|
|
|
|
|
|
|
if os.path.exists(dirname) is False:
|
|
|
|
|
|
os.mkdir(dirname)
|
|
|
|
|
|
|
|
|
|
|
|
print ("Exporting to folder: " + dirname)
|
2019-09-19 13:25:04 +02:00
|
|
|
|
resinsight.commands.set_export_folder(type='SNAPSHOTS', path=dirname)
|
2019-08-19 13:46:14 +02:00
|
|
|
|
|
2019-09-19 13:25:04 +02:00
|
|
|
|
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)))
|
2019-08-19 13:46:14 +02:00
|
|
|
|
|
2019-08-21 15:11:29 +02:00
|
|
|
|
view = case.views()[0]
|
2019-08-19 13:46:14 +02:00
|
|
|
|
for property in property_list:
|
|
|
|
|
|
view.applyCellResult(resultType='DYNAMIC_NATIVE', resultVariable=property)
|
|
|
|
|
|
for ts_snapshot in tss_snapshot:
|
2019-09-19 13:25:04 +02:00
|
|
|
|
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'
|