mirror of
https://github.com/OPM/ResInsight.git
synced 2026-11-01 08:38:00 -06:00
The previous commit auto-generated StrEnum classes for caf::AppEnum scriptable fields, but the hand-written gRPC API in rips.case still accepted bare strings for proto-backed enums (PropertyType, PropertyDataType, NNCPropertyType) and the AppEnum-backed PorosityModelType. Add a new rips.enums module with hand-written StrEnum classes for the three proto-only enums and reuse the auto-generated PorosityModelType from resinsight_classes. Re-export the new enums from the rips package and narrow the parameter type hints across cell_count, cell_info_for_active_cells, available_properties, active_cell_property, selected_cell_property, grid_property, set_active_cell_property, set_grid_property, active_cell_centers, active_cell_corners, set_nnc_connections_values, and grid_property_for_positions (sync and async variants). Existing string arguments keep working because StrEnum members are strings and protobuf's EnumTypeWrapper.Value accepts both. A new test_10k_grid_property_strenum asserts string and enum forms return the same data.
49 lines
1.5 KiB
Python
49 lines
1.5 KiB
Python
import sys
|
|
import os
|
|
import tempfile
|
|
|
|
sys.path.insert(1, os.path.join(sys.path[0], "../../"))
|
|
import rips
|
|
|
|
import dataroot
|
|
|
|
|
|
def test_10k_well_log_extraction(rips_instance, initialize_test):
|
|
case_root_path = dataroot.PATH + "/TEST10K_FLT_LGR_NNC"
|
|
case_path = case_root_path + "/TEST10K_FLT_LGR_NNC.EGRID"
|
|
case = rips_instance.project.load_case(path=case_path)
|
|
assert len(case.grids()) == 2
|
|
well_path_files = [
|
|
case_root_path + "/wellpath_a.dev",
|
|
]
|
|
|
|
view = case.create_view()
|
|
view.set_time_step(1)
|
|
|
|
well_path_names = rips_instance.project.import_well_paths(well_path_files)
|
|
assert len(well_path_names) == 1
|
|
wells = rips_instance.project.well_paths()
|
|
well_path = wells[0]
|
|
|
|
properties = [
|
|
(rips.ResultType.STATIC_NATIVE, "INDEX_K", 0),
|
|
(rips.ResultType.STATIC_NATIVE, "PORO", 0),
|
|
(rips.ResultType.STATIC_NATIVE, "PERMX", 0),
|
|
(rips.ResultType.DYNAMIC_NATIVE, "PRESSURE", 0),
|
|
]
|
|
|
|
well_log_plot_collection = rips_instance.project.descendants(
|
|
rips.WellLogPlotCollection
|
|
)[0]
|
|
|
|
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:
|
|
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)
|
|
assert c
|
|
|
|
with tempfile.TemporaryDirectory(prefix="rips") as tmpdirname:
|
|
well_log_plot.export_data_as_las(export_folder=tmpdirname)
|