Flopy AttributeError: output

140 views
Skip to first unread message

Angelo Breda

unread,
Jul 20, 2021, 3:34:58 AM7/20/21
to MODFLOW Users Group
Hello guys! I have not found any other discussion group specific for Flopy, so I will try here.

I just started with MODFLOW but I have experience in Python, so I am trying to use the Flopy library. I ran the "Quick start" example on flopy's Github page:

import os
import flopy
ws = './mymodel'
name = 'mymodel'
sim = flopy.mf6.MFSimulation(sim_name=name, sim_ws=ws, exe_name='mf6')
tdis = flopy.mf6.ModflowTdis(sim)
ims = flopy.mf6.ModflowIms(sim)
gwf = flopy.mf6.ModflowGwf(sim, modelname=name, save_flows=True)
dis = flopy.mf6.ModflowGwfdis(gwf, nrow=10, ncol=10)
ic = flopy.mf6.ModflowGwfic(gwf)
npf = flopy.mf6.ModflowGwfnpf(gwf, save_specific_discharge=True)
chd = flopy.mf6.ModflowGwfchd(gwf, stress_period_data=[[(0, 0, 0), 1.],
                                                       [(0, 9, 9), 0.]])
budget_file = name + '.bud'
head_file = name + '.hds'
oc = flopy.mf6.ModflowGwfoc(gwf,
                            budget_filerecord=budget_file,
                            head_filerecord=head_file,
                            saverecord=[('HEAD', 'ALL'), ('BUDGET', 'ALL')])
sim.write_simulation()
sim.run_simulation()

head = gwf.output.head().get_data()
bud = gwf.output.budget()

spdis = bud.get_data(text='DATA-SPDIS')[0]
pmv = flopy.plot.PlotMapView(gwf)
pmv.plot_array(head)
pmv.plot_grid(colors='white')
pmv.contour_array(head, levels=[.2, .4, .6, .8], linewidths=3.)
pmv.plot_specific_discharge(spdis, color='white')

But got the following error when I run it:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-1-8e7554ad25d5> in <module>
     21 sim.run_simulation()
     22
---> 23 head = gwf.output.head().get_data()
     24 bud = gwf.output.budget()
     25

~\Anaconda3\lib\site-packages\flopy\mf6\mfmodel.py in __getattr__(self, item)
    216         if package is not None:
    217             return package
--> 218         raise AttributeError(item)
    219
    220     def __repr__(self):

AttributeError: output



Did anyone get something similar before? Is it a version issue? My floppy version is 3.3.3

Cheers!

Rodrigo Brust

unread,
Aug 4, 2021, 1:07:54 AM8/4/21
to MODFLOW Users Group
I'm facing the same thing. I also have flopy 3.3.3, and I'm using Ubuntu 20.04 LTS with binary exe from MF6. 

Joseph Hughes

unread,
Aug 14, 2021, 1:49:45 AM8/14/21
to MODFLOW Users Group
The .output  functionality is only available in flopy version 3.3.4 which was just released. If you are looking at the GitHub repo please be aware that it may display functionality available in the development version of flopy (release candidate).
Reply all
Reply to author
Forward
0 new messages