Flopy: PEST / pyEMU

811 views
Skip to first unread message

Leander

unread,
Jan 11, 2021, 6:08:25 AM1/11/21
to MODFLOW Users Group
Hello everybody, 

I'm struggeling getting pyEMU working for my MODFLOW 6 model.

The example (on github: pstfrom_mf6.ipynb) uses unformated txt files to get the properties and stress period data into the pyEMU environement with an 'OPEN/CLOSE' command. 
Is there a possibility to make pyEMU read MODFLOW 6 files directly? Or do I have to reformat the MODFLOW 6 files?
It seemes that currently pyEMU is only familiar with the MODFLOW2005 structure.

Many thanks!
Leander

Tariq Laattoe

unread,
Jan 12, 2021, 2:23:04 AM1/12/21
to MODFLOW Users Group
Hi,

Might need to know the following before offering any suggestions.

Can you successfully run the notebook as it is with the example problem? 
Are you able to load your model with Flopy? 

Tariq

Leander

unread,
Jan 13, 2021, 1:27:57 AM1/13/21
to MODFLOW Users Group
Hi, 
Thanks for the answer Tariq. 
To your questions: I couldn't run the notebook, because I wasn't able to implement my own data (created with flopy) appropriate.

I got an answer from J.T.White (https://github.com/pypest/pyemu/issues/212). This solution worked for me (after some struggles with flopy version and code structure).

If you have further recommendations for tutorials, examples or literature about calibrating with python/pyemu I'd be glad to get your hints ;)

Regards, Leander



Tariq Laattoe

unread,
Jan 13, 2021, 4:47:24 AM1/13/21
to MODFLOW Users Group
Hi,

I thought it might be a version issue. It's usually always a good idea to make sure that you can run the example using its own data first. That way you rule out any version/installation/path issues straight away. Glad you got it all up and running. I slowly worked my way through all the notebooks by changing them to work with my own models and data. PyEMU definitely helps a lot with highly parameterized inversion. That said, getting your head around all the intricacies of PEST and PESTPP is just as big a challenge. Happy to help out with any further questions.

Tariq

Leander

unread,
Feb 3, 2021, 6:55:52 AM2/3/21
to MODFLOW Users Group
Hi, 

I still can't execute PEST. Neither the github example (pstfrom_mf6.ipynb) nor my own model. Both are stuck with the same error message.
I guess a step in the setup is missing...

The error message i get in the console: 
model input/output error:error in template files
Parameter "multiplier_h" cited on line 2 of template file hk_layer_1_inst0_grid.csv.tpl has not been supplied with a value
  Aborting model run

 numin          28

  model input/output error:initializing mio module
Error in subroutine MIO_INITIALISE: cannot allocate sufficient memory to store model interface filenames
  Aborting model run
(to my understanding, there are values on line 2 - maybe a format error??)

After executing the following commands in the notebook (from the example):
# run with noptmax = 0
pyemu.os_utils.run("{0} freyberg.pst".format(
    os.path.join("pestpp-ies")), cwd=pf.new_d)

Error message from the notebook:
~\Anaconda3\lib\site-packages\pyemu\utils\os_utils.py in run(cmd_str, cwd, verbose) 
if "window" in platform.platform().lower(): 
if ret_val != 0raise Exception("run() returned non-zero: {0}".format(ret_val)) 
else: estat = os.WEXITSTATUS(ret_val) 
    Exception: run() returned non-zero: -1073740940

Has anyone (Tariq ? :) ) an idea, how to properly run pest from python (with pyemu)?  
Any tips for a documentation or example? 
Are there further PEST files required than pest-ies.exe?

Many thanks! 
Leander 

 

Tariq Laattoe

unread,
Feb 3, 2021, 11:16:59 AM2/3/21
to MODFLOW Users Group
Hi,
I always troubleshoot PEST template file errors using TEMPCHEK, a utility that is part of the PEST suite. The variable that is unassigned has to come from the PEST control file itself or in the case of IES an ensemble of parameters kept in a .csv or a .jcb file.
Are you cloning the repository so that you have all the directories? I've come unstuck there before by just downloading the notebooks and not making sure that I have all the ancillary files plus their paths correct before trying to run the notebooks. Failing that perhaps consider putting the pestpp-ies.exe is in the system path. I'll have a crack at the notebook myself tomorrow and get back to you. I'm currently working with glm, ies and opt but using MF-USG so haven't really played with the pyemu mf6 features.  
Tariq

Jeremy White

unread,
Feb 3, 2021, 10:53:37 PM2/3/21
to MODFLOW Users Group
I think you might be using an old(er) pest++ executable - pest++ v5 no longer uses the MIO module (which requires par names <=12 chars and obs names <= 20 chars).  The mf6 pstfrom demo notebook gets checked/run each time changes are made to pyemu/pest++ but you need to have the more recent pest++ and mf6 executables in a location that can found by the system.    The latest pest++ executables can be found here:

If you put the latest executables in a system-known place, that notebook should run...

Randall Hanson

unread,
Feb 3, 2021, 10:53:50 PM2/3/21
to mod...@googlegroups.com
Hey Leander and Tariq,
One thing that we had an issue with (maybe a bug in Pest?) is that if you include a path or a relative path for the model (or batch file that runs you model and any pre- and post-processing) in your Pest Control file, Pest gave some weird errors like this that were not related to the real problem. Once the Pest control file is in the same directory it seems to work ok. I notified John about this but didn't get a response. But we use Pest straight away and not in any python apps.
Cheers,
Randy Hanson
One-Water Hydrologic

--
You received this message because you are subscribed to the Google Groups "MODFLOW Users Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to modflow+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/modflow/a1072310-31bc-4e5b-a8eb-c81240e88abfn%40googlegroups.com.

Tariq Laattoe

unread,
Feb 3, 2021, 11:12:22 PM2/3/21
to MODFLOW Users Group
Hi again,

I just ran the notebook as it is without any issues. I downloaded the repo as a zip and loaded into a folder. I also had to upgrade to the latest versions of both flopy and pyemu. Prior to upgrading I ran into all sorts of problems. Below outlines what I did to run it.

I run Anaconda so started by entering an environment with : 
conda activate base 

once in an environment I entered:
pip install --upgrade --user flopy

then
pip install --upgrade --user pyemu

without the --user option windows complains

I then fired up a Jupyter console in the examples folder for Pyemu and ran the notebook without any issues.

One thing that may be different on my machine is the system path to all exes I use when modelling. I have a folder that holds all MF and PEST/PESTPP exes plus all the PEST utils mapped in the path so I can call them from any command window. If you don't have this then you may run into problems.

Hope that helps you get the notebook running at least.

Tariq

Leander

unread,
Feb 5, 2021, 8:44:02 AM2/5/21
to MODFLOW Users Group
Thank you guys! The example-notebook is working well!
I used an ancient PEST version. 

I have to figure out some issues for my own model, but I'll manage that.

What would I do without you :) 
Cheers! 
Leander

Reply all
Reply to author
Forward
0 new messages