0% found this document useful (1 vote)
738 views

Course Notes Advanced SWAT: Calibrating Using SWAT-CUP

This document provides instructions for calibrating a SWAT model for the Santa Lucia catchment using SWAT-CUP. It outlines preparing observed data for calibration, setting up a SWAT-CUP project, and using the SUFI2 and PSO algorithms for sensitivity analysis and calibration. Key steps include formatting observed data for SWAT-CUP, defining calibration parameters and objectives, and running and evaluating the calibration simulations. The overall aim is to calibrate the SWAT model and understand uncertainty bounds from the calibration results.

Uploaded by

RahulKumarSingh
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (1 vote)
738 views

Course Notes Advanced SWAT: Calibrating Using SWAT-CUP

This document provides instructions for calibrating a SWAT model for the Santa Lucia catchment using SWAT-CUP. It outlines preparing observed data for calibration, setting up a SWAT-CUP project, and using the SUFI2 and PSO algorithms for sensitivity analysis and calibration. Key steps include formatting observed data for SWAT-CUP, defining calibration parameters and objectives, and running and evaluating the calibration simulations. The overall aim is to calibrate the SWAT model and understand uncertainty bounds from the calibration results.

Uploaded by

RahulKumarSingh
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 27

Course Notes Advanced SWAT: Calibrating

using SWAT-CUP
Willem Vervoort
2017-10-17

Introduction

This is an introduction into using SWAT CUP written for the "How do I use satellite and global
reanalysis data for hydrological simulations in SWAT?" workshop in Montevideo between 7 -
11 August 2017, jointly organised by the University of Sydney, IRI and INIA.

1
Aims of this part of the course:

• Use SWAT CUP to calibrate a SWAT model for the Santa Lucia catchment
• Understand and interpret the difference between global and local sensitivity analysis
• Independently use SUFI2 in SWAT CUP to run a sensitivity analysis
• Comprehend and manipulate the PSO calibration routines in SWAT-CUP, interpret the
outcomes of the calibration
• Comprehend uncertainty bounds indicated by SWAT-CUP in both SUFI2 and PSO
• Include other calibration data, such as MODIS ET in SWAT-CUP for calibration
• Extracting the calibrated model from SWAT-CUP for simulations

Table of Contents
Introduction ............................................................................................................................... 1
Aims of this part of the course: ................................................................................................. 2
SWAT-CUP .................................................................................................................................. 3
System requirements (for this tutorial) ................................................................................. 3
Preparing observed data for SWAT calibration ......................................................................... 4
Basic Data check..................................................................................................................... 4
SWAT CUP specific formatting ............................................................................................... 4
Setting up a SWAT-CUP project ................................................................................................. 5
Using SUFI2 for sensitivity analysis ............................................................................................ 6
Setting up the sensitivity/calibration run .......................................................................... 7
Defining the parameters to be adjusted: par_inf.txt ............................................................ 7
SUFI2_swEdit.def ............................................................................................................... 9
File.cio .............................................................................................................................. 10
Defining the observed data ................................................................................................. 10
Observed_rch.txt ............................................................................................................. 11
Var_file_rch.txt for SUFI2 ................................................................................................ 12
SUFI2_extract_rch.def ..................................................................................................... 12
Defining the Objective function: Observed.txt .................................................................... 13
Var_file_name.txt ............................................................................................................ 14
RUNNING the SUFI2 Sensitivity (or calibration analysis) ..................................................... 14
Using PSO (Particle Swarm Optimisation) ............................................................................... 17
Setting up the calibration run for Flow only ........................................................................ 17
File.cio .............................................................................................................................. 19
Defining the observed data in PSO ...................................................................................... 20
Observed_rch.txt ............................................................................................................. 20

2
Extraction component ......................................................................................................... 21
Var_file_rch.txt ................................................................................................................ 21
PSO_extract_rch.def ........................................................................................................ 21
Defining the Objective function: Observed.txt ................................................................ 22
Var_file_name.txt ............................................................................................................ 23
Running SWAT-CUP Calibration ........................................................................................... 23
Inspecting the Calibration outputs .......................................................................................... 24
Evaluation (Validation) of the SWAT model results using PSO in SWAT-CUP ......................... 25
par_inf.txt ........................................................................................................................ 25
observed_rch.txt .............................................................................................................. 26
Adjusting Observed.txt .................................................................................................... 26
Adjusting File.cio .............................................................................................................. 26

