mirror of
https://github.com/OPM/ResInsight.git
synced 2026-11-01 08:38:00 -06:00
#14772 Python: Add Reservoir.export_property as object method and forward exportProperty to it
RimEclipseCase_exportProperty writes a cell property to a GRDECL style text file and requires an explicit export file. RicfExportProperty resolves the default file name from the command file executor's PROPERTIES export folder and forwards to it. The hand-written Case.export_property() wrapper is removed. The generated Reservoir.export_property() has the same argument names and shadows the base class wrapper anyway, so a deprecation shim would never be reached.
This commit is contained in:
1 parent
77c32a3fa5
commit
d2078613a8
5 files changed
+185
-95
No files matched your search
@@ -970,36 +970,6 @@ def set_grid_property(
|
||||
raise IndexError
|
||||
|
||||
|
||||
@add_method(Case)
|
||||
def export_property(
|
||||
self,
|
||||
time_step: int,
|
||||
property_name: str,
|
||||
eclipse_keyword: Any = property,
|
||||
undefined_value: float = 0.0,
|
||||
export_file: Any = property,
|
||||
) -> Any:
|
||||
"""Export an Eclipse property
|
||||
|
||||
Arguments:
|
||||
time_step (int): time step index
|
||||
property_name (str): property to export
|
||||
eclipse_keyword (str): Keyword used in export header. Defaults: value of property
|
||||
undefined_value (double): Value to use for undefined values. Defaults to 0.0
|
||||
export_file (str): File name for export. Defaults to the value of property parameter
|
||||
"""
|
||||
return self._execute_command(
|
||||
exportProperty=Cmd.ExportPropertyRequest(
|
||||
caseId=self.id,
|
||||
timeStep=time_step,
|
||||
property=property_name,
|
||||
eclipseKeyword=eclipse_keyword,
|
||||
undefinedValue=undefined_value,
|
||||
exportFile=export_file,
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
@add_method(Case)
|
||||
def create_well_bore_stability_plot(
|
||||
self,
|
||||
|
||||
@@ -256,3 +256,34 @@ def test_exportPropertyInView(rips_instance, initialize_test):
|
||||
expected_file_name = case.name + "-" + str("3D_View") + "-" + "T0" + "-SOIL"
|
||||
full_path = tmpdirname + "/" + expected_file_name
|
||||
assert os.path.exists(full_path)
|
||||
|
||||
|
||||
def test_export_property(rips_instance, initialize_test):
|
||||
case_path = dataroot.PATH + "/TEST10K_FLT_LGR_NNC/TEST10K_FLT_LGR_NNC.EGRID"
|
||||
case = rips_instance.project.load_case(case_path)
|
||||
with tempfile.TemporaryDirectory(prefix="rips") as tmpdirname:
|
||||
export_file = os.path.join(tmpdirname, "soil_t1.grdecl")
|
||||
case.export_property(time_step=1, property_name="SOIL", export_file=export_file)
|
||||
assert os.path.exists(export_file)
|
||||
with open(export_file) as f:
|
||||
assert "SOIL" in f.read(200)
|
||||
|
||||
# Keyword override and static property
|
||||
export_file = os.path.join(tmpdirname, "poro.grdecl")
|
||||
case.export_property(
|
||||
time_step=0,
|
||||
property_name="PORO",
|
||||
eclipse_keyword="MYPORO",
|
||||
export_file=export_file,
|
||||
)
|
||||
with open(export_file) as f:
|
||||
assert "MYPORO" in f.read(200)
|
||||
|
||||
with pytest.raises(rips.RipsError):
|
||||
case.export_property(
|
||||
time_step=0,
|
||||
property_name="NOT_A_PROPERTY",
|
||||
export_file=os.path.join(tmpdirname, "x"),
|
||||
)
|
||||
with pytest.raises(rips.RipsError):
|
||||
case.export_property(time_step=0, property_name="PORO")
|
||||
Reference in new issue
Block a user