ResInsight/ApplicationCode/GrpcInterface/Python/rips/PythonExamples/SoilAverageSync.py
Gaute Lindkvist a2bad82391
#4736 System python command refactor (#4743)
* Move case loading commands from Commands to project and case
* Major refactor
* Fix problems with Python examples
* Add ability to export snapshot from just one view + fixup
* Case comments and black
* Make all modules pass pylint test
2019-09-23 11:50:33 +02:00

27 lines
834 B
Python

###########################################################################################
# This example will synchronously calculate the average value for SOIL for all time steps
###########################################################################################
import rips
import itertools
import time
resinsight = rips.Instance.find()
start = time.time()
# Get the case with case id 0
case = resinsight.project.case(case_id=0)
# Get a list of all time steps
time_steps = case.time_steps()
averages = []
for i in range(0, len(time_steps)):
# Get a list of all the results for time step i
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)
print(averages)