SWAT-CUP

SWAT-CUP is a calibration, validation and sensitivity analysis tool for SWAT and can be freely
downloaded. Most of the general information is provided here:
http://www.eawag.ch/forschung/siam/software/swat/index, while the program can be
downloaded here: http://www.neprashtechnology.ca/Default.aspx).
The SWAT CUP source code is not freely available, and there is also a cost if you want to use
the parallel processing routine. However, at the moment SWAT CUP is the standard in the
SWAT community for calibration. We will use SWAT-CUP running on a single core, which
means our calibration problems need to be small
This document only gives specific instructions to calibrate the SWAT model for the catchment
that we want to study (Santa Lucia). Regrettably there are only limited detailed instructions
for SWAT-CUP on the web, and also the SWAT CUP help file is not very useful.

System requirements (for this tutorial)

ARCGIS 10, SWAT 2012, SWAT CUP and possibly file access to the C drive of the computer.
Access to the build in drives of the computer will make the program run faster.
Files required:
The SWAT directory on shared drive, on which we have stored all the files needed for this
project now also includes files needed for SWAT-CUP. Copy these files to your own workspace
or to a USB drive.
This example is based on the ARCSWAT version of the Santa Lucia catchment model. The
QSWAT version would follow a similar set-up but would have many more subbasins.

3
Preparing observed data for SWAT calibration

Basic Data check

As a first check it is important to understand something about the quality of the data. To do
this it can be useful to develop annual or monthly water balances from the observed data.
This involves running a script to calculate potential ET/rough actual ET using a crop factor and
to do a simple water balance: P - ET = Q and to plot this. This should help get an understanding
of the data quality and if there are major issues with the data before we start modelling.

Your initial check of this is by looking at the SWAT output using SWAT check in ARC SWAT.

If you don’t have ARCSWAT, there is an R-script in the folder (C1A_AnalyseOutput.R) to run
the same analysis on “output.std” in the txtinout folder. This analysis already indicates
whether the order of magnitudes in the rainfall is OK. However, we should also check the
streamflow data and make a rough estimate of the Evapotranspiration.

I have developed a document that outlines the Rcode how you can do this for the Santa Lucia
catchment. You would be able to repeat this for your catchment of choice. This document
indicates some simple ways of checking whether the input data for your catchment are
reasonable and the water balance not skewed one way or the other.
The document is called C1_WaterbalanceCheckSWATInput.pdf

SWAT CUP specific formatting

SWAT-CUP requires a specific format in all the observed data to allow the calibration, and we
want to also limit the flow data to a certain period.

4
Together with former PhD student Dr Dipangkar Kundu we have written a set of R functions
that will do this, which are in the “functions” folder on the shared drive. You can call these
functions using
source(“path/to/file/SWATCUPfunctions.R”)
Where “path/to/file” is the path to the directory where you have stored the file.
I have also developed a document that demonstrates the use of these functions, which is:
“D_CreatingSWATCUPobservedData_Simplified.pdf”

Task
- We will now go through these different functions and prepare the input data

Setting up a SWAT-CUP project

This is fairly straight forward and the program steps you through the different inputs. Start by
starting a new project from the toolbar, and the wizard should guide you through the different
steps. Make sure you know where to find your working directory, and probably it will be useful
to also put this on the C:\drive (and copying it at the end of the day to your own storage).
This first step is the same between the SUFI2 and the PSO project.

Navigate to the txtinout directory of your developed SWAT model. This is important as this is
the data that SWAT-CUP will use to adjust the parameters in the model. In the next screen
choose SWAT version 2012 and 64 bit architecture.

5
Using SUFI2 for sensitivity analysis

We are initially using SUFI2 as a project type while we are concentrating on the sensitivity
analysis. Later will also use the PSO routine. Note that there are several other ways of
calibrating the model including Beven’s GLUE, ParaSol, PSO (Particle Swarm Optimisation) and
MCMC (Metropolis Monte Carlo).
Finally give your project a name and store it in your folder on the C:\drive or a USB drive (but
remember to copy it to a safe place at the end of the course).

