Transfer best_value of all parameter back to SWAT model

96 views
Skip to first unread message

Minsu KIM

unread,
Dec 6, 2024, 4:12:49 PM12/6/24
to R-SWAT
Dear Dr. Tam Nguyen and all members,
After calibration, I obtained the best set of values for all my parameters. I would like to ask how we can transfer these parameters back to SWAT quickly and easily. I knew the old way of doing it by manually entering the calibrated parameters one by one through the manual calibrator tab in the SWAT editor. However, this approach can sometimes lead to errors, especially when dealing with a large number of parameters.

I would really appreciate your help!

Best Regrads,

Tam Nguyen

unread,
Dec 6, 2024, 4:17:11 PM12/6/24
to R-SWAT
Hi, you don't need to do one by one but can export/save to good parametersets to text file and then run SWAT again with parameters from user defined file (that text file). Is this the way that you are using?

So if you want to have TxtInOut with all new parametersets, you should set the number of cores/threads the same as the number of parametersets from that parameter file

hope this helps

ana corrochano

unread,
Dec 11, 2024, 1:55:42 PM12/11/24
to R-SWAT
Hello Tam,

I also need to extract the best parameters to then run SWAT + Editor. If I'm running 200 iterations using 4 parallel runs, how do I know which  TxtInOut I need to use?

I don't completely understand when you say "So if you want to have TxtInOut with all new parametersets, you should set the number of cores/threads the same as the number of parametersets from that parameter file"

Tam Nguyen

unread,
Dec 17, 2024, 2:46:26 PM12/17/24
to R-SWAT
hi, if you just want to have the best parameterset(s), you can sort by the objective function of the calibration period and export to the csv file (Step 4.1 or 4.3)

Wayana Dolan

unread,
4:49 AM (4 hours ago) 4:49 AM
to R-SWAT
Hi Tam,

I have a similar question. If I am running 2000 latin hypercube samples for calibration on 30 cores, I can then find the set of parameters associated with the best model accuracy. Let's say that overall, the best parameter set is associated with simulation/parameter set 100. which happens to be the 5th simulation run on core 3 (for example). If I then want to generate a new best model, my initial thought would be to apply that best parameter set to update the original model. Doing this, and running the new updated model, produces output values that are very nearly the same as the outputs associated with the calibration associated with parameter set 100. The difference between the two seems like it is small enough it could be attributed to a rounding error. 

However, I was doing some reading, and it seems like the process might be more iterative if you are using multiple cores? For example, does the calibration process copy the original model to the core once, and then, for the first run, apply parameter changes to that original model, generating a new model. And then the next iteration in that core modifies the new model, and so on and so forth. If I try to update the original model using these more iterative procedures, then it really doesn't seem to match the outputs from the original calibration. But maybe I have a coding error. 

Sorry if that is confusing to write!

The relevant part of the code, I think is:
# 16. Set first run is true so R-SWAT will delete previous simulation
firstRun <- TRUE
copyUnchangeFiles <- TRUE

# 17. Get content of the file.cio file (about simulation time)
fileCioInfo <- getSimTime(TxtInOutFolder)

# 18. Now start to run SWAT
runSWATpar(workingFolder,TxtInOutFolder,outputExtraction,ncores,SWATexeFile,
           parameterValue,paraSelection,caliParam,copyUnchangeFiles,fileCioInfo,
           dateRangeCali,firstRun, outputFun)
Reply all
Reply to author
Forward
0 new messages