Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
7048d69
only read/write nstrail if isfropt>1
aleaf May 9, 2017
aa6d683
merging with upstream
aleaf Aug 21, 2017
893095f
Merge branch 'develop' of https://github.com/modflowpy/flopy into dev…
aleaf Nov 17, 2017
d1ee2bf
Merge branch 'develop' of https://github.com/modflowpy/flopy into dev…
aleaf Nov 22, 2017
b315aac
Merge branch 'develop' of https://github.com/modflowpy/flopy into dev…
aleaf Nov 22, 2017
249d3d6
Merge branch 'develop' of https://github.com/modflowpy/flopy into dev…
aleaf Nov 28, 2017
6e0c960
Merge branch 'develop' of https://github.com/modflowpy/flopy into dev…
aleaf Nov 30, 2017
606bb5f
move matplotlib inside plot profile fn
aleaf Nov 30, 2017
69dcf23
add detail
aleaf Dec 4, 2017
5e884c4
merged
aleaf Dec 4, 2017
61823af
export inlets method with tests
aleaf Dec 4, 2017
f85165b
export inlets method with tests
aleaf Dec 4, 2017
43a2771
method to export segment data variable across stress periods; fix int…
aleaf Dec 12, 2017
379be47
oops
aleaf Dec 13, 2017
5f1e6f5
Merge branch 'develop' of https://github.com/modflowpy/flopy into dev…
aleaf Jan 2, 2018
c9406b1
convert uzf arrays to transient 2D
aleaf Jan 2, 2018
42f5f48
Merge branch 'develop' of https://github.com/aleaf/flopy into develop
aleaf Jan 2, 2018
ebc624a
cruft removal
aleaf Jan 2, 2018
8599b73
stop using segment number to index spd arrays on load
aleaf Jan 2, 2018
b3af2c2
updated uzf example notebook
aleaf Jan 2, 2018
987f432
switch write path to temp
aleaf Jan 5, 2018
06b1585
uzgag support
aleaf Jan 15, 2018
17964c3
/bin/bash: q: command not found
aleaf Jan 15, 2018
8df5c09
uzgag support
aleaf Jan 16, 2018
a4bbf5f
improve handling of sparse stress period recarrays inexporting variables
aleaf Jan 19, 2018
f9815df
remove nuzgag arg
aleaf Jan 31, 2018
fba1813
Merge branch 'develop' of https://github.com/modflowpy/flopy into dev…
aleaf Jan 31, 2018
681fa9e
shorten int fields in shapefile export to 18 char; may be interpreted…
aleaf Feb 5, 2018
2470e26
shorten int fields in shapefile export to 18 char; may be interpreted…
aleaf Feb 5, 2018
3099aa6
change write_gridSpec so that the origin is in same units as grid spa…
aleaf Feb 7, 2018
561b5e7
Merge branch 'develop' of https://github.com/modflowpy/flopy into dev…
aleaf Feb 7, 2018
6d89309
fix numpy issues in checker
aleaf Feb 7, 2018
ba09a22
fix recarray issue in modpathfile
aleaf Feb 8, 2018
8041266
fix bug in writing uzgag info
aleaf Feb 8, 2018
7b6b1f2
merged uzf notebook back into develop branch
aleaf Feb 8, 2018
e6e4460
merging with upstream
aleaf Feb 15, 2018
cb709bd
extwc was being cast as int
aleaf Feb 15, 2018
f7e7c0f
Merge branch 'develop' of https://github.com/modflowpy/flopy into dev…
aleaf Feb 15, 2018
d4aba87
handle dtypes as lists
aleaf Feb 15, 2018
2b3849a
updated
aleaf Feb 15, 2018
824056c
trying to resolve merge conflict in t009
aleaf Feb 15, 2018
673f307
revert to create_empty_recarray requiring np.dtype
aleaf Feb 15, 2018
c17da4d
typo
aleaf Feb 15, 2018
d6f968c
switch back to correct cbb filename
aleaf Feb 15, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 47 additions & 1 deletion autotest/t007_test.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# Test export module
import sys
sys.path.append('..')
import copy
import glob
import os
Expand Down Expand Up @@ -138,6 +140,49 @@ def test_export_output():
arr_mask = arr.mask[0]
assert np.array_equal(ibound_mask, arr_mask)

