Files
ResInsight/GrpcInterface/Python/rips/PythonExamples/soil_average_sync.py

28 lines
818 B
Python
Raw Permalink Normal View History

###########################################################################################
# This example will synchronously calculate the average value for SOIL for all time steps
###########################################################################################
import rips
import itertools
import time
2021-01-26 20:48:01 +01:00
resinsight = rips.Instance.find()
2021-01-26 20:48:01 +01:00
start = time.time()
# Get the case with case id 0
2021-01-26 20:48:01 +01:00
case = resinsight.project.case(case_id=0)
# Get a list of all time steps
2021-01-26 20:48:01 +01:00
time_steps = case.time_steps()
averages = []
2019-09-19 15:14:01 +02:00
for i in range(0, len(time_steps)):
# Get a list of all the results for time step i
2021-01-26 20:48:01 +01:00
results = case.active_cell_property("DYNAMIC_NATIVE", "SOIL", i)
mysum = sum(results)
averages.append(mysum / len(results))
end = time.time()
print("Time elapsed: ", end - start)
2021-01-26 20:48:01 +01:00
print(averages)