Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
23 changes: 22 additions & 1 deletion autotest/t004_test_utilarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -889,9 +889,30 @@ def test_util3d_reset():
ml.bas6.strt = arr


def test_mflist_fromfile():
"""test that when a file is passed to stress period data,
the .array attribute will load the file
"""
import pandas as pd
import flopy

wel_data = pd.DataFrame([(0,1,2, -50.0),(0,5,5, -50.0)],
columns=['k', 'i', 'j', 'flux'])
wel_data.to_csv('wel_000.dat', index=False, sep=' ',header=False)

nwt_model = flopy.modflow.Modflow('nwt_testmodel',verbose=True)
dis = flopy.modflow.ModflowDis(nwt_model, nlay=1, nrow=10, ncol=10, delr=500.0,
delc=500.0, top=100.0, botm=50.0)
wel = flopy.modflow.ModflowWel(nwt_model, stress_period_data={0: 'wel_000.dat'})
flx_array = wel.stress_period_data.array["flux"][0]
for k,i,j,flx in zip(wel_data.k,wel_data.i,wel_data.j,wel_data.flux):
assert flx_array[k,i,j] == flx


if __name__ == "__main__":
# test_util3d_reset()
test_mflist()
#test_mflist()
test_mflist_fromfile()
# test_new_get_file_entry()
# test_arrayformat()
# test_util2d_external_free_nomodelws()
Expand Down
2 changes: 2 additions & 0 deletions flopy/utils/util_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -1086,6 +1086,8 @@ def to_array(self, kper=0, mask=False):
kper = self.__find_last_kper(kper)

sarr = self.data[kper]
if isinstance(sarr, str):
sarr = self.__fromfile(sarr)

if np.isscalar(sarr):
# if there are no entries for this kper
Expand Down