Skip to content

Commit

Permalink
Fix(plot_array): update plot_array method to mask using np.ma.masked_…
Browse files Browse the repository at this point in the history
…values (#851)

* Fix(plot_array): update plot_array method to mask using np.ma.masked_values

* Update(plotting): change np.equal to np.isclose for large floating points
  • Loading branch information
jlarsen-usgs committed Apr 15, 2020
1 parent 52ecd98 commit f6545ff
Show file tree
Hide file tree
Showing 7 changed files with 66 additions and 71 deletions.
101 changes: 50 additions & 51 deletions examples/Notebooks/flopy3.3_PlotCrossSection.ipynb

Large diffs are not rendered by default.

Binary file modified examples/data/mf6/test003_gwfs_disv/test003_gwfs_disv.dbf
Binary file not shown.
Binary file modified examples/data/mf6/test003_gwfs_disv/test003_gwfs_disv.shp
Binary file not shown.
Binary file modified examples/data/mf6/test003_gwfs_disv/test003_gwfs_disv.shx
Binary file not shown.
16 changes: 6 additions & 10 deletions flopy/plot/crosssection.py
Expand Up @@ -357,19 +357,15 @@ def plot_array(self, a, masked_values=None, head=None, **kwargs):
vpts = np.array(vpts)
if masked_values is not None:
for mval in masked_values:
vpts = np.ma.masked_equal(vpts, mval)
vpts = np.ma.masked_values(vpts, mval)

if isinstance(head, np.ndarray):
zpts = self.set_zpts(head)
else:
zpts = self.zpts

if masked_values is not None:
for mval in masked_values:
vpts = np.ma.masked_equal(vpts, mval)

if self.ncb > 0:
vpts = np.ma.masked_equal(vpts, -1e9)
vpts = np.ma.masked_values(vpts, -1e9)

pc = self.get_grid_patch_collection(zpts, vpts, **kwargs)
if pc != None:
Expand Down Expand Up @@ -420,7 +416,7 @@ def plot_surface(self, a, masked_values=None, **kwargs):

if masked_values is not None:
for mval in masked_values:
vpts = np.ma.masked_equal(vpts, mval)
vpts = np.ma.masked_values(vpts, mval)

plot = []
# adust distance array for modelgrid offset
Expand Down Expand Up @@ -488,9 +484,9 @@ def plot_fill_between(self, a, colors=('blue', 'red'),

if masked_values is not None:
for mval in masked_values:
vpts = np.ma.masked_equal(vpts, mval)
vpts = np.ma.masked_values(vpts, mval)
if self.ncb > 0:
vpts = np.ma.masked_equal(vpts, -1e9)
vpts = np.ma.masked_values(vpts, -1e9)
idxm = np.ma.getmask(vpts)

plot = []
Expand Down Expand Up @@ -567,7 +563,7 @@ def contour_array(self, a, masked_values=None, head=None, **kwargs):

if masked_values is not None:
for mval in masked_values:
vpts = np.ma.masked_equal(vpts, mval)
vpts = np.ma.masked_values(vpts, mval)

if isinstance(head, np.ndarray):
zcentergrid = self.set_zcentergrid(head)
Expand Down
10 changes: 5 additions & 5 deletions flopy/plot/map.py
Expand Up @@ -149,7 +149,7 @@ def plot_array(self, a, masked_values=None, **kwargs):

if masked_values is not None:
for mval in masked_values:
plotarray = np.ma.masked_equal(plotarray, mval)
plotarray = np.ma.masked_values(plotarray, mval)

# add NaN values to mask
plotarray = np.ma.masked_where(np.isnan(plotarray), plotarray)
Expand Down Expand Up @@ -292,9 +292,9 @@ def contour_array(self, a, masked_values=None, **kwargs):
if masked_values is not None:
for mval in masked_values:
if ismasked is None:
ismasked = np.equal(plotarray, mval)
ismasked = np.isclose(plotarray, mval)
else:
t = np.equal(plotarray, mval)
t = np.isclose(plotarray, mval)
ismasked += t

if 'ax' in kwargs:
Expand Down Expand Up @@ -678,9 +678,9 @@ def contour_array_cvfd(self, vertc, a, masked_values=None, **kwargs):
if masked_values is not None:
for mval in masked_values:
if ismasked is None:
ismasked = np.equal(plotarray, mval)
ismasked = np.isclose(plotarray, mval)
else:
t = np.equal(plotarray, mval)
t = np.isclose(plotarray, mval)
ismasked += t

# add NaN values to mask
Expand Down
10 changes: 5 additions & 5 deletions flopy/plot/vcrosssection.py
Expand Up @@ -236,7 +236,7 @@ def plot_array(self, a, masked_values=None, head=None, **kwargs):

if masked_values is not None:
for mval in masked_values:
a = np.ma.masked_equal(a, mval)
a = np.ma.masked_values(a, mval)

if isinstance(head, np.ndarray):
projpts = self.set_zpts(np.ravel(head))
Expand Down Expand Up @@ -291,7 +291,7 @@ def plot_surface(self, a, masked_values=None, **kwargs):

if masked_values is not None:
for mval in masked_values:
a = np.ma.masked_equal(a, mval)
a = np.ma.masked_values(a, mval)

data = []
lay_data = []
Expand Down Expand Up @@ -374,7 +374,7 @@ def plot_fill_between(self, a, colors=('blue', 'red'),

if masked_values is not None:
for mval in masked_values:
a = np.ma.masked_equal(a, mval)
a = np.ma.masked_values(a, mval)

if isinstance(head, np.ndarray):
projpts = self.set_zpts(head)
Expand Down Expand Up @@ -478,9 +478,9 @@ def contour_array(self, a, masked_values=None, head=None, **kwargs):
if masked_values is not None:
for mval in masked_values:
if ismasked is None:
ismasked = np.equal(plotarray, mval)
ismasked = np.isclose(plotarray, mval)
else:
t = np.equal(plotarray, mval)
t = np.isclose(plotarray, mval)
ismasked += t

if isinstance(head, np.ndarray):
Expand Down

0 comments on commit f6545ff

Please sign in to comment.