2 Plotting of SWAP model results
Visualizing model results can be time-consuming. An automated procedure for generating figures can therefore be useful to obtain an overview of model outcomes and performance. SWAPtools is designed to create basic plots based on the results of a single SWAP-WOFOST simulation.
2.1 Layout and settings of plot
The layout and settings of the figure are defined in separate control file(s) listed in DIRFIG (see Tip 1.5). Required inputs include the filename of the main SWAP input file (FILSWP), the filename of the figure to be created (FILPNG), and the type of graph to generate (GRAPH). An example of a control file is shown below, which creates a figure with four panels: crop development of storage organs, followed by salinity concentrations at depths of -5, -25 and -55 cm below soil surface. All panels of the figure will outline automatically by SWAPtools.
Path to directories may contain keys as defined in the Excel file (or SQLite database). In addition the keywords DIRRUN, DIROBS and DIROUT are parsed from the main control file control.inp. The figure dimensions are defined using the keywords WIDTH (default: 10.0) and HEIGHT (default: 5.0).
Optionally, the figure can be futher adjusted. The time period to be visualized can be defined using TSTART and TEND, while the x- and y-axis ranges can be controlled with XMIN, XMAX, YMIN and YMAX. These settings apply to all panels in the figure. If the settings should apply to a single panel, a keyword consisting of the graph name followed by the specific setting can be added to the controle file (such as CROPDEV_WSO_YMIN). The language of the labels can be set to English (EN; default) or Dutch (NL) using LANGUAGE.
2.2 Selecting graphs
A complete list of graphs supported by SWAPtools is included in the package’s installation directory. If the installation procedure described in Appendix A is followed, this list can be found at C:\ProgramData\R\R-4.5.2\libraries\SWAPtools\io\swap_output.csv (see R_LIBS in Section A.3). In general, all SWAP model results can be selected. For vector variable, time or depth information can be specified within square brackets. If a date or datetime is specified, SWAPtools will automatically generate a profile at the corresponding timestamp. If a depth is sepcified, SWAPtools will generate a time series. If no square brackets are used a time-depth plot is generated.
Some graphs supported by SWAPtools depend on multiple output variables (such as WATBAL, SUBREG_MIN[…] , or TRED), of on transformations of output variables (such as H_LOG[…], which is a logarithmic transformation of H). These graphs are (in most cases) defined using R expressions, which are also included in the file C:\ProgramData\R\R-4.5.2\libraries\SWAPtools\io\swap_output.csv. Adding or modifying the definition of graphs is possible, but should be done with care.
2.3 Adding observations and model performance
If available, observations can be included in the graph. In this case, a path to the directory containing the observations must be specified using DIR_OBS (see Tip 2.1). SWAPtools will then search this directory for *.csv files named after the SWAP variable (e.g. GWL.csv or WC.csv).
The *.csv file(s) should contain the columns DATE (or DATETIME) and VALUE, see the example below with observations of biomass in storage organs. The DATE column represents the end of the day. An additional DEPTH column should be included when plotting vector variables.
If present, observations are shown as red dots in the graph. Model performance can optionally be displayed in the lower-left corner of the graph if a performance index is provided. This index can be defined by the user with STATS. Multiple performance metrics are allowed and should be separated by a comma. SWAptools supports the following indices: rpearson, syserr, rnderr, sse, mse, rmse, mae, ioa and nse.
2.4 Extra options
For graphs related to crop growth, the model output can be filtered using the crop filename via CROPFIL. Multiple crops can be specified by separating them with a comma; by default, all crops are included.
For graphs showing the actual transpiration and the reduction of transpiration (graph TRED), stressors can be selected using STRESSOR (options: ‘drought’, ‘oxygen’, ‘salinity’, and ‘frost’). By default, all active stressors are included.
Finally, AGGREGATION can be used in the control file to aggregate model output over time, with options ‘year’, ‘month’, ‘decade’ or ‘day’. By default, no aggregation is applied.