#14772 Python: Add WellLogPlot.export_data_as_las/ascii as object methods and forward exportWellLogPlotData to them

RimWellLogPlot_exportDataAsLas and RimWellLogPlot_exportDataAsAscii
return the exported file names. RicfExportWellLogPlotData picks the
method from the exportFormat and forwards to it. Add
RicfForwarding::findWellLogPlot().

The Python wrappers keep their signature and List[str] return value,
now calling the object methods. The misspelled export_tvdrkb argument
is kept as a deprecated alias of export_tvd_rkb.
This commit is contained in:
Kristian Bendiksen committed 2026-09-22 14:19:23 +02:00
1 parent e3e09c0d1f
commit 6a2e7a2a21
7 files changed
+362 -82

No files matched your search

@@ -1,5 +1,6 @@
import sys
import os
import pytest
import tempfile
sys.path.insert(1, os.path.join(sys.path[0], "../../"))
@@ -46,3 +47,29 @@ def test_10k_well_log_extraction(rips_instance, initialize_test):
with tempfile.TemporaryDirectory(prefix="rips") as tmpdirname:
well_log_plot.export_data_as_las(export_folder=tmpdirname)
def test_export_data_as_ascii(rips_instance, initialize_test):
project = rips_instance.project.open(
dataroot.PATH + "/TEST10K_FLT_LGR_NNC/10KWithWellLog.rsp"
)
well_log_plots = [
plot for plot in project.plots() if isinstance(plot, rips.WellLogPlot)
]
assert len(well_log_plots) > 0
with tempfile.TemporaryDirectory(prefix="rips") as tmpdirname:
files = well_log_plots[0].export_data_as_ascii(
export_folder=tmpdirname, file_prefix="pfx_"
)
assert len(files) == 1
assert os.path.exists(files[0])
assert os.path.basename(files[0]).startswith("pfx_")
las_files = well_log_plots[0].export_data_as_las(export_folder=tmpdirname)
assert len(las_files) >= 1
for las in las_files:
assert las.endswith(".las")
with pytest.raises(rips.RipsError):
well_log_plots[0].export_data_as_las(export_folder="/does/not/exist")
+37 -27
View File
@@ -2,7 +2,7 @@
ResInsight Well Log Plot plot module
"""
import Commands_pb2
import warnings
from .pdmobject import add_method
from .resinsight_classes import WellLogPlot
@@ -19,32 +19,44 @@ def export_data_as_las(
capitalize_file_names: bool = False,
resample_interval: float = 0.0,
convert_to_standard_units: bool = False,
export_tvd_rkb: bool = None,
) -> List[str]:
"""Export LAS file(s) for the current plot
Arguments:
export_folder(str): The path to export to. By default will use the global export folder
export_folder(str): The path to export to. Must exist.
file_prefix (str): Exported file name prefix
export_tvdrkb(bool): Export in TVD-RKB format
export_tvdrkb(bool): Deprecated spelling of export_tvd_rkb
capitalize_file_names(bool): Make all file names upper case
resample_interval(double): if > 0.0 the files will be resampled
convert_to_standard_units(bool): Convert curve units to standard units
export_tvd_rkb(bool): Export in TVD-RKB format
Returns:
A list of files exported
"""
res = self._execute_command(
exportWellLogPlotData=Commands_pb2.ExportWellLogPlotDataRequest(
exportFormat="LAS",
viewId=self.id,
exportFolder=export_folder,
filePrefix=file_prefix,
exportTvdRkb=export_tvdrkb,
capitalizeFileNames=capitalize_file_names,
resampleInterval=resample_interval,
convertCurveUnits=convert_to_standard_units,
if export_tvdrkb:
warnings.warn(
"WellLogPlot.export_data_as_las(export_tvdrkb=...) is deprecated, use export_tvd_rkb=...",
DeprecationWarning,
stacklevel=3,
)
if export_tvd_rkb is None:
export_tvd_rkb = export_tvdrkb
from .resinsight_classes import DataContainerString
res = self._call_pdm_method_return_value(
"exportDataAsLas",
DataContainerString,
export_folder=export_folder,
file_prefix=file_prefix,
export_tvd_rkb=export_tvd_rkb,
capitalize_file_names=capitalize_file_names,
resample_interval=resample_interval,
convert_to_standard_units=convert_to_standard_units,
)
return res.exportWellLogPlotDataResult.exportedFiles
return list(res.values)
@add_method(WellLogPlot)
@@ -54,25 +66,23 @@ def export_data_as_ascii(
file_prefix: str = "",
capitalize_file_names: bool = False,
) -> List[str]:
"""Export LAS file(s) for the current plot
"""Export ASCII file for the current plot
Arguments:
export_folder(str): The path to export to. By default will use the global export folder
export_folder(str): The path to export to. Must exist.
file_prefix (str): Exported file name prefix
capitalize_file_names(bool): Make all file names upper case
Returns:
A list of files exported
"""
res = self._execute_command(
exportWellLogPlotData=Commands_pb2.ExportWellLogPlotDataRequest(
exportFormat="ASCII",
viewId=self.id,
exportFolder=export_folder,
filePrefix=file_prefix,
exportTvdRkb=False,
capitalizeFileNames=capitalize_file_names,
resampleInterval=0.0,
)
from .resinsight_classes import DataContainerString
res = self._call_pdm_method_return_value(
"exportDataAsAscii",
DataContainerString,
export_folder=export_folder,
file_prefix=file_prefix,
capitalize_file_names=capitalize_file_names,
)
return res.exportWellLogPlotDataResult.exportedFiles
return list(res.values)