I am using Flopy to set up a MODFLOW model in Python 2.7. I am trying to add head observations via the HOB package. The following example code is taken directly from the function documentation at https://modflowpy.github.io/flopydoc/mfhob.html:
import flopy
model = flopy.modflow.Modflow()
dis = flopy.modflow.ModflowDis(model, nlay=1, nrow=11, ncol=11,
nper=2, perlen=[1,1])
obs = flopy.modflow.mfhob.HeadObservation(model, layer=0, row=5,
column=5,
time_series_data=[[1.,54.4],
[2., 55.2]])
Using this example code for the function, I am getting the following error:
ValueError: Can't cast from structure to non-structure, except if the structure only has a single field.
I get the same error when I try to create a head observation for my model, which is steady-state and has some different input values. Unfortunately, I haven't been able to find a working example to compare with. Any ideas?
Edit: jdhughes's code works like a charm; BUT I had also neglected to update Flopy to the most recent version - I tried updating numpy first, but didn't get rid of the ValueError until I updated Flopy from 3.2.8 to 3.2.9. Works now, thank you!!!
You need to create one or more instances of a HeadObservation type and pass that to
ModflowHob
. An example with two observation locations is shown below.Will submit an issue to update the documentation and docstrings.