djlampert / PyHSPF

Python extensions to the Hydrological Simulation Program in Fortran (HSPF), including classes for gathering input data, building input files, performing simulations, postprocessing results, calibrating hydrology process parameters, and forecasting climate and land use change effects on water resources
Other
83 stars 51 forks source link

Unable to execute pyHSPF model from command line #9

Open DEQrshojin opened 5 years ago

DEQrshojin commented 5 years ago

I have created and successfully executed a watershed model by modifying your example pyHSPF scripts, however I am unsuccessful at executing the same model (uci and in/out wdm files) from either the command line or from within HPSF 3.0. The attached error message is given from both the command line and from HSPF 3.0. The HSPF executables I am using is are WinHspfLt.exe (from cmd line) and WinHSPF 3.0--both from Basins 4.1. The syntax I am using from the command line is "WinHspfLt.exe example.uci". I am running this locally (not on network) and the file paths are all less than 64 characters.

I do know that this works because I am able to run a different model from command line using .uci and .wdm files not created through pyHSPF.

Some of the methods to solve this have included, commenting out the out.wdm and external target lines in the uci (but got the same message) and reducing the model to its barest of bones (one HRU and one basin), but in all instances I get the same message.

Do you know of any incompatibilities between the wdms created by pyHSPF and WinHSPFLt/WinHSPF 3.0?

Thank you very much for pyHSPF, by the way, I think it’s a great tool for watershed modeling.

image

djlampert commented 5 years ago

I think that PyHSPF builds can run WDM files from BASINS/WinHSPF, but I do remember there being issues with people trying to run WDM files from PyHSPF back with WinHSPF. Are you just wanting to see that you get the same result either way? For me, running things in Python with the associated utilities rather than DOS or GUI is the whole point.

DEQrshojin commented 5 years ago

Thank you for getting back to me. I plan to use PEST for calibration/uncertainty. I like pyHSPF because I can build the model without the GUI & the 'no-longer-supported' WDM Utility. But, I figured it would be more efficient to do PEST directly from command line. As it stands, I can run my scripts with PEST, but I think I could reduce the run time by about 50-75 percent.

djlampert commented 5 years ago

I've had someone else comment on using PEST. I guess it would seem to me that parameter estimation methods could be explored more effectively in Python...but PEST is a "name brand" so I should try to think about how to accommodate this need. Does PEST only work with WinHSPF? I was thinking that it is independent of the model completely IIRC.

DEQrshojin commented 5 years ago

Usually I try to come at it from a few different angle, including PEST. I can get my python scripts to work with PEST, but the flow is a bit 'convoluted' and I suspect I could cut the processing time significantly if I could run it directly from command line.

djlampert commented 5 years ago

You can compile a stand alone HSPF program outside of Python. I have some instructions and a shell script/DOS script in the "misc" directory. This was how I started. I later moved the whole thing into Python. I would guess that you can figure out how to compile from what I have provided there. Please advise if it works so I can close this ticket.

DEQrshojin commented 5 years ago

I'll give that a try. Thank you.

trees4me commented 5 years ago

I've just finished a PEST-style analysis using PyHSPF to execute the runs. It worked really well. Imported the parameters using HSPsquared to a H5 file, then created some tables for modifying PERLND variables. After that I looped with each run by calculating random PERLND block and writing a uci and copying a dummy wdm and running with PyHSPF. I had a lot of RCHRES and COPY and other model complexities that made it nicer to run using some of the routines from HSPsquared or PyHSPF without importing entirely. PyHSPF is well setup for this. Checkout the hspexp.py example.
Ended up doing about 3000 runs, and calculating 30+ metrics on 4 gages. Can't imagine that oustide python...
For a simpler model that can be built within PyHSPF the autocalibrator seems much more elegant.
PyHSPF is really useful, very much a step forward compared to my past HSPF modeling. Thanks!