Skip to content

Commit

Permalink
Update Python library
Browse files Browse the repository at this point in the history
  • Loading branch information
magnesj committed Mar 16, 2023
1 parent cd9d0f5 commit 9e0313e
Show file tree
Hide file tree
Showing 22 changed files with 27 additions and 39 deletions.
2 changes: 1 addition & 1 deletion docs/rips/PythonExamples/all_simulation_wells.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
for sim_well in sim_wells:
print("Simulation well: " + sim_well.name)

for (tidx, timestep) in enumerate(timesteps):
for tidx, timestep in enumerate(timesteps):
status = sim_well.status(tidx)
cells = sim_well.cells(tidx)
print(
Expand Down
11 changes: 1 addition & 10 deletions docs/rips/PythonExamples/case_grid_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,7 @@

case_group = resinsight.project.create_grid_case_group(case_paths=case_paths)

case_group.print_object_info()

# stat_cases = caseGroup.statistics_cases()
# case_ids = []
# for stat_case in stat_cases:
# stat_case.set_dynamic_properties_to_calculate(["SWAT"])
# case_ids.append(stat_case.id)

case_group.compute_statistics()

view = case_group.views()[0]
cell_result = view.cell_result()
cell_result.set_result_variable("PRESSURE_DEV")
view.apply_cell_result("DYNAMIC_NATIVE", "PRESSURE_DEV")
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@
# Create and export a StimPlan model for each depth
measured_depths = [3200.0, 3400.0, 3600.0]
for measured_depth in measured_depths:

# Create stim plan model at a give measured depth
stim_plan_model = stim_plan_model_collection.append_stim_plan_model(
well_path=well_path,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ def generate_surface_from_file(path):


def export_surface_as_ts_file(surf, point_cloud, properties, path):

# open text file
text_file = open(path, "w")

Expand Down Expand Up @@ -93,7 +92,6 @@ def export_surface_as_ts_file(surf, point_cloud, properties, path):
home_dir = expanduser("~")

for fracture in fractures:

fracture_name = fracture.user_description

# Create the ouput directory
Expand Down
4 changes: 2 additions & 2 deletions docs/rips/PythonExamples/export_contour_maps.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
print("Number of eclipse contour maps:", len(contour_maps))

# Export the contour maps to a text file
for (index, contour_map) in enumerate(contour_maps):
for index, contour_map in enumerate(contour_maps):
filename = "eclipse_contour_map" + str(index) + ".txt"
filepath = tmpdir / filename
print("Exporting to:", filepath)
Expand All @@ -25,7 +25,7 @@
for case in cases:
contour_maps = case.descendants(rips.GeoMechContourMap)
# Export the contour maps to a text file
for (index, contour_map) in enumerate(contour_maps):
for index, contour_map in enumerate(contour_maps):
filename = "geomech_contour_map" + str(index) + ".txt"
filepath = tmpdir / filename
print("Exporting to:", filepath)
Expand Down
2 changes: 1 addition & 1 deletion docs/rips/PythonExamples/generate_ensemble_of_well_logs.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
well_log_plot = well_log_plot_collection.new_well_log_plot(case, well_path)

# Create a track for each property
for (prop_type, prop_name, time_step) in properties:
for prop_type, prop_name, time_step in properties:
track = well_log_plot.new_well_log_track(
"Track: " + prop_name, case, well_path
)
Expand Down
1 change: 0 additions & 1 deletion docs/rips/PythonExamples/import_fractures_on_well.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
# Place fracture at given depths
measured_depths = [3200.0, 3400.0, 3600.0]
for measured_depth in measured_depths:

print("Placing fracture at {} depth (MD)".format(measured_depth))
# Create stim plan at a give measured depth
fracture = well_path.add_fracture(
Expand Down
5 changes: 3 additions & 2 deletions docs/rips/PythonExamples/input_prop_test_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@
import rips
import time


# 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.
def create_result(poro_chunks, permx_chunks):
# Loop through all the chunks of poro and permx in order
for (poroChunk, permxChunk) in zip(poro_chunks, permx_chunks):
for poroChunk, permxChunk in zip(poro_chunks, permx_chunks):
resultChunk = []
# Loop through all the values inside the chunks, in order
for (poro, permx) in zip(poroChunk.values, permxChunk.values):
for poro, permx in zip(poroChunk.values, permxChunk.values):
resultChunk.append(poro * permx)
# Return a generator object that behaves like a Python iterator
yield resultChunk
Expand Down
2 changes: 1 addition & 1 deletion docs/rips/PythonExamples/input_prop_test_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

# Generate output result
results = []
for (poro, permx) in zip(poro_results, permx_results):
for poro, permx in zip(poro_results, permx_results):
results.append(poro * permx)

try:
Expand Down
4 changes: 2 additions & 2 deletions docs/rips/PythonExamples/selected_cells.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

time_step_info = case.time_steps()

for (idx, cell) in enumerate(cells):
for idx, cell in enumerate(cells):
print(
"Selected cell: [{}, {}, {}] grid: {}".format(
cell.ijk.i + 1, cell.ijk.j + 1, cell.ijk.k + 1, cell.grid_index
Expand Down Expand Up @@ -56,7 +56,7 @@
print("c6:\n" + str(cell_corners.c6))
print("c7:\n" + str(cell_corners.c7))

for (tidx, timestep) in enumerate(time_step_info):
for tidx, timestep in enumerate(time_step_info):
# Read the full SOIL result for time step
soil_results = case.selected_cell_property(
"DYNAMIC_NATIVE", "SOIL", tidx
Expand Down
5 changes: 3 additions & 2 deletions docs/rips/PythonExamples/soil_porv_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@
import rips
import time


# Internal function for creating a result from a small chunk of soil and porv results
# The return value of the function is a generator for the results rather than the result itself.
def create_result(soil_chunks, porv_chunks):
for (soil_chunk, porv_chunk) in zip(soil_chunks, porv_chunks):
for soil_chunk, porv_chunk in zip(soil_chunks, porv_chunks):
resultChunk = []
number = 0
for (soil_value, porv_value) in zip(soil_chunk.values, porv_chunk.values):
for soil_value, porv_value in zip(soil_chunk.values, porv_chunk.values):
resultChunk.append(soil_value * porv_value)
# Return a Python generator
yield resultChunk
Expand Down
2 changes: 1 addition & 1 deletion docs/rips/PythonExamples/soil_porv_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

# Generate the result by looping through both lists in order
results = []
for (soil, porv) in zip(soil_results, porv_results):
for soil, porv in zip(soil_results, porv_results):
results.append(soil * porv)

# Send back result
Expand Down
2 changes: 1 addition & 1 deletion docs/rips/generated/RiaVersionInfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@
# Just sets version constants

RESINSIGHT_MAJOR_VERSION = "2023"
RESINSIGHT_MINOR_VERSION = "01"
RESINSIGHT_MINOR_VERSION = "03"
RESINSIGHT_PATCH_VERSION = "0"
2 changes: 1 addition & 1 deletion docs/rips/generated/generated_classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -1747,7 +1747,7 @@ def new_well_log_track(self, title="", case="", well_path=""):

class WellBoreStabilityPlot(WellLogPlot):
"""
A GeoMechanical Well Bore Stabilit Plot
A GeoMechanical Well Bore Stability Plot
"""
__custom_init__ = None #: Assign a custom init routine to be run at __init__
Expand Down
1 change: 1 addition & 0 deletions docs/rips/gridcasegroup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import Commands_pb2
from .resinsight_classes import GridCaseGroup
from .resinsight_classes import EclipseView


@add_method(GridCaseGroup)
Expand Down
2 changes: 0 additions & 2 deletions docs/rips/grpc_retry_interceptor.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,10 @@ def __init__(
self.status_for_retry = status_for_retry

def _intercept_call(self, continuation, client_call_details, request_or_iterator):

for retry_num in range(self.retry_policy.num_retries()):
response = continuation(client_call_details, request_or_iterator)

if isinstance(response, grpc.RpcError):

# Return if it was last attempt
if retry_num == (self.retry_policy.num_retries() - 1):
return response
Expand Down
4 changes: 2 additions & 2 deletions docs/rips/tests/test_cases.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def test_MultipleCases(rips_instance, initialize_test):


def get_cell_index_with_ijk(cell_info, i, j, k):
for (idx, cell) in enumerate(cell_info):
for idx, cell in enumerate(cell_info):
if cell.local_ijk.i == i and cell.local_ijk.j == j and cell.local_ijk.k == k:
return idx
return -1
Expand Down Expand Up @@ -216,7 +216,7 @@ def test_selected_cells(rips_instance, initialize_test):
assert len(selected_cells) == 0

time_step_info = case.time_steps()
for (tidx, timestep) in enumerate(time_step_info):
for tidx, timestep in enumerate(time_step_info):
# Try to read for SOIL the time step (will be empty since nothing is selected)
soil_results = case.selected_cell_property("DYNAMIC_NATIVE", "SOIL", tidx)
assert len(soil_results) == 0
Expand Down
2 changes: 1 addition & 1 deletion docs/rips/tests/test_nnc_properties.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def test_10kSync(rips_instance, initialize_test):

# Generate some data
new_data = []
for (c, _) in enumerate(nnc_connections):
for c, _ in enumerate(nnc_connections):
new_data.append(float(c))

property_name = "NEW_PROP"
Expand Down
6 changes: 3 additions & 3 deletions docs/rips/tests/test_properties.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,15 @@ def test_10k_set_out_of_bounds_client(rips_instance, initialize_test):


def createResult(poroChunks, permxChunks):
for (poroChunk, permxChunk) in zip(poroChunks, permxChunks):
for poroChunk, permxChunk in zip(poroChunks, permxChunks):
resultChunk = []
for (poro, permx) in zip(poroChunk.values, permxChunk.values):
for poro, permx in zip(poroChunk.values, permxChunk.values):
resultChunk.append(poro * permx)
yield resultChunk


def checkResults(poroValues, permxValues, poropermxValues):
for (poro, permx, poropermx) in zip(poroValues, permxValues, poropermxValues):
for poro, permx, poropermx in zip(poroValues, permxValues, poropermxValues):
recalc = poro * permx
assert recalc == pytest.approx(poropermx, rel=1.0e-10)

Expand Down
2 changes: 1 addition & 1 deletion docs/rips/tests/test_simulation_wells.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def test_10k(rips_instance, initialize_test):
expected_cell_count["GI1"] = 38
expected_cell_count["GP2"] = 18
for sim_well in sim_wells:
for (tidx, timestep) in enumerate(timesteps):
for tidx, timestep in enumerate(timesteps):
if tidx > 0:
cells = sim_well.cells(tidx)
print(
Expand Down
2 changes: 1 addition & 1 deletion docs/rips/tests/test_summary_cases.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def test_summary_data(rips_instance, initialize_test):
addresses = summary_case.available_addresses()
# Summary reader type is controlled from Preferences. libecl reports 343 vectors, opm_common (ESMRY) reports 339.
# As this configuration can be different, allow both variants
assert len(addresses.values) == 343 or len(addresses.values) == 339
assert len(addresses.values) == 335 or len(addresses.values) == 339

summary_data = summary_case.summary_vector_values("FOPT")
assert len(summary_data.values) == 60
Expand Down
2 changes: 1 addition & 1 deletion docs/rips/tests/test_well_log_extraction.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def test_10k_well_log_extraction(rips_instance, initialize_test):
well_log_plot = well_log_plot_collection.new_well_log_plot(case, well_path)

# Create a track for each property
for (prop_type, prop_name, time_step) in properties:
for prop_type, prop_name, time_step in properties:
track = well_log_plot.new_well_log_track("Track: " + prop_name, case, well_path)
c = track.add_extraction_curve(case, well_path, prop_type, prop_name, time_step)

Expand Down

0 comments on commit 9e0313e

Please sign in to comment.