Skip to contents

Preprocessing tools

Functions for preparing SWAT model input data, including climate forcings, parameter files, and TxtInOut inputs.

areal_mean()
Compute areal means of raster data over polygons
pcp2swat_editor()
Generate SWAT Editor-compatible precipitation input files
tmp2swat_editor()
Generate SWAT Editor-compatible temperature input files
pcp2swat()
Update SWAT precipitation input files (`pcp*.pcp`)
tmp2swat()
Update SWAT temperature input files (`tmp*.tmp`)

Project setup and execution

Tools for configuring, initializing, and running SWAT projects, including example datasets and model executables.

download_swat_exe()
Download SWAT executable
get_swat_example()
Write example SWAT TxtInOut files to a local folder
setup_swat()
Configure a SWAT project for simulation
run_swat()
Run SWAT model with or without parameter updates
run_swat_exe()
Run SWAT executable

Parameter management

Functions for retrieving, modifying, and organizing SWAT model parameters, including support for parallel calibration workflows.

get_swat_parameters()
Retrieve SWAT model parameters
change_parameter()
Change a single SWAT model parameter
change_multiple_parameters()
Change multiple SWAT model parameters
split_swat_parameters()
Split SWAT parameters for parallel processing

Multiobjective calibration

Multiobjective calibration tools for SWAT based on the NSGA-II evolutionary algorithm.

create_calibration_project()
Create a SWAT calibration project
calibrate_swat()
Perform multiobjective calibration of a SWAT model with NSGA-II
calculate_objectives()
Compute calibration objectives for the SWAT model
best_compromise_solution()
Select a best-compromise Pareto solution by Euclidean distance

Performance evaluation

Model performance assessment using classical goodness-of-fit metrics and hydrological signatures, including Flow Duration Curve (FDC)–based diagnostics.

evaluate_swat()
Evaluate SWAT model performance
gof_metrics()
Goodness-of-fit (GOF) metrics and FDC-based signatures
fdc_signature()
Flow Duration Curve (FDC) signature
pbias_fdc_midsegment()
Percent bias in the midsegment slope of a Flow Duration Curve (FDC)
pbias_fdc_target_segment()
Percent bias in a Flow Duration Curve (FDC) segment
trmse()
Transformed root mean squared error (TRMSE)
plot_timeseries()
Plot time series of simulated and observed data
plot_mean_annual_cycle()
Plot mean annual cycle by evaluation periods
plot_fdc()
Plot Flow Duration Curve (FDC) by evaluation periods

Output readers

Functions for reading and parsing SWAT output files at different spatial levels (HRU, subbasin, and reach).

get_swat_vars()
Retrieve SWAT output variables
output_rch()
Read SWAT reach output
output_sub()
Read SWAT subbasin output
output_hru()
Read SWAT HRU output
read_pcp()
Read precipitation data from SWAT .pcp files
read_tmp()
Read temperature data from SWAT .tmp files

Output analysis

Tools for aggregating, summarizing, and analyzing SWAT simulation outputs for further interpretation and visualization.

summarize_swat_output()
Summarize SWAT output data

Data

Example datasets bundled with the package for demonstrations, testing, and reproducible vignettes.

example_basin_datasets
Datasets included with the package for demos, vignettes, and tests. Unless otherwise noted, they correspond to the **Huancane River basin (Peru)**.
gridded_climate_netcdfs
Gridded climate NetCDFs (precipitation and temperature)
subs1
Subbasins (sf)
riv1
River network (sf)
swat_txtinout_data
SWAT TxtInOut inputs
qobserved
Observed streamflow (daily)