Skip to content

Mike-Fuchs/SWATandR

 
 

Repository files navigation

SWATandR

lifecycle DOI

The SWATandR package provides tools to link existing SWAT2012 and SWAT+ models with your modeling workflows in R. SWATandR enables you to execute SWAT simulations and to control all relevant parameters of a SWAT simulation, such as changes in model parameters, the simulation periods and time steps, or the simulated variables that should be returned to R. The central goal of SWATandR is to return simulation results in a tidy format to facilitate an easy implementation of SWAT simulations, together with other R packages into clean and efficient R programming workflows. To efficiently handle large SWAT projects with large numbers of model evaluations and/or large simulation outputs, SWATandR provides parallel computation and incremental saving and selective loading of simulation results into and from SQLite data bases.

Installation

SWATandR is still under development and will be constantly updated (particularly to keep up with the newest revisions of SWAT+). You can install the current version of SWATandR from the default branch of the package's GitHub repository:

# If you do not have the package devtools installed
install.packages("devtools")

devtools::install_github("Mike-Fuchs/SWATandR")

The most recent developments of SWATandR are available from the development branch of the package's GitHub repository. See the package's Changelog for updates available in the development version. You can install the development version of SWATandR available from the dev branch as follows:

devtools::install_github("Mike-Fuchs/SWATandR", ref = "dev")

Functionality and workflow

The functionality of SWATandR is reduced to a few essential functions that maintain the link between the SWAT project on the local hard drive and the R environment. With load_demo() you can retrieve demo data sets of SWAT projects, calibration data, and shape files of the demo catchment. To keep SWATandR lightweight demo date sets are hosted in the separate package SWATdata. With run_swat2012() and run_swat2012() you can run a SWAT model located in a local project folder and return simulation outputs to R that were defined with define_output(). Simulation results can be saved incrementally to an SQLite data base when a save_file is defined in run_swat*(). With load_swat_run() all or selected parts of the simulation results stored in the data base can be loaded back to R. scan_swat_run() scans the content of saved simulations and returns meta data on the saved content.

plot of chunk workflowfig

Getting started with SWATandR

You can explore the basic functionality of SWATandR in the Get started section. There you can learn the following basics:

  • Loading demo data >>

    • SWAT projects >>
    • Observation data >>
    • Spatial catchment data >>
  • Performing first SWAT model runs from R >>

    • Output definition >>
    • Exploring the first simulation results >>
  • Defining parameter modifications for a SWAT run >>

    • Simulation with a single parameter set >>
    • Simulations with many parameter sets >>
    • Exploring the outputs when the parameter were modified >>
  • Saving and loading SWAT simulations >>

  • Further input arguments of SWATandR >>

The Articles section is a collection of tutorials for typical topics on SWAT modeling. Here you can learn how to use SWATandR in combination with other R packages to perform tasks such as:

  • Parameter sensitivity analysis >>
  • Model parameter optimization >>
  • Parameter sampling and model calibration >>
  • Visualization >>

The Articles section will be updated in the future with further topics that can be relevant for any modeling workflow with SWATandR.

About

Running SWAT projects within R

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Languages

  • R 81.7%
  • TeX 18.3%