Reputation: 307
I'm taking a shot in the dark that someone can guide me with this. I've just started working on this and information is not so easy to find. I have a python code that simulates land use change and can output arcgis raster images. The watershed model SWAT uses these images to calculate land use parameters generating streamflow quantities. I have the source code for SWAT, it's written in fortran. I'm basically asking how to talk with SWAT using my python code. SWAT uses txt files to compile the watershed model. I need to intercept SWATs writting of txt files with my simulated land use rasters...over and over again for each yearly change of land use. I don't know where to start so any advice on the process would be greatly appreciated. Thanks!
Upvotes: 3
Views: 2073
Reputation: 50220
SWAT is probably written to run non-interactively (in "batch" mode). If it generates lots and lots of files with a single call, your program can read them in and process them. If it needs to be called a lot of times to generate your results, you can call SWAT from your python program. Figure out how the command line options (or control file) that SWAT needs, then take a look at the python module subprocess
.
Upvotes: 1
Reputation: 69222
Have you looked at F2PY? If SWAT has already, or you could write yourself, a way to get the data before it's written to the file, you could make a fairly seamless interface. (I did this type of things years ago for some legacy code and was super happy with the result. It made working with the program and data much, much easier.)
Upvotes: 2