Skip to content
Merged
4 changes: 2 additions & 2 deletions autotest/t007_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1312,7 +1312,7 @@ def test_export_contourf():
# test_vertex_model_dot_plot()
#test_sr_with_Map()
#test_modelgrid_with_PlotMapView()
# test_epsgs()
test_epsgs()
# test_sr_scaling()
# test_read_usgs_model_reference()
#test_dynamic_xll_yll()
Expand All @@ -1330,5 +1330,5 @@ def test_export_contourf():
#test_export_array_contours()
#test_tricontour_NaN()
#test_export_contourf()
test_sr()
#test_sr()
pass
38 changes: 37 additions & 1 deletion autotest/t020_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,5 +147,41 @@ def test_mfnwt_run():
return


def test_irch():
import os
import flopy
org_model_ws = os.path.join("..","examples","data","freyberg_multilayer_transient")
nam_file = "freyberg.nam"
m = flopy.modflow.Modflow.load(nam_file,model_ws=org_model_ws,check=False,forgive=False,
verbose=True)
irch = {}
for kper in range(m.nper):
arr = np.random.randint(0,m.nlay,size=(m.nrow,m.ncol))
irch[kper] = arr

m.remove_package("RCH")
flopy.modflow.ModflowRch(m,rech=0.1,irch=irch,nrchop=2)

for kper in range(m.nper):
arr = irch[kper]
aarr = m.rch.irch[kper].array
d = arr - aarr
assert np.abs(d).sum() == 0


new_model_ws = "temp"
m.change_model_ws(new_model_ws)
m.write_input()
mm = flopy.modflow.Modflow.load(nam_file,model_ws="temp",forgive=False,verbose=True,
check=False)
for kper in range(m.nper):
arr = irch[kper]
aarr = mm.rch.irch[kper].array
d = arr - aarr
assert np.abs(d).sum() == 0



if __name__ == '__main__':
test_mfnwt_run()
# test_mfnwt_run()
test_irch()
9 changes: 6 additions & 3 deletions autotest/t032_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,13 @@ def test_epsgreference():
ep.reset()
ep.show()

prjtxt = CRS.getprj(32614) # WGS 84 / UTM zone 14N
prjtxt = CRS.getprj(32614) # WGS 84 / UTM zone 14N
if prjtxt is None:
print("unable to retrieve CRS prj txt")
return
if sys.version_info[0] == 2:
prjtxt = prjtxt.encode('ascii')
assert isinstance(prjtxt, str)
assert isinstance(prjtxt, str),type(prjtxt)
prj = ep.to_dict()
assert 32614 in prj
ep.show()
Expand All @@ -111,5 +114,5 @@ def test_epsgreference():

if __name__ == '__main__':
#test_polygon_from_ij()
#test_epsgref()
test_epsgreference()
pass
18 changes: 15 additions & 3 deletions flopy/modflow/mfrch.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ def __init__(self, model, nrchop=3, ipakcb=None, rech=1e-3, irch=0,
rech, name='rech_')
if self.nrchop == 2:
self.irch = Transient2d(model, (nrow, ncol), np.int32,
irch + 1,
irch,
name='irch_')
else:
self.irch = None
Expand Down Expand Up @@ -287,10 +287,21 @@ def write_file(self, check=True, f=None):
f_rch = open(self.fn_path, 'w')
f_rch.write('{0:s}\n'.format(self.heading))
f_rch.write('{0:10d}{1:10d}\n'.format(self.nrchop, self.ipakcb))

if self.nrchop == 2:
irch = {}
for kper,u2d in self.irch.transient_2ds.items():
irch[kper] = u2d.array + 1
irch = Transient2d(self.parent
,self.irch.shape,
self.irch.dtype,
irch,
self.irch.name)

for kper in range(nper):
inrech, file_entry_rech = self.rech.get_kper_entry(kper)
if self.nrchop == 2:
inirch, file_entry_irch = self.irch.get_kper_entry(kper)
inirch, file_entry_irch = irch.get_kper_entry(kper)
else:
inirch = -1
f_rch.write('{0:10d}{1:10d} # {2:s}\n'.format(inrech,
Expand Down Expand Up @@ -426,7 +437,8 @@ def load(f, model, nper=None, ext_unit_dict=None, check=True):
print(txt)
t = Util2d.load(f, model, (nrow, ncol), np.int32, 'irch',
ext_unit_dict)
current_irch = t
current_irch = Util2d(model,(nrow, ncol), np.int32,
t.array - 1, "irch")
irch[iper] = current_irch

if openfile:
Expand Down