def test_write_shapefile():
from flopy.utils.reference import SpatialReference
from flopy.export.shapefile_utils import shp2recarray
from flopy.export.shapefile_utils import write_grid_shapefile, write_grid_shapefile2

sr = SpatialReference(delr=np.ones(10) *1.1, # cell spacing along model rows
delc=np.ones(10) *1.1, # cell spacing along model columns
epsg=26715,
lenuni=1 # MODFLOW length units
)
outshp1 = os.path.join(tpth, 'junk.shp')
outshp2 = os.path.join(tpth, 'junk2.shp')
write_grid_shapefile(outshp1, sr, array_dict={})
write_grid_shapefile2(outshp2, sr, array_dict={})

for outshp in [outshp1, outshp2]:
# check that pyshp reads integers
# this only check that row/column were recorded as "N"
# not how they will be cast by python or numpy
import shapefile as sf
sfobj = sf.Reader(outshp)
for f in sfobj.fields:
if f[0] == 'row' or f[0] == 'column':
assert f[1] == 'N'
recs = list(sfobj.records())
for r in recs[0]:
assert isinstance(r, int)

# check that row and column appear as integers in recarray
ra = shp2recarray(outshp)
assert np.issubdtype(ra.dtype['row'], np.integer)
assert np.issubdtype(ra.dtype['column'], np.integer)

try: # check that fiona reads integers
import fiona
with fiona.open(outshp) as src:
meta = src.meta
assert 'int' in meta['schema']['properties']['row']
assert 'int' in meta['schema']['properties']['column']
except:
pass


def test_export_array():

try:
Expand Down Expand Up @@ -847,7 +892,8 @@ def build_sfr_netcdf():
# for namfile in ["fhb.nam"]:
# export_netcdf(namfile)
#test_freyberg_export()
test_export_array()
#test_export_array()
test_write_shapefile()
#test_wkt_parse()
#test_get_rc_from_node_coordinates()
pass
75 changes: 64 additions & 11 deletions autotest/t009_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,34 @@
}

def create_sfr_data():

dtype = np.dtype([('iseg', int), ('ireach', int)])
dtype = np.dtype([('k', int),
('i', int),
('j', int),
('iseg', int),
('ireach', int)])
r = create_empty_recarray(27, dtype=dtype)
r['i'] = [3, 4, 5,
7, 8, 9,
0, 1, 2,
4, 4, 5,
0, 0, 0,
3, 4, 5,
0, 1, 2,
4, 5, 6,
2, 2, 2]
r['j'] = [0, 1, 2,
6, 6, 6,
6, 6, 6,
3, 4, 5,
9, 8, 7,
6, 6, 6,
0, 0, 0,
6, 6, 6,
9, 8, 7]
r['iseg'] = sorted(list(range(1, 10)) * 3)
r['ireach'] = [1, 2, 3] * 9

dtype = np.dtype([('nseg', int), ('outseg', int)])
d = create_empty_recarray(9, dtype=dtype)
d = create_empty_recarray(9, dtype=np.dtype([('nseg', int), ('outseg', int)]))
d['nseg'] = range(1, 10)
d['outseg'] = [4, 0, 6, 8, 3, 8, 1, 2, 8]
return r, d
Expand Down Expand Up @@ -251,6 +271,38 @@ def test_const():
assert sfr.const == 1.486 * 86400.
assert True

def test_export():
fm = flopy.modflow
m = fm.Modflow()
dis = fm.ModflowDis(m, 1, 10, 10, lenuni=2, itmuni=4)
m.sr = SpatialReference(delr=m.dis.delr.array, delc=m.dis.delc.array)
m.sr.write_shapefile(os.path.join(outpath, 'grid.shp'))
r, d = create_sfr_data()
sfr = flopy.modflow.ModflowSfr2(m, reach_data=r, segment_data={0: d})
sfr.segment_data[0]['flow'][-1] = 1e4
sfr.stress_period_data.export(os.path.join(outpath, 'sfr.shp'), sparse=True)
sfr.export_linkages(os.path.join(outpath, 'linkages.shp'))
sfr.export_outlets(os.path.join(outpath, 'outlets.shp'))
sfr.export_transient_variable(os.path.join(outpath, 'inlets.shp'),
'flow')

from flopy.export.shapefile_utils import shp2recarray
ra = shp2recarray(os.path.join(outpath, 'inlets.shp'))
assert ra.flow0[0] == 1e4
ra = shp2recarray(os.path.join(outpath, 'outlets.shp'))
assert ra.iseg[0] + ra.ireach[0] == 5
ra = shp2recarray(os.path.join(outpath, 'linkages.shp'))
crds = np.array(list(ra.geometry[2].coords))
assert np.array_equal(crds, np.array([[2.5, 4.5], [3.5, 5.5]]))
ra = shp2recarray(os.path.join(outpath, 'sfr.shp'))
assert ra.iseg0.sum() == sfr.reach_data.iseg.sum()
assert ra.ireach0.sum() == sfr.reach_data.ireach.sum()
y = np.concatenate([np.array(g.exterior)[:, 1] for g in ra.geometry])
x = np.concatenate([np.array(g.exterior)[:, 0] for g in ra.geometry])
assert (x.min(), y.min(), x.max(), y.max()) == m.sr.bounds
assert ra[(ra.iseg0 == 2) & (ra.ireach0 == 1)]['geometry'][0].bounds \
== (6.0, 2.0, 7.0, 3.0)

def test_example():
m = flopy.modflow.Modflow.load('test1ss.nam', version='mf2005',
exe_name='mf2005.exe',
Expand Down Expand Up @@ -397,12 +449,13 @@ def test_sfr_plot():
pass

if __name__ == '__main__':
#test_sfr()
test_sfr()
test_sfr_renumbering()
#test_example()
#test_transient_example()
#test_sfr_plot()
#test_assign_layers()
#test_SfrFile()
#test_const()
test_example()
test_export()
test_transient_example()
test_sfr_plot()
test_assign_layers()
test_SfrFile()
test_const()
pass
7 changes: 4 additions & 3 deletions autotest/t024_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,8 @@ def test_properties_check():


if __name__ == '__main__':
# for mfnam in testmodels:
# checker_on_load(mfnam)
print('numpy version: {}'.format(np.__version__))
for mfnam in testmodels:
checker_on_load(mfnam)
test_bcs_check()
#test_properties_check()
test_properties_check()
5 changes: 5 additions & 0 deletions autotest/t031_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@
for f in mffiles:
shutil.copy(f, os.path.join(path, os.path.split(f)[1]))

def ra_slice(ra, cols):
raslice = np.column_stack([ra[c] for c in cols])
dtype = [(str(d[0]), d[1]) for d in ra.dtype.descr if d[0] in cols]
return np.array([tuple(r) for r in raslice],
dtype=dtype).view(np.recarray)

def test_mpsim():
model_ws = path
Expand Down
58 changes: 52 additions & 6 deletions autotest/t034_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,33 @@ def test_create():

finf = np.loadtxt(os.path.join(datpth, 'finf.dat'))
finf = np.reshape(finf, (m.nper, m.nrow, m.ncol))
finf = {i: finf[i] for i in range(finf.shape[0])}

extwc = np.loadtxt(os.path.join(datpth, 'extwc.dat'))

uzgag = {-68: [-68],
uzgag = {-68: [],
65: [3, 6, 1],
66: [6, 3, 2],
67: [10, 5, 3]}
uzf = flopy.modflow.ModflowUzf1(m,
nuztop=1, iuzfopt=1, irunflg=1, ietflg=1,
ipakcb=0,
iuzfcb2=61,
# binary output of recharge and groundwater discharge
ntrail2=25, nsets=20,
surfdep=1.0, uzgag=uzgag,
iuzfbnd=m.bas6.ibound.array,
irunbnd=irunbnd,
vks=vks,
finf=finf,
eps=3.5,
thts=0.3,
pet=5.000000E-08,
extdp=15.,
extwc=extwc
)
assert uzf.uzgag == uzgag
uzgag2 = {-68: [-68],
65: [3, 6, 65, 1],
66: [6, 3, 66, 2],
67: [10, 5, 67, 3]}
Expand All @@ -58,8 +81,8 @@ def test_create():
ipakcb=0,
iuzfcb2=61,
# binary output of recharge and groundwater discharge
ntrail2=25, nsets=20, nuzgag=4,
surfdep=1.0, uzgag=uzgag,
ntrail2=25, nsets=20,
surfdep=1.0, uzgag=uzgag2,
iuzfbnd=m.bas6.ibound.array,
irunbnd=irunbnd,
vks=vks,
Expand All @@ -70,13 +93,36 @@ def test_create():
extdp=15.,
extwc=extwc
)
assert uzf.uzgag == uzgag
uzgaglist = [[-68],
[3, 6, 65, 1],
[6, 3, 66, 2],
[10, 5, 67, 3]]
uzf = flopy.modflow.ModflowUzf1(m,
nuztop=1, iuzfopt=1, irunflg=1, ietflg=1,
ipakcb=0,
iuzfcb2=61,
# binary output of recharge and groundwater discharge
ntrail2=25, nsets=20,
surfdep=1.0, uzgag=uzgaglist,
iuzfbnd=m.bas6.ibound.array,
irunbnd=irunbnd,
vks=vks,
finf=finf,
eps=3.5,
thts=0.3,
pet=5.000000E-08,
extdp=15.,
extwc=extwc
)
assert uzf.uzgag == uzgag
m.write_input()

uzf2 = flopy.modflow.ModflowUzf1.load(os.path.join(cpth, uzf.file_name[0]), m)
assert uzf2.uzgag == uzgag
m2 = flopy.modflow.Modflow.load('UZFtest2.nam', version='mf2005',
exe_name='mf2005',
verbose=True,
model_ws=os.path.split(gpth)[0])

model_ws=os.path.split(gpth)[0], forgive=False)
# verify that all of the arrays in the created UZF package are the same
# as those in the loaded example
attrs = [attr for attr in dir(uzf)
Expand Down
2 changes: 2 additions & 0 deletions autotest/t049_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,8 @@ def test_pathline_plot():
run = False
lpth = pth

nampath = os.path.join(lpth, mfnam)
assert os.path.exists(nampath), "namefile {} doesn't exist.".format(nampath)
# load the modflow files for model map
m = flopy.modflow.Modflow.load(mfnam, model_ws=lpth, verbose=True, forgive=False,
exe_name=mf2005_exe)
Expand Down
11 changes: 11 additions & 0 deletions docs/version_changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ FloPy Changes
* MODFLOW 6 identifiers are now zero based
* Added remove_package method in MFSimulation and MFModel that removes MODFLOW 6 packages from the existing simulation/model
* Flopy code for MODFLOW 6 generalized to support different model types
* Added `ModflowSfr2.export_transient_variable` method to export shapefiles of segment data variables, with stress period data as attributes
* Added support for UZF package gages

* Bug fixes:
* Fixed issue with default settings for MODFLOW 5 SUB package `dp` dataset.
Expand All @@ -17,6 +19,10 @@ FloPy Changes
* IMS file name conflicts now automatically resolved
* Fixed issue with passing in numpy ndarrays arrays as layered data
* Doc string formatting for MODFLOW 6 packages fixed to make doc strings easier to read
* UZF package: fixed issues with handling of finf, pet, extdp and extwc arrays.
* SFR package: fixed issue with reading stress period data where not all segments are listed for periods > 0.
* `SpatialReference.write_gridSpec` was not converting the model origin coordinates to model length units.
* shorted integer field lengths written to shapefiles to 18 characters; some readers may misinterpret longer field lengths as float dtypes.

### Version 3.2.8
* Added `has_package(name)` method to see if a package exists. This feature goes nicely with `get_package(name)` method.
Expand All @@ -25,6 +31,11 @@ FloPy Changes
* Installation: Added dfn files required by MODFLOW 6 functionality to MANIFEST.in so that they are included in the distribution.
* SFR2 package: Fixed issue reading transient data when `ISFOPT` is 4 or 5 for the first stress period.

### Version 3.2.7 - develop
* Added SFR2 package functionarlity
* `export_inlets` method to write shapefile showing locations where external flows are entering the stream network.


### Version 3.2.7
* Added beta support for MODFLOW 6 See [here](./mf6.md) for more information.
* Added support for retrieving time series from binary cell-by-cell files. Cell-by-cell time series are accessed in the same way they are accessed for heads and concentrations but a text string is required.
Expand Down
Loading