Skip to content

Commit

Permalink
feat(vectors): vector plots when stresses applied along boundaries (#817
Browse files Browse the repository at this point in the history
)

* feat(postprocessing): add get_extended_budget() and get_specific_discharge()

* Add new function get_extended_budget() to get the correct flow rate across cell faces when stresses are applied along boundaries.
* Add new function get_specific_discharge() to get the correct specific discharge vector including at boundary cells.
* Deprecate centered_specific_discharge() function in module plotutil since the new get_specific_discharge() function just gives more flexibility (the function is kept to ensure backward compatibility).
* Add autotests for the new functions (t070).

* fix(PlotMapView): fix minor bugs in PlotMapView

* Fix squeeze of wrong axis in particular situations
* Make plot_discharge() return the quiver generated by plot_specific_discharge()

* feat(PlotMapView, plotutil): deal with nan values

* Make it such that nan values are not plotted

* fix(testunitcbc.py): fix bug in examples/Testing/testunitcbc.py

The ipackcb option was not provided to the LPF package, so the cell-by-cell flow terms could not be loaded. Fix it.

* feat(PlotMapView, PlotCrossSection): add plot_vector() functions

* Add new plot_vector() function in both PlotMapView and PlotCrossSection classes to plot any vector (typically specific discharge). This function is meant to replace both plot_specific_discharge() and plot_discharge(). It makes the code both more concise and more generic (can plot any vector).
* Deprecate plot_specific_discharge() and plot_discharge() functions (but keep them to ensure backward compatibility).
* Add tests for the new functions.
* Fix several tests for non-closed figures (close them).

* docs(multiple files): fix code documentation

Fix a few errors, inaccuracies and typos in code documentation.

* refactor(discretization): homogenize assignment of _grid_type

The _grid_type attribute was not assigned in the same way for all grid types. Make it more homogeneous. Also remove redundant grid_type() function in UnstructuredGrid.

* fix(ModflowOc): fix small error in unitnumber vector

The unitnumber vector in __init__() was wrong (too many zeros padded at the end). This error was without consequence, but still better fixed.
  • Loading branch information
langevin-usgs authored Mar 5, 2020
1 parent 90a498e commit 1284871
Show file tree
Hide file tree
Showing 19 changed files with 1,297 additions and 39 deletions.
2 changes: 2 additions & 0 deletions autotest/t006_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ def test_binaryfile_reference():

if matplotlib is not None:
assert isinstance(h.plot(), matplotlib.axes.Axes)
matplotlib.pyplot.close()
return


Expand All @@ -36,6 +37,7 @@ def test_formattedfile_reference():

if matplotlib is not None:
assert isinstance(h.plot(masked_values=[6999.000]), matplotlib.axes.Axes)
matplotlib.pyplot.close()
return


Expand Down
8 changes: 8 additions & 0 deletions autotest/t007_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1304,6 +1304,7 @@ def test_tricontour_NaN():
from flopy.plot import PlotMapView
import numpy as np
from flopy.discretization import StructuredGrid
import matplotlib.pyplot as plt

arr = np.random.rand(10, 10) * 100
arr[-1, :] = np.nan
Expand Down Expand Up @@ -1335,6 +1336,8 @@ def test_tricontour_NaN():
if not np.allclose(lev, levels[ix]):
raise AssertionError("TriContour NaN catch Failed")

plt.close()


def test_get_vertices():
from flopy.utils.reference import SpatialReference
Expand Down Expand Up @@ -1365,6 +1368,7 @@ def test_get_vertices():


def test_vertex_model_dot_plot():
import matplotlib.pyplot as plt
# load up the vertex example problem
sim_name = "mfsim.nam"
sim_path = "../examples/data/mf6/test003_gwftri_disv"
Expand All @@ -1374,13 +1378,16 @@ def test_vertex_model_dot_plot():
disv_ml = disv_sim.get_model('gwf_1')
ax = disv_ml.plot()
assert ax
plt.close('all')


def test_model_dot_plot():
import matplotlib.pyplot as plt
loadpth = os.path.join('..', 'examples', 'data', 'secp')
ml = flopy.modflow.Modflow.load('secp.nam', model_ws=loadpth)
ax = ml.plot()
assert ax
plt.close('all')


def test_get_rc_from_node_coordinates():
Expand Down Expand Up @@ -1597,6 +1604,7 @@ def test_export_contourf():
cs = plt.contourf(a)
export_contourf(filename, cs)
assert os.path.isfile(filename), 'did not create contourf shapefile'
plt.close()
return

def main():
Expand Down
2 changes: 2 additions & 0 deletions autotest/t009_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ def test_sfr():
if matplotlib is not None:
assert isinstance(sfr.plot()[0],
matplotlib.axes.Axes) # test the plot() method
matplotlib.pyplot.close()

# trout lake example (only sfr file is included)
# can add tests for sfr connection with lak package
Expand Down Expand Up @@ -559,6 +560,7 @@ def test_sfr_plot():
#sfr.plot(key='strtop')
#plt.show()
#assert True
#plt.close()
pass


Expand Down
1 change: 1 addition & 0 deletions autotest/t015_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ def test_str_plot():
verbose=True)
if matplotlib is not None:
assert isinstance(m.str.plot()[0], matplotlib.axes.Axes)
matplotlib.pyplot.close()


if __name__ == '__main__':
Expand Down
Loading

0 comments on commit 1284871

Please sign in to comment.