Skip to content

Commit

Permalink
MAINT: Resolve xtgeo dataframe warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
mferrera committed Jul 9, 2024
1 parent a056443 commit c256789
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 22 deletions.
28 changes: 13 additions & 15 deletions src/xtgeoviz/plot/xsection.py
Original file line number Diff line number Diff line change
Expand Up @@ -376,16 +376,14 @@ def plot_well(
if self.fence is None:
return

wo = self._well

# reduce the well data by Pandas operations
dfr = wo.dataframe
wo.dataframe = dfr[dfr["Z_TVDSS"] > self._zmin]
dfr = self._well.get_dataframe(copy=False)
dfr = dfr[dfr["Z_TVDSS"] > self._zmin]

# Create a relative XYLENGTH vector (0.0 where well starts)
wo.create_relative_hlen()
self._well.create_relative_hlen()

dfr = wo.dataframe
dfr = self._well.get_dataframe(copy=False)
if dfr.empty:
self._showok = False
return
Expand Down Expand Up @@ -423,7 +421,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(copy=False)["MDEPTH"].iloc[0]
md_start_round = int(math.floor(md_start / 100.0)) * 100
md_start_delta = md_start - md_start_round

Expand Down Expand Up @@ -1086,7 +1084,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(copy=False)["MDEPTH"].iloc[0]
data_well["R_HLEN"] = data_well["MDEPTH"]
data_well["R_HLEN"] = data_well["R_HLEN"].subtract(md_start)

Expand Down Expand Up @@ -1117,8 +1115,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(copy=False)["X_UTME"].values
ywellarray = self._well.get_dataframe(copy=False)["Y_UTMN"].values

ax.plot(xwellarray, ywellarray, linewidth=4, c="cyan")

Expand All @@ -1144,8 +1142,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(copy=False)[poly.xname].values
ywp = poly.get_dataframe(copy=False)[poly.yname].values
ax.plot(xwp, ywp, linewidth=1, c="grey")
ax.annotate(poly.name, xy=(xwp[-1], ywp[-1]), color="grey", size=5)

Expand All @@ -1159,9 +1157,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(copy=False)["X_UTME"].values
yp = self._outline.get_dataframe(copy=False)["Y_UTMN"].values
ip = self._outline.get_dataframe(copy=False)["POLY_ID"].values

ax.plot(self._fence[:, 0], self._fence[:, 1], linewidth=3, c="red")

Expand Down
8 changes: 4 additions & 4 deletions src/xtgeoviz/plot/xtmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ def plot_faults(
.. _Matplotlib: http://matplotlib.org/api/colors_api.html
"""
aff = fpoly.dataframe.groupby(idname)
aff = fpoly.get_dataframe(copy=False).groupby(idname)

for name, _group in aff:
# make a dataframe sorted on faults (groupname)
Expand All @@ -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(copy=False).groupby(idname)

for _name, group in aff:
# make a dataframe sorted on groupname
Expand All @@ -220,7 +220,7 @@ def plot_points(self, points):
"""
# This function is "in prep"

dataframe = points.dataframe
dataframe = points.get_dataframe(copy=False)

self._ax.scatter(
dataframe["X_UTME"].values, dataframe["Y_UTMN"].values, marker="x"
Expand All @@ -235,7 +235,7 @@ def plot_wells(self, wells):
"""
for well in wells.wells:
dataframe = well.dataframe
dataframe = well.get_dataframe(copy=False)

xval = dataframe["X_UTME"].values
yval = dataframe["Y_UTMN"].values
Expand Down
5 changes: 2 additions & 3 deletions tests/test_plot/test_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -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[::20])

# just make the instance, with a lot of defaults behind the scene
myplot = Map()
Expand Down

0 comments on commit c256789

Please sign in to comment.