In [1]:
import os
import numpy as np
import pandas as pd
import flopy
In [2]:
path = '../data/'
mfnam = 'test1ss.nam'
mfsfr = 'test1ss.sfr'
model_ws = path + 'test-run'
outpath = 'written_sfr/'
In [3]:
m = flopy.modflow.Modflow.load(mfnam, model_ws=model_ws, verbose=True)
Creating new model with name: test1ss
--------------------------------------------------
Parsing the namefile --> ../data/test-run/test1ss.nam
Setting filehandles:
could not set filehandle for test1ss.lst
could not set filehandle for test1ss.hds
could not set filehandle for test1ss.et
could not set filehandle for test1ss.flw
could not set filehandle for test1ss.sg1
could not set filehandle for test1ss.sg2
could not set filehandle for test1ss.sg3
could not set filehandle for test1ss.sg4
could not set filehandle for test1ss.sg5
could not set filehandle for test1ss.sg6
could not set filehandle for test1ss.sg7
could not set filehandle for test1ss.sg8
could not set filehandle for test1ss.dvsg9
--------------------------------------------------
External unit dictionary:
{7: <flopy.utils.mfreadnam.NamData object at 0x1088bbbe0>, 8: <flopy.utils.mfreadnam.NamData object at 0x1088bbd30>, 9: <flopy.utils.mfreadnam.NamData object at 0x1088bbac8>, 75: <flopy.utils.mfreadnam.NamData object at 0x1088bba58>, 13: <flopy.utils.mfreadnam.NamData object at 0x1088bbeb8>, 14: <flopy.utils.mfreadnam.NamData object at 0x10893d048>, 15: <flopy.utils.mfreadnam.NamData object at 0x10893d198>, 81: <flopy.utils.mfreadnam.NamData object at 0x10893d780>, 18: <flopy.utils.mfreadnam.NamData object at 0x10893d438>, 83: <flopy.utils.mfreadnam.NamData object at 0x10893d7f0>, 84: <flopy.utils.mfreadnam.NamData object at 0x10893d860>, 85: <flopy.utils.mfreadnam.NamData object at 0x10893d8d0>, 86: <flopy.utils.mfreadnam.NamData object at 0x10893d940>, 87: <flopy.utils.mfreadnam.NamData object at 0x10893d9b0>, 88: <flopy.utils.mfreadnam.NamData object at 0x10893da20>, 89: <flopy.utils.mfreadnam.NamData object at 0x10893da90>, 90: <flopy.utils.mfreadnam.NamData object at 0x10893db00>, 91: <flopy.utils.mfreadnam.NamData object at 0x10893db70>, 32: <flopy.utils.mfreadnam.NamData object at 0x10893d6d8>, 17: <flopy.utils.mfreadnam.NamData object at 0x10893d2e8>, 19: <flopy.utils.mfreadnam.NamData object at 0x10893d588>, 58: <flopy.utils.mfreadnam.NamData object at 0x10893d5f8>, 59: <flopy.utils.mfreadnam.NamData object at 0x10893d748>}
--------------------------------------------------
loading dis package file...
Loading dis package with:
1 layers, 15 rows, 10 columns, and 1 stress periods
loading laycbd...
loading delr...
loading delc...
loading top...
loading botm...
loading stress period data...
adding Package: DIS
DIS package load...success
loading lpf package file...
loading IBCFCB, HDRY, NPLPF...
loading LAYTYP...
loading LAYAVG...
loading CHANI...
loading LAYVKA...
loading LAYWET...
loading hk layer 1...
loading vka layer 1...
adding Package: LPF
LPF package load...success
LIST package load...skipped
loading bas6 package file...
adding Package: BAS6
BAS6 package load...success
loading sip package file...
Warning: load method not completed. default sip object created.
adding Package: SIP
SIP package load...success
loading oc package file...
adding Package: OC
OC package load...success
adding Package: SFR2
SFR2 package load...success
DATA file load...skipped
test1ss.flw
loading evt package file...
loading surf stress period 1...
loading evtr stress period 1...
loading exdp stress period 1...
adding Package: EVT
EVT package load...success
DATA file load...skipped
test1ss.sg1
DATA file load...skipped
test1ss.sg2
DATA file load...skipped
test1ss.sg3
DATA file load...skipped
test1ss.sg4
DATA file load...skipped
test1ss.sg5
DATA file load...skipped
test1ss.sg6
DATA file load...skipped
test1ss.sg7
DATA file load...skipped
test1ss.sg8
DATA file load...skipped
test1ss.dvsg9
GAGE package load...skipped
loading ghb package file...
loading <class 'flopy.modflow.mfghb.ModflowGhb'> for kper 1
adding Package: GHB
GHB package load...success
loading rch package file...
loading rech stress period 1...
adding Package: RCH
RCH package load...success
DATA file load...skipped
test1ss.hds
DATA(binary) file load...skipped
test1ss.et
The following 9 packages were successfully loaded.
test1ss.dis
test1ss.lpf
test1ss.ba6
test1ss.sip
test1ss.oc
test1ss.sfr
test1ss.evt
test1ss.ghb
test1ss.rch
The following 2 packages were not loaded.
test1ss.lst
test1ss.gag
In [4]:
sfr = m.get_package('SFR2')
In [5]:
sfr.nstrm, sfr.nss, sfr.const, sfr.dleak, sfr.istcb1, sfr.istcb2
Out[5]:
(36, 8, 1.486, 0.0001, -1, 81)
In [6]:
reach_data = sfr.reach_data
reach_data
Out[6]:
rec.array([(0, 0, 0, 1, 1, 4500.0), (0, 1, 1, 1, 2, 7000.0),
(0, 2, 2, 1, 3, 6000.0), (0, 2, 3, 1, 4, 5550.0),
(0, 3, 4, 2, 1, 6500.0), (0, 4, 5, 2, 2, 5000.0),
(0, 5, 5, 2, 3, 5000.0), (0, 6, 5, 2, 4, 5000.0),
(0, 7, 5, 2, 5, 5000.0), (0, 2, 4, 3, 1, 5000.0),
(0, 2, 5, 3, 2, 5000.0), (0, 2, 6, 3, 3, 4500.0),
(0, 3, 7, 3, 4, 6000.0), (0, 4, 7, 3, 5, 5000.0),
(0, 5, 7, 3, 6, 2000.0), (0, 4, 9, 4, 1, 2500.0),
(0, 4, 8, 4, 2, 5000.0), (0, 5, 7, 4, 3, 3500.0),
(0, 5, 7, 5, 1, 4000.0), (0, 6, 6, 5, 2, 5000.0),
(0, 7, 6, 5, 3, 3500.0), (0, 7, 5, 5, 4, 2500.0),
(0, 8, 5, 6, 1, 5000.0), (0, 9, 6, 6, 2, 5000.0),
(0, 10, 6, 6, 3, 5000.0), (0, 11, 6, 6, 4, 5000.0),
(0, 12, 6, 6, 5, 2000.0), (0, 13, 8, 7, 1, 5000.0),
(0, 12, 7, 7, 2, 5500.0), (0, 12, 6, 7, 3, 5000.0),
(0, 12, 5, 8, 1, 5000.0), (0, 12, 4, 8, 2, 5000.0),
(0, 12, 3, 8, 3, 5000.0), (0, 12, 2, 8, 4, 5000.0),
(0, 12, 1, 8, 5, 5000.0), (0, 12, 0, 8, 6, 3000.0)],
dtype=[('krch', '<i8'), ('irch', '<i8'), ('jrch', '<i8'), ('iseg', '<i8'), ('ireach', '<i8'), ('rchlen', '<f4')])
In [7]:
sfr.dataset_5
Out[7]:
{0: [8, 0, 0, 0]}
In [8]:
sfr.segment_data
Out[8]:
{0: rec.array([ (1, 4, 2, 0, 0, 11, 25.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2.9999999242136255e-05, 3.0, 1095.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2.9999999242136255e-05, 3.0, 1075.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0),
(2, 1, 6, 0, 0, 0, 0.0, 0.0, 0.0, 0.0, 0.029999999329447746, 0.0, 0.0, 0.0, 0.0, 0.0, 2.9999999242136255e-05, 3.0, 1075.0, 12.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2.9999999242136255e-05, 3.0, 1050.0, 12.0, 0.0, 0.0, 0.0, 0.0, 0.0),
(3, 0, 5, 1, 0, 0, 10.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2.9999999242136255e-05, 2.0, 1075.0, 10.0, 2.0, 0.0, 0.0, 0.0, 0.0, 2.9999999242136255e-05, 2.0, 1060.0, 6.0, 1.0, 0.0, 0.0, 0.0, 0.0),
(4, 1, 5, 0, 0, 0, 10.0, 0.0, 0.0, 0.0, 0.029999999329447746, 0.0, 0.0, 0.0, 0.0, 0.0, 2.9999999242136255e-05, 3.0, 1080.0, 10.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2.9999999242136255e-05, 3.0, 1060.0, 10.0, 0.0, 0.0, 0.0, 0.0, 0.0),
(5, 3, 6, 0, 0, 0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.30000001192092896, 0.3499999940395355, 3.799999952316284, 0.6000000238418579, 2.9999999242136255e-05, 3.0, 1060.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2.9999999242136255e-05, 3.0, 1045.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0),
(6, 1, 8, 0, 0, 0, 0.0, 0.0, 0.0, 0.0, 0.029999999329447746, 0.0, 0.0, 0.0, 0.0, 0.0, 2.9999999242136255e-05, 3.0, 1045.0, 12.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2.9999999242136255e-05, 3.0, 1025.0, 12.0, 0.0, 0.0, 0.0, 0.0, 0.0),
(7, 2, 8, 0, 0, 0, 150.0, 0.0, 0.0, 0.0, 0.02500000037252903, 0.04500000178813934, 0.0, 0.0, 0.0, 0.0, 5.999999848427251e-05, 3.0, 1040.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 5.999999848427251e-05, 3.0, 1025.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0),
(8, 2, 0, 0, 0, 0, 0.0, 0.0, 0.0, 0.0, 0.02500000037252903, 0.04500000178813934, 0.0, 0.0, 0.0, 0.0, 5.999999848427251e-05, 3.0, 1025.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 5.999999848427251e-05, 3.0, 990.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0)],
dtype=[('nseg', '<i8'), ('icalc', '<i8'), ('outseg', '<i8'), ('iupseg', '<i8'), ('iprior', '<i8'), ('nstrpts', '<i8'), ('flow', '<f4'), ('runoff', '<f4'), ('etsw', '<f4'), ('pptsw', '<f4'), ('roughch', '<f4'), ('roughbk', '<f4'), ('cdpth', '<f4'), ('fdpth', '<f4'), ('awdth', '<f4'), ('bwdth', '<f4'), ('hcond1', '<f4'), ('thickm1', '<f4'), ('elevup1', '<f4'), ('width1', '<f4'), ('depth1', '<f4'), ('thts1', '<f4'), ('thti1', '<f4'), ('eps1', '<f4'), ('uhc1', '<f4'), ('hcond2', '<f4'), ('thickm2', '<f4'), ('elevup2', '<f4'), ('width2', '<f4'), ('depth2', '<f4'), ('thts2', '<f4'), ('thti2', '<f4'), ('eps2', '<f4'), ('uhc2', '<f4')])}
In [9]:
pd.DataFrame(sfr.segment_data[0])
Out[9]:
nseg
icalc
outseg
iupseg
iprior
nstrpts
flow
runoff
etsw
pptsw
...
uhc1
hcond2
thickm2
elevup2
width2
depth2
thts2
thti2
eps2
uhc2
0
1
4
2
0
0
11
25
0
0
0
...
0
0.00003
3
1075
0
0
0
0
0
0
1
2
1
6
0
0
0
0
0
0
0
...
0
0.00003
3
1050
12
0
0
0
0
0
2
3
0
5
1
0
0
10
0
0
0
...
0
0.00003
2
1060
6
1
0
0
0
0
3
4
1
5
0
0
0
10
0
0
0
...
0
0.00003
3
1060
10
0
0
0
0
0
4
5
3
6
0
0
0
0
0
0
0
...
0
0.00003
3
1045
0
0
0
0
0
0
5
6
1
8
0
0
0
0
0
0
0
...
0
0.00003
3
1025
12
0
0
0
0
0
6
7
2
8
0
0
0
150
0
0
0
...
0
0.00006
3
1025
0
0
0
0
0
0
7
8
2
0
0
0
0
0
0
0
0
...
0
0.00006
3
990
0
0
0
0
0
0
8 rows × 34 columns
In [10]:
sfr.get_empty_reach_data()
Out[10]:
rec.array([],
dtype=[('krch', '<i8'), ('irch', '<i8'), ('jrch', '<i8'), ('iseg', '<i8'), ('ireach', '<i8'), ('rchlen', '<f4'), ('strtop', '<f4'), ('slope', '<f4'), ('strthick', '<f4'), ('strhc1', '<f4'), ('thts', '<i8'), ('thti', '<f4'), ('eps', '<f4'), ('uhc', '<f4')])
In [11]:
sfr.get_empty_segment_data()
Out[11]:
rec.array([],
dtype=[('nseg', '<i8'), ('icalc', '<i8'), ('outseg', '<i8'), ('iupseg', '<i8'), ('iprior', '<i8'), ('nstrpts', '<i8'), ('flow', '<f4'), ('runoff', '<f4'), ('etsw', '<f4'), ('pptsw', '<f4'), ('roughch', '<f4'), ('roughbk', '<f4'), ('cdpth', '<f4'), ('fdpth', '<f4'), ('awdth', '<f4'), ('bwdth', '<f4'), ('hcond1', '<f4'), ('thickm1', '<f4'), ('elevup1', '<f4'), ('width1', '<f4'), ('depth1', '<f4'), ('thts1', '<f4'), ('thti1', '<f4'), ('eps1', '<f4'), ('uhc1', '<f4'), ('hcond2', '<f4'), ('thickm2', '<f4'), ('elevup2', '<f4'), ('width2', '<f4'), ('depth2', '<f4'), ('thts2', '<f4'), ('thti2', '<f4'), ('eps2', '<f4'), ('uhc2', '<f4')])
In [12]:
sfr.write(outpath + mfsfr)
In [13]:
sfr = flopy.modflow.ModflowSfr2.load(outpath + mfsfr, m)
****Warning -- two packages of the same type: <class 'flopy.modflow.mfsfr2.ModflowSfr2'> <class 'flopy.modflow.mfsfr2.ModflowSfr2'>
replacing existing Package...
In [14]:
np.array_equal(reach_data, sfr.reach_data)
Out[14]:
True
In [ ]:
Content source: brclark-usgs/flopy
Similar notebooks: