2019-08-19 13:46:14 +02:00
|
|
|
########################################################################################
|
|
|
|
|
# This example generates a derived property in an asynchronous manner
|
|
|
|
|
# Meaning it does not wait for all the data for each stage to be read before proceeding
|
|
|
|
|
########################################################################################
|
2019-06-03 21:11:27 +02:00
|
|
|
import rips
|
2019-06-04 10:34:31 +02:00
|
|
|
import time
|
2019-05-30 18:52:38 +02:00
|
|
|
|
2019-08-19 13:46:14 +02:00
|
|
|
# Internal function for creating a result from a small chunk of poro and permx results
|
|
|
|
|
# The return value of the function is a generator for the results rather than the result itself.
|
2019-05-30 18:52:38 +02:00
|
|
|
def createResult(poroChunks, permxChunks):
|
2019-08-19 13:46:14 +02:00
|
|
|
# Loop through all the chunks of poro and permx in order
|
2019-05-30 18:52:38 +02:00
|
|
|
for (poroChunk, permxChunk) in zip(poroChunks, permxChunks):
|
|
|
|
|
resultChunk = []
|
2019-08-19 13:46:14 +02:00
|
|
|
# Loop through all the values inside the chunks, in order
|
2019-05-30 18:52:38 +02:00
|
|
|
for (poro, permx) in zip(poroChunk.values, permxChunk.values):
|
|
|
|
|
resultChunk.append(poro * permx)
|
2019-08-19 13:46:14 +02:00
|
|
|
# Return a generator object that behaves like a Python iterator
|
2019-05-30 18:52:38 +02:00
|
|
|
yield resultChunk
|
|
|
|
|
|
2019-06-03 21:11:27 +02:00
|
|
|
resInsight = rips.Instance.find()
|
2019-06-04 10:34:31 +02:00
|
|
|
start = time.time()
|
2019-06-03 14:33:16 +02:00
|
|
|
case = resInsight.project.case(id=0)
|
2019-05-30 18:52:38 +02:00
|
|
|
|
2019-08-19 13:46:14 +02:00
|
|
|
# Get a generator for the poro results. The generator will provide a chunk each time it is iterated
|
2019-08-07 23:33:08 +02:00
|
|
|
poroChunks = case.properties.activeCellPropertyAsync('STATIC_NATIVE', 'PORO', 0)
|
2019-08-19 13:46:14 +02:00
|
|
|
# Get a generator for the permx results. The generator will provide a chunk each time it is iterated
|
2019-08-07 23:33:08 +02:00
|
|
|
permxChunks = case.properties.activeCellPropertyAsync('STATIC_NATIVE', 'PERMX', 0)
|
2019-05-30 18:52:38 +02:00
|
|
|
|
2019-08-19 13:46:14 +02:00
|
|
|
# Send back the result with the result provided by a generator object.
|
|
|
|
|
# Iterating the result generator will cause the script to read from the poro and permx generators
|
|
|
|
|
# And return the result of each iteration
|
2019-06-14 16:07:09 +02:00
|
|
|
case.properties.setActiveCellPropertyAsync(createResult(poroChunks, permxChunks),
|
|
|
|
|
'GENERATED', 'POROPERMXAS', 0)
|
2019-05-30 18:52:38 +02:00
|
|
|
|
2019-06-04 10:34:31 +02:00
|
|
|
end = time.time()
|
|
|
|
|
print("Time elapsed: ", end - start)
|
2019-08-19 13:46:14 +02:00
|
|
|
print("Transferred all results back")
|
|
|
|
|
view = case.views()[0].applyCellResult('GENERATED', 'POROPERMXAS')
|