Skip to contents

After the calibration process, the SWAT+ model should be validated to ensure that the model is not overfitted. The validation process is similar to the calibration process, but the validation data set is used instead of the calibration data set. The following lines provide an example of how to validate the SWAT+ model. It is important to mention, that model run during the final calibration step should cover both calibration and validation periods.

1. Validation preparation

To prepare validation data set is quite simple with fix_dates function, which cuts simulation results and observations to defined validation period. Following code snippet shows how to prepare validation data set. wq_val_period was defined select_best_print. Example could bewritten as wq_val_period <- c("2010-01-01", "2014-12-31").

# Readjusting the dates of the simulated and observed data for validation period
tmp <- fix_dates(sim_wq_full, obs_wq_full, trim_start = wq_val_period[1], 
                 trim_end = wq_val_period[2])
sim_wq_val <- tmp$sim
obs_wq_val <- tmp$obs

2. Performance calculation

To calculate the performance of the SWAT+ model, you can use the same functions as in the calibration process. The following code snippet shows how to calculate the performance of the SWAT+ model for the validation period. obj_tbl_cal dataframe is obtained at the end of calibration and contains the best run ids @ref(select_best_print).

# Calculate the performance metrics for validation period
obj_tbl_val <- calculate_performance(sim_wq_val, obs_wq_val, par_name = "flo_day_52")

# Filter the performance metrics for the selected calibration runs
obj_tbl_val <- obj_tbl_val[obj_tbl_val$run_id %in% obj_tbl_cal$run_id,]

3. Performance visualization

To visualize the performance of the SWAT+ model, you can use the same functions as in the calibration process. Particularly, the plot_calval_comparison and plot_selected_sim functions could be used to visualize the performance of the SWAT+ model for validation period.

4. Write out ‘calibration.cal’ file

The final step is to write out the “calibration.cal” file, which could be supplied to the model to run already calibrated and validated model. Please don’t forget to check master file ‘file.cio’, if it has connection to ‘calibration.cal’ on line 22. The following code snippet shows how to write out the ‘calibration.cal’ file.

write_cal_file(par = par_flow, 
               write_path = 'your_path',
               i_run = 1)
``