From 13a4c7accf49805c8178f30b7b6cd8103a1fc07c Mon Sep 17 00:00:00 2001 From: mferrera Date: Mon, 8 Jul 2024 12:40:50 +0200 Subject: [PATCH] MAINT: Resolve xtgeo dataframe warnings --- src/xtgeoviz/plot/xsection.py | 24 ++++++++++++------------ src/xtgeoviz/plot/xtmap.py | 8 ++++---- tests/test_plot/test_map.py | 5 ++--- 3 files changed, 18 insertions(+), 19 deletions(-) diff --git a/src/xtgeoviz/plot/xsection.py b/src/xtgeoviz/plot/xsection.py index d47fcab..20ad81a 100644 --- a/src/xtgeoviz/plot/xsection.py +++ b/src/xtgeoviz/plot/xsection.py @@ -379,13 +379,13 @@ def plot_well( wo = self._well # reduce the well data by Pandas operations - dfr = wo.dataframe - wo.dataframe = dfr[dfr["Z_TVDSS"] > self._zmin] + dfr = wo.get_dataframe() + wo.set_dataframe(dfr[dfr["Z_TVDSS"] > self._zmin]) # Create a relative XYLENGTH vector (0.0 where well starts) wo.create_relative_hlen() - dfr = wo.dataframe + dfr = wo.get_dataframe() if dfr.empty: self._showok = False return @@ -423,7 +423,7 @@ def plot_well( def set_xaxis_md(self, gridlines=False): """Set x-axis labels to measured depth.""" - md_start = self._well.dataframe["MDEPTH"].iloc[0] + md_start = self._well.get_dataframe()["MDEPTH"].iloc[0] md_start_round = int(math.floor(md_start / 100.0)) * 100 md_start_delta = md_start - md_start_round @@ -1086,7 +1086,7 @@ def plot_md_data( data_well = data_well.loc[data_well["WELL"] == well.xwellname] del data_well["WELL"] - md_start = well.dataframe["MDEPTH"].iloc[0] + md_start = well.get_dataframe()["MDEPTH"].iloc[0] data_well["R_HLEN"] = data_well["MDEPTH"] data_well["R_HLEN"] = data_well["R_HLEN"].subtract(md_start) @@ -1117,8 +1117,8 @@ def plot_wellmap(self, otherwells=None, expand=1): ax = self._ax2 if self.fence is not None: - xwellarray = self._well.dataframe["X_UTME"].values - ywellarray = self._well.dataframe["Y_UTMN"].values + xwellarray = self._well.get_dataframe()["X_UTME"].values + ywellarray = self._well.get_dataframe()["Y_UTMN"].values ax.plot(xwellarray, ywellarray, linewidth=4, c="cyan") @@ -1144,8 +1144,8 @@ def plot_wellmap(self, otherwells=None, expand=1): continue if poly.name == self._well.xwellname: continue - xwp = poly.dataframe[poly.xname].values - ywp = poly.dataframe[poly.yname].values + xwp = poly.get_dataframe()[poly.xname].values + ywp = poly.get_dataframe()[poly.yname].values ax.plot(xwp, ywp, linewidth=1, c="grey") ax.annotate(poly.name, xy=(xwp[-1], ywp[-1]), color="grey", size=5) @@ -1159,9 +1159,9 @@ def plot_map(self): ax = self._ax3 if self.fence is not None: - xp = self._outline.dataframe["X_UTME"].values - yp = self._outline.dataframe["Y_UTMN"].values - ip = self._outline.dataframe["POLY_ID"].values + xp = self._outline.get_dataframe()["X_UTME"].values + yp = self._outline.get_dataframe()["Y_UTMN"].values + ip = self._outline.get_dataframe()["POLY_ID"].values ax.plot(self._fence[:, 0], self._fence[:, 1], linewidth=3, c="red") diff --git a/src/xtgeoviz/plot/xtmap.py b/src/xtgeoviz/plot/xtmap.py index 4bfc8a8..907c4c0 100644 --- a/src/xtgeoviz/plot/xtmap.py +++ b/src/xtgeoviz/plot/xtmap.py @@ -169,7 +169,7 @@ def plot_faults( .. _Matplotlib: http://matplotlib.org/api/colors_api.html """ - aff = fpoly.dataframe.groupby(idname) + aff = fpoly.get_dataframe().groupby(idname) for name, _group in aff: # make a dataframe sorted on faults (groupname) @@ -196,7 +196,7 @@ def plot_polygons(self, fpoly, idname="POLY_ID", color="k", linewidth=0.8): .. _Matplotlib: http://matplotlib.org/api/colors_api.html """ - aff = fpoly.dataframe.groupby(idname) + aff = fpoly.get_dataframe().groupby(idname) for _name, group in aff: # make a dataframe sorted on groupname @@ -220,7 +220,7 @@ def plot_points(self, points): """ # This function is "in prep" - dataframe = points.dataframe + dataframe = points.get_dataframe() self._ax.scatter( dataframe["X_UTME"].values, dataframe["Y_UTMN"].values, marker="x" @@ -235,7 +235,7 @@ def plot_wells(self, wells): """ for well in wells.wells: - dataframe = well.dataframe + dataframe = well.get_dataframe() xval = dataframe["X_UTME"].values yval = dataframe["Y_UTMN"].values diff --git a/tests/test_plot/test_map.py b/tests/test_plot/test_map.py index 93bdada..68f5ac2 100644 --- a/tests/test_plot/test_map.py +++ b/tests/test_plot/test_map.py @@ -35,9 +35,8 @@ def test_map_plot_with_points(tmpdir, generate_plot): mypoints = xtgeo.points_from_surface(mysurf) - df = mypoints.dataframe.copy() - df = df[::20] - mypoints.dataframe = df + df = mypoints.get_dataframe() + mypoints.set_dataframe(df[::29]) # just make the instance, with a lot of defaults behind the scene myplot = Map()