From 0e2ee182807d9603c6e3d2fc79ca5ba53e21e192 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20C=2E=20Riven=C3=A6s?= Date: Thu, 24 Aug 2023 08:12:35 +0200 Subject: [PATCH] BUG: add realisation in blockedwell_from_roxar() --- src/xtgeo/well/_blockedwell_roxapi.py | 14 +++++++------- src/xtgeo/well/blocked_well.py | 24 +++++++++++++++++++++--- 2 files changed, 28 insertions(+), 10 deletions(-) diff --git a/src/xtgeo/well/_blockedwell_roxapi.py b/src/xtgeo/well/_blockedwell_roxapi.py index de43ea48f..d86c56dc2 100644 --- a/src/xtgeo/well/_blockedwell_roxapi.py +++ b/src/xtgeo/well/_blockedwell_roxapi.py @@ -70,7 +70,7 @@ def _roxapi_import_bwell( else: raise ValueError(f"No such blocked well set: {bwname}") - if wname in bwset.get_well_names(): + if wname in bwset.get_well_names(realisation=realisation): self._wname = wname else: raise WellNotFoundError(f"No such well in blocked well set: {wname}") @@ -79,8 +79,8 @@ def _roxapi_import_bwell( bwprops = [item for item in bwset.properties] bwnames = [item.name for item in bwset.properties] - bw_cellindices = bwset.get_cell_numbers() - dind = bwset.get_data_indices([wname]) + bw_cellindices = bwset.get_cell_numbers(realisation=realisation) + dind = bwset.get_data_indices([wname], realisation=realisation) cind = bw_cellindices[dind] xyz = np.transpose(gmodel.get_grid(realisation=realisation).get_cell_centers(cind)) @@ -154,7 +154,7 @@ def _roxapi_export_bwell( else: raise ValueError(f"No such blocked well set: {bwname}") - if wname in bwset.get_well_names(): + if wname in bwset.get_well_names(realisation=realisation): self._wname = wname else: raise WellNotFoundError(f"No such well in blocked well set: {wname}") @@ -162,7 +162,7 @@ def _roxapi_export_bwell( bwnames = [item.name for item in bwset.properties] # get the current indices for the well - dind = bwset.get_data_indices([self._wname]) + dind = bwset.get_data_indices([self._wname], realisation=realisation) for lname in self.lognames: if not ijk and "_INDEX" in lname: @@ -190,7 +190,7 @@ def _roxapi_export_bwell( bwprop = bwlog.get_values(realisation=realisation) usedtype = bwprop.dtype - dind = bwset.get_data_indices([self._wname]) + dind = bwset.get_data_indices([self._wname], realisation=realisation) if self.dataframe[lname].values.size != dind.size: raise ValueError( @@ -202,4 +202,4 @@ def _roxapi_export_bwell( ) bwprop[dind] = maskedvalues - bwlog.set_values(bwprop) + bwlog.set_values(bwprop, realisation=realisation) diff --git a/src/xtgeo/well/blocked_well.py b/src/xtgeo/well/blocked_well.py index 38cf4ca8f..e3c0cffda 100644 --- a/src/xtgeo/well/blocked_well.py +++ b/src/xtgeo/well/blocked_well.py @@ -3,6 +3,8 @@ import deprecation +import pandas as pd + import xtgeo from . import _blockedwell_roxapi @@ -45,7 +47,9 @@ def blockedwell_from_file( # return obj -def blockedwell_from_roxar(project, gname, bwname, wname, lognames=None, ijk=True): +def blockedwell_from_roxar( + project, gname, bwname, wname, lognames=None, ijk=True, realisation=0 +): """This makes an instance of a BlockedWell directly from Roxar RMS. For arguments, see :meth:`BlockedWell.from_roxar`. @@ -60,9 +64,23 @@ def blockedwell_from_roxar(project, gname, bwname, wname, lognames=None, ijk=Tru """ - obj = BlockedWell() + # TODO: replace this with proper class method + obj = BlockedWell( + *([0.0] * 3), "", pd.DataFrame({"X_UTME": [], "Y_UTMN": [], "Z_TVDSS": []}) + ) + + _blockedwell_roxapi.import_bwell_roxapi( + obj, + project, + gname, + bwname, + wname, + lognames=lognames, + ijk=ijk, + realisation=realisation, + ) - obj.from_roxar(project, gname, bwname, wname, ijk=ijk, lognames=lognames) + obj._ensure_consistency() return obj