On clicking finish SWAT-CUP will copy all the SWAT txt files to a new folder in your
XXX.Sufi2.swatcup folder. This might take some time.

6
Setting up the sensitivity/calibration run
The key elements of a calibration are (in order):
1. Defining the parameters to be adjusted. SWAT has many parameters as we discussed.
In this case we will limit ourselves to a group of parameters related to the hydrological
processes at the soil, groundwater, overland flow and routing level.
2. Defining the observed data and time period for which we will run the calibration. We
have discussed that this can be difficult.
3. Defining the objective function. Different objective functions can give different
calibration results leading to variations in the final calibrated parameters. You might
want to test this out later.
Currently, the left hand side of our SWAT-CUP interface looks like this:

Defining the parameters to be adjusted: par_inf.txt

We will start with the file “Par_inf.txt” which is the main parameter file. The text view of
Par_inf.txt gives you an overview of the parameters that are going to be calibrated and the
number of simulation runs. You can also look at the form view (below) and decide yourself
which one you find easiest to use. I will use the text view mainly Scrolling down you can see
examples of other parameters and so we need to decide how this works and what parameters
to adjust. If you plan to do very complex subsets of parameters (see below) then the form
view might be easier.

7
The text view of par_inf.txt

Example of the form view of par_inf.txt

The naming of the parameters is explained in detail on page 40 of the SWAT CUP user manual
and further, but can be summarised more briefly as follows:
Prefix Explanation
v__ “value” this means the existing parameter value will be replaced by the given
value

8
a__ “addition” this means the given value will be added to the existing parameter
values
r__ “ratio” this means the existing parameter is multiplied by (1 + given value)

The next bit is the parameter name and the extension of the related file names (as given in
SWAT) and this is followed by possible soil hydrological group, soil texture, landuse, subbasin,
slope or soil layer. So for example:
r__CN2.mgt________1 -0.2 0.2
This means, ratio parameter (r__) for the curve number base value CN2, which can be found
in the management (mgt) files and only for subbasin 1. This ratio is allowed to be varied by
the calibration routine between -0.2 and 0.2
The number of __ after “mgt” or any file extension is crucial, please check the SWAT CUP
manual or use the form view to get this right.
Or:
v__CH_K2.rte 5.0 130.0
This means, value parameter (v__) for the global channel hydraulic conductivity (CH_K2) in
the routing files (rte) which can vary between 5 and 130
Or:
a__GW_REVAP.gw________3-6 -0.1 0.0
This means additive parameter for groundwater REVAP in the gw files for subbasins 3 – 6
varying between -0.1 and 0
And finally, because there is more than one soil layer for soil K and soil AWC:
r__SOL_K(1).sol -0.8 0.8
ratio parameters for soil hydraulic conductivity for layer 1 varying between -0.8 and 0.8 and
for AWC the ratio parameters for layer 1 varying between -0.3 and 0.1
r__SOL_AWC(1).sol -0.3 0.1
When you decide on the ranges of parameters it is important to consider whether the range
actually makes sense for the parameter. Some parameters cannot be negative and some
cannot be 0.
So how do we decide which parameters are in and which are out? In SWAT-CUP this is not
fully automated and you have to make decisions about this. In a way this is good, as you can
apply your hydrological understanding to the watershed and use this as a “sanity check”. To
kick things off we have decided long range of parameters that are linked to the 4 main groups:
Soil, Groundwater, Overland Flow and Routing. I have put this as a textfile
“SWATCUPparameterexample.txt” in the shared folders. Note that there are two sets of
examples, you only want the top 29 parameters to start. You can add or delete parameters if
you like.
SUFI2_swEdit.def
You also need to adjust the next file, which is SUFI2_swEdit.def, which is unique for SUFI2.
Here you just have to set the ending simulation number to 10.

9
File.cio
You need to have a look at File.cio. This is the main control file for SWAT and defines the
period of the simulation and what output is being produced.
Check File.cio to make sure that you have set up a daily simulation, for 8 years (2006 - 2011)
and that NYSKIP is set to 2. This also means that the ending day of the simulation is 365. Check
also whether you are set to model daily data and not monthly data (IPRINT = 1).

Defining the observed data

Expanding the Observation item indicates three items that are crossed out. Basically these
are observations a three different levels: Reach (Rch), Subbasin (Sub) and HRU that you can
use in your calibration. You can activate any of them by clicking on the buttons higher up on
the left side. As a first step we only want to activate the Rch component, as we only calibrate
on Flow.

10
Observed_rch.txt
You can now open the Observed_rch.txt, which defines the data that will be used to calibrate
the model. The data that exists in the file are example data. There are two things to work out,
which reach number are we using for the calibration and how many days are we using for the
calibration. Looking back at File.cio and the model set-up, we know we only run the model for
8 years, of which two years are “warm-up”. A warm-up period is important for all larger
hydrological models as this stabilises the initial conditions.

If you think back to our simple model, we made some guesses about the initial storage in the
soil bucket and the initial storage in the groundwater. Up to a certain point in time, these
choices affect the model outcomes. In the case of our simple model, this was only a few time
steps, but in the case of a complex model this could be much longer. Therefore choosing two
years as warm-up period puts you on the safe side.

In Observed_rch.txt we will fill in that we have:


- 1 observed variable (the flow at Paso Pache station in the Santa Lucia catchment)
- FLOW_OUT_1 will be the name of the variable using 28 as the subbasin where the
outlet is, you can check this in ARCSWAT or QSWAT, but also in the fig.fig file in the txt
files.
- 1386 is the number of data points, or whatever else we decided (this is dependent on
the number of years you run the calibration for).

11
You then need to replace the rest of the file with the data which we have generated with the
R script at the start. Clip the data from the file and replace all the info in the file. This is safer
than actually replacing the file in the SUFI2 directory
Click Save, or Save all to save your changes
Var_file_rch.txt for SUFI2
Now expand the “Extraction” component and open the Var_file_rch.txt. Basically this now list
4 variables from the example. You need to replace this with the one variable that we want to
use: FLOW_OUT_1.txt

SUFI2_extract_rch.def
The next file to adjust is SUFI2_extract_rch.def. Fill in as below: 1 variable, column 7 (see
comments in green), 31 reaches in the project, 1 to use and this is number 28.
We are running 2008 – 2011 and on a daily time step.

12
Defining the Objective function: Observed.txt

Our last step is to define the objective function component. For this expand this section and
open the Observed.txt file. First we will clip and paste the data from the file which we
generated earlier with the R script in here.
Then we will adjust the top of the file:

We have:
- 1 observed variable
- We will use the KGE as our objective function (9). The other choices are highlighted in
more detail on page 44 in the SWAT-CUP manual, but basically 1 is a multiplicative
form of squared errors, while 2 is similar to a regular sum squared of errors, but allows
different flow components to be assessed separately. The third option is the classic
coefficient of determination (r2), while 4 is similar but based on the χ2 distribution.
13
Option 5 is the standard NSE. Option 6 uses the bias to force the relationship
calculated based on r2 closer to a 1:1 line, while option 7 uses the flood frequency
curves. Option 9 is the KGE, which is a bias corrected version of the NSE. We will use
this one.
- Set the next entry to 1 to make sure we capture sufficient model simulations.
- We will be using FLOW_OUT_1 as our observed values
- Don’t worry about the 6 entries, which give further options to calculate objective
functions and uncertainty.
- Finally we will use 1386 observations (or whatever else you generated in the R output)
- Below the top section you need to paste the observations from the Observed.txt that
we generated with the R script earlies.
Save and move to the next file.
Var_file_name.txt
This is essentially the same as you did before. You just need 1 line with FLOW_OUT_1.txt
Again click Save All

RUNNING the SUFI2 Sensitivity (or calibration analysis)

We are now able to run SWAT-CUP , but we are only doing a test run with 10 simulations. The
analysis is run through 3 “batch” files SUFI2_pre.bat, which sets up the separate result and
analysis files and gets everything ready, mostly by running the latin hypercube sampling of
the parameters to test, SUFI2_run.bat which runs the actual model runs, and SUFI2_post.bat,
which does the file clean-up and makes all the output for you to see and analyse. A more
detailed description of the program execution is on page 52 of the SWAT-CUP manual.
In our case we just press Execute all and this brings up a DOS box that runs SUFI2_pre.bat

Press Y and OK to start SUFI2_run.bat. This will run for a little while (remember we only asked
for 10 simulations), close the window when asked.

14
This will start SUFI2_post.bat

This confirms that we can run SUFI2 correctly and we can move on to the real calibration and
sensitivity analysis

Running more simulations for a proper sensitivity analysis


There are two things we have to do:
1. Restore the original files from backup, rather than keeping the ones after 10 runs. To
do this, go to the top left hand corner button and choose “Restore files from backup”.
This will ask you to confirm and bring up the standard windows copy interface.
Choose: Copy and replace, but remember to tick the box “do this for the next …
conflicts”. This should copy all the original files back.

15
2. Increase the number of simulations to 500 in the files: Par_inf.txt and
SUFI2_swEdit.def
Now hit Save All and Calibrate and Execute All and go through the same steps in SUFI2_pre.bat
until you can run SUFI2_run.bat. Now go and get a deserved cup of tea. This will take a while
before you get to SUFI2_post.bat (500 simulations). Run SUFI2_post.bat and make sure you
save the iteration.
Sensitivity analysis
From this point we will be working with the results of the iteration you have saved, so at the
bottom of the left hand list.

There are basically two types of sensitivity analysis and page 47 – 49 in the SWAT-CUP manual
covers this. The easiest to understand is the “one at a time” sensitivity analysis. This tests how
the objective function changes with changes in a single parameter, keeping all other
parameters constant. As the manual explains, this is somewhat problematic as we never know
what the constant values of the other parameters should be and this might influence the
outcomes. However, don’t click on this option, as it will take a long time to load
The second approach is the “Global Sensitivity analysis”, which is what we will use. This works
slightly different and is similar to the Morris method. This works basically by regressing a
multilinear model of the parameters against the changes in the objective function as a result
of perturbing the parameters values (Monte Carlo simulation). The statistics of the

16
parameters (whether they are significant or not) can be expressed in terms of a t-value or a
p-value.
TASK 1: Investigate the ranking of the parameters in the global sensitivity analysis. What are
the best 4 – 6 parameters?
You can also inspect the Dotty Plots and compare this to the earlier sensitivity analysis. The
Dotty Plots indicate also the sensitivity of a few parameters to the objective function and thus
identify whether a specific parameter can be defined or whether there is more than one
possibility.
Do the Dotty Plot results confirm the sensitivity analysis ranking?
You might want to rerun the sensitivity analysis to test different or less parameters
You can also analyse the SUFI2 results as a calibration, check the manual for more detail.

Using PSO (Particle Swarm Optimisation)

Once we have decided on the final set of parameters, using the sensitivity analysis, we can
use the PSO (Particle Swarm Optimisation) to further improve the calibration. Many of the
instructions below are very similar to the SUFI2 example, but I have left all the text in, so you
can run the two examples independently.
Finally give your project a name and store it in your folder if possible on the C:\drive, this
makes it run the fastest (but remember to copy it to a safe place at the end, such as an USB
drive). Regrettably, SWAT and SWAT-CUP have issues with running from cloud storage

Setting up the calibration run for Flow only

The key elements of a calibration are (in order):


4. Defining the parameters to be adjusted. SWAT has many parameters. In this case we
will limit ourselves to a group of parameters related to the hydrological processes at
the soil, groundwater, overland flow and routing level. But we can choose other
parameters as we go. We will discuss this later in the course.
5. Defining the observed data and time period for which we will run the calibration. We
have discussed that this can be difficult. We can use the R script to generate different
time periods for calibration. I am suggesting to use 2006 – 2011.

17
6. Defining the objective function. Different objective functions can give different
calibration results leading to variations in the final calibrated parameters. I am
suggesting we should use KGE as an objective function.
Currently, the left hand side of our SWAT-CUP interface looks like this:

Expand the “Calibration Inputs” by clicking on the + sign. This gives a list of different files,
some of which cover the points mentioned above. Double clicking on the files opens them up
in the right hand side.

Copy and paste the second set of parameters into Par_inf.txt in SWAT_CUP from
SWATCUPparameterExample.txt, or from your final parameters after sensitivity analysis using
SUFI2, this basically replaces the top parameters in par_inf.txt, or you can paste above this.
Of course you now need to adjust the top line as you now have 24 (or however many you
decide from the sensitivity analysis) parameters to adjust. In addition we want to run 2
simulations and 10 iterations to test if SWAT_CUP works:

18
The parameters we choose are the curve number value for the whole catchment. We can do
this for Cotter as we only have one landuse (FRST). We will go through how this would be
different for other catchment. Note that this is a relative parameter. The next parameter is
the SURLAG parameter which determines the delay for the local HRU runoff (generated by
CN2) to reach the local stream. The ALPHA_BF parameter is basically the inverse of the
residence time of the groundwater, so smaller values mean greater residence time. The
parameter REVAPMN determines the minimum level of the groundwater for “REVAP” to
occur, or water to flow back to the soil from the groundwater. You can look up the rest of the
parameters on the slides that I have provided before.
File.cio
You need to have a look at File.cio. This is the main control file for SWAT and defines the
period of the simulation and what output is being produced.
Check File.cio to make sure that you have set up a daily simulation, for 8 years (2006 - 2011)
and that NYSKIP is set to 2. This also means that the ending day of the simulation is 365. Check
also whether you are set to model daily data and not monthly data (IPRINT = 1).

19
Defining the observed data in PSO

Expanding the Observation item indicates three items that are crossed out. Basically these
are observations a three different levels: Reach (Rch), Subbasin (Sub) and HRU that you can
use in your calibration. You can activate any of them by clicking on the buttons higher up on
the left side. As a first step we only want to activate the Rch component, as we only calibrate
on Flow.

Observed_rch.txt
You can now open the Observed_rch.txt, which defines the data that will be used to calibrate
the model. The data that exists in the file are example data. There are two things to work out,
which reach number are we using for the calibration and how many days are we using for the
20
calibration. Looking back at File.cio and the model set-up, we know we only run the model for
8 years, of which two years are “warm-up”. A warm-up period is important for all larger
hydrological models as this stabilises the initial conditions.

If you think back to our simple model, we made some guesses about the initial storage in the
soil bucket and the initial storage in the groundwater. Up to a certain point in time, these
choices affect the model outcomes. In the case of our simple model, this was only a few time
steps, but in the case of a complex model this could be much longer. Therefore choosing two
years as warm-up period puts you on the safe side.

In Observed_rch.txt we will fill in that we have:


- 1 observed variable (the flow at Paso Pache in Santa Lucia)
- FLOW_OUT_1 will be the name of the variable but 28 is the subbasin where the outlet
is, you can check this in ARCSWAT or QSWAT, but also in the fig.fig file in the txt files.
- 1386 is the number of data points

You then need to replace the rest of the file with the data which we have generated with the
R script at the start. Clip the data from the file and replace all the info in the file. This is safer
than actually replacing the file in the PSO directory
Click Save, or Save all to save your changes

Extraction component

Var_file_rch.txt
Now expand the “Extraction” component and open the Var_file_rch.txt. Basically this now list
4 variables from the example. You need to replace this with the one variable that we want to
use: FLOW_OUT_1.txt

PSO_extract_rch.def
The next file to adjust is PSO_extract_rch.def. Fill in as below: 1 variable, column 7 (see
comments in green), 31 reaches in the project, 1 to use and this is number 1.
We are running 2008 – 2011 and on a daily time step.

21
Defining the Objective function: Observed.txt
Our last step is to define the objective function component. For this expand this section and
open the Observed.txt file. First we will clip and paste the data from the file which we
generated earlier with the R script in here.
Then we will adjust the top of the file:

We have:
- 1 observed variable
- We will use the KGE as our objective function (9). The other choices are highlighted in
more detail on page 44 in the SWAT-CUP manual, but basically 1 is a multiplicative
form of squared errors, while 2 is similar to a regular sum squared of errors, but allows
different flow components to be assessed separately. The third option is the classic

22
coefficient of determination (r2), while 4 is similar but based on the χ2 distribution.
Option 5 is the standard NSE. Option 6 uses the bias to force the relationship
calculated based on r2 closer to a 1:1 line, while option 7 uses the flood frequency
curves. Option 9 is the KGE, which is a bias corrected version of the NSE. We will use
this one.
- Set the next entry to 1 to make sure we capture sufficient model simulations.
- We will be using FLOW_OUT_1 as our observed values
- Don’t worry about the 6 entries, which give further options to calculate objective
functions and uncertainty.
- Finally we will use 1386 observations (or whatever else you generated in the R output)
- Below the top section you need to paste the observations from the Observed.txt that
we generated with the R script earlier.
Save and move to the next file.
Var_file_name.txt
This is essentially the same as you did before. You just need 1 line with FLOW_OUT_1.txt
Again click Save All

Running SWAT-CUP Calibration

We are now able to run SWAT-CUP calibration, but we are only doing a test run with 10
simulations. The calibration is run through 2 “batch” files PSO_run.bat which runs the actual
calibration, and PSO_post.bat, which does the file clean-up and makes all the output for you
to see and analyse. A more detailed description of the program execution is on page 52 of the
SWAT-CUP manual.
In our case we just press Execute all and this brings up a DOS box that runs PSO_run.bat. Press
Y and OK. This will run for a little while (remember we only asked for 5 simulations), close the
window when asked.

23
This confirms that we can run PSO correctly and we can move on to the real calibration and
sensitivity analysis
Once everything runs, change par_inf.txt to 20 simulations and 30 iterations
Now hit Save All and Calibrate and Execute All. Now go and get a deserved cup of Mate or
coffee (on my computer this took 41 minutes). Make sure you save your iteration

Inspecting the Calibration outputs

The next thing to do is to inspect the Calibration outputs. Start with looking at the
Summary_Stat.txt file

Do you consider this to be a good calibration? What would you base this on? Remember the
difference between NSE, r2 and KGE, see week 5. What objective function did you use again?
VOL_FR indicates the fraction of the overall water balance that is predicted, you want this to
be 1. The p-factor relates to the fraction of observed data that is inside the 95% confidence
intervals of the predictive uncertainty, while the r-factor is the width of the 95% prediction
uncertainty. You want p-factor to be close to 1, and the r-factor to be close to 0.

You can then inspect is the 95ppu plot, which gives you a comparison of the observed and
predicted and the 95% prediction uncertainty.
What is your final assessment of the initial calibration?

24
This is a screen shot of the initial evaluation chain. This indicates calibration is still not
stabilized as the objective function is still changing (for only a few iterations)

Evaluation (Validation) of the SWAT model results using PSO in SWAT-CUP

This is fairly straight forward, you might almost say “simple”.


You need to generate the new observation files using the R scripts that we provided.
Going back to the top of the tree, we want to edit: “par_inf.txt”, “File.cio”, “observed_rch.txt”
and “observed.txt”
First use the R script to generate new input files for SWAT, but now for a different time period,
maybe 2008 – 2010.
par_inf.txt
For “par_inf.txt” go back to the file and clip and paste the parameter ranges from your “best
parameters” in the calibration into the text view
Set the number of particles and the number of iterations both to 1.

25
Save all
observed_rch.txt
In observed_rch.txt we will fill in that we have:
- 1 observed variable (the flow at Paso Pache)
- FLOW_OUT_1 will be the name of the variable, you can check this in ARCSWAT
- Change the data

You then need to replace the rest of the file with the data from the file you generated with
the R script

Click Save, or Save all to save your changes


Adjusting Observed.txt
Next step is to adjust the Observed.txt file. There are a few things to change, which are
obvious after the earlier changes. The example below gives some guidance.
Again we have:
- We will be using FLOW_OUT_1 as our observed values
- Below the top lines you need to replace the file again with the file you generated with
the R script.
Adjusting File.cio
An important action is to adjust file.cio. As we said before, this is the main file that runs SWAT.
Here we also have to change the years to simulate. Change the NBYR to whatever years you
want to simulate, NYSKIP (towards the end) to 1. Change the beginning year of the simulation
to your beginning year (using only 1 year “warm-up”)

26
Then, you can just rerun the “calibration” using the “calibrate all” button and analyse the
results as the validation.

27

You might also like