This script is a detailed set of instructions written in R programming language for a workflow related to using the SWAT+ (Soil and Water Assessment Tool) model for climate scenarios. Workflow is following these steps:
-
Loading Libraries: This section loads various R libraries required for the workflow. These libraries include SWATfarmR, SWATprepR, and other data manipulation and visualization libraries like tidyverse and ggpubr.
-
Preparing Management Files: It involves creating necessary directories and copying setup files required for the simulation. Additionally, it updates, copies a database file to the temporary directory and write out model text files.
-
Updating landuse.lum File: This section involves backing up and updating the landuse.lum file using a custom script.
-
Run Climate Data Preparation: Parallel processing is used to prepare climate data files required for the simulation.
-
Prepare for SWATfarmR: Copies necessary files from the setup directory to the temporary result directory.
-
Run Parallelized SWATfarmR Calculation: Executes the SWATfarmR calculation for preparing model management files in parallel.
-
Adjust Output Settings: Modifies settings related to output files and print settings for the simulation.
-
Run All Climate Scenarios in Parallel and Collect Results: Executes the simulation for all scenarios in parallel and collects the output files.
-
Load Functions for Output Extraction and Prepare Results: Loads custom functions for extracting output indicators and prepares the results directory.
-
Output Analysis: Calculates various indicators related to water quantity, quality, and crop yield from the simulation results.
-
Aggregate Outputs for Plotting: Combines the calculated indicators into a dataframe for plotting.
-
Plotting Results: Divides the indicators into thematic plots and creates visualizations using the throw_box function.