Skip to content

Commit

Permalink
Merge pull request #64 from tamnva/joss_manuscript
Browse files Browse the repository at this point in the history
fix: error in readAllOutVar.R causes program to stop
  • Loading branch information
tamnva authored Feb 9, 2024
2 parents 8cdcd1b + ca7ea8a commit c7f8cd2
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 26 deletions.
2 changes: 1 addition & 1 deletion R/readAllOutVar.R
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ readAllOutVar <- function(workingFolder, numTimesteps){
outVarFiles <- list.files(coreFolders[1], full.names = TRUE)

output <- list()
for (ifolder in 1:length(coreFolder)){
for (ifolder in 1:length(coreFolders)){
# Loop over each outVarfiles
for (var in 1:length(outVarFiles)){
# Read content of each file and store
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## RSWAT <a href="https://github.com/tamnva/R-SWAT/tree/master/inst/R-SWAT/figures/RSWAT_logo.svg"><img src="inst/R-SWAT/figures/RSWAT_logo.svg" align="right" height="50" /></a>

[![DOI](https://zenodo.org/badge/395115735.svg)](https://zenodo.org/badge/latestdoi/395115735) [![License: GPL v3](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://github.com/tamnva/R-SWAT/blob/master/LICENSE) [![Release](https://img.shields.io/github/release/tamnva/R-SWAT.svg?style=flat-square)](https://github.com/tamnva/R-SWAT/releases) [![R-CMD-check](https://github.com/tamnva/R-SWAT/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/tamnva/R-SWAT/actions/workflows/R-CMD-check.yaml)
[![DOI](https://zenodo.org/badge/395115735.svg)](https://zenodo.org/badge/latestdoi/395115735) [![License: GPL v3](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://github.com/tamnva/R-SWAT/blob/master/LICENSE) [![Release](https://img.shields.io/github/release/tamnva/R-SWAT.svg?style=flat-square)](https://github.com/tamnva/R-SWAT/releases) [![R-CMD-check](https://github.com/tamnva/R-SWAT/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/tamnva/R-SWAT/actions/workflows/R-CMD-check.yaml) [![status](https://joss.theoj.org/papers/89a04bc6f9a2a2b08cbac33fcd91c0c6/status.svg)](https://joss.theoj.org/papers/89a04bc6f9a2a2b08cbac33fcd91c0c6)

- This is an R package with a graphical user interface (GUI) for parallel parameter calibration, sensitivity, and uncertainty analyses with the Soil and Water Assessment Tool models (e.g., [SWAT](https://swat.tamu.edu/), [SWAT+](https://swat.tamu.edu/software/plus/), [SWAT-Carbon](https://sites.google.com/view/swat-carbon), and its other modified versions).
- RSWAT can also be used without the GUI, please see the RSWAT vignettes (see Quick Start section).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,12 @@ knitr::opts_chunk$set(
# FileType = c("channel_sd_day.txt"),
# FileName = c("channel_sd_day.txt"),
# Column = c("48"),
# Reach = c("1")
# Reach = c("1") # E.g., for 100 reaches use: Reach = paste(as.character(c(1:100)), collapse = ",")
# )
# # NOTE: if you want to extract for many reaches (e.g., for the first 100 reaches), create variable for th
#
# reach <- paste(as.character(c(1:100)), collapse = ",")
#
#
# # 10. Date range for extraction (TODO: change this)
# dateRangeCali <- as.Date(c("2003-01-01", "2012-12-31"), format = "%Y-%m-%d")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,12 @@ outputExtraction <- data.frame(
FileType = c("channel_sd_day.txt"),
FileName = c("channel_sd_day.txt"),
Column = c("48"),
Reach = c("1")
Reach = c("1") # E.g., for 100 reaches use: Reach = paste(as.character(c(1:100)), collapse = ",")
)
# NOTE: if you want to extract for many reaches (e.g., for the first 100 reaches), create variable for th
reach <- paste(as.character(c(1:100)), collapse = ",")
# 10. Date range for extraction (TODO: change this)
dateRangeCali <- as.Date(c("2003-01-01", "2012-12-31"), format = "%Y-%m-%d")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -408,31 +408,35 @@ <h3>3. Input configuration</h3>
<span id="cb1-44"><a href="#cb1-44" tabindex="-1"></a> <span class="at">FileType =</span> <span class="fu">c</span>(<span class="st">&quot;channel_sd_day.txt&quot;</span>),</span>
<span id="cb1-45"><a href="#cb1-45" tabindex="-1"></a> <span class="at">FileName =</span> <span class="fu">c</span>(<span class="st">&quot;channel_sd_day.txt&quot;</span>),</span>
<span id="cb1-46"><a href="#cb1-46" tabindex="-1"></a> <span class="at">Column =</span> <span class="fu">c</span>(<span class="st">&quot;48&quot;</span>),</span>
<span id="cb1-47"><a href="#cb1-47" tabindex="-1"></a> <span class="at">Reach =</span> <span class="fu">c</span>(<span class="st">&quot;1&quot;</span>)</span>
<span id="cb1-47"><a href="#cb1-47" tabindex="-1"></a> <span class="at">Reach =</span> <span class="fu">c</span>(<span class="st">&quot;1&quot;</span>) <span class="co"># E.g., for 100 reaches use: Reach = paste(as.character(c(1:100)), collapse = &quot;,&quot;)</span></span>
<span id="cb1-48"><a href="#cb1-48" tabindex="-1"></a> )</span>
<span id="cb1-49"><a href="#cb1-49" tabindex="-1"></a></span>
<span id="cb1-50"><a href="#cb1-50" tabindex="-1"></a><span class="co"># 10. Date range for extraction (</span><span class="al">TODO</span><span class="co">: change this)</span></span>
<span id="cb1-51"><a href="#cb1-51" tabindex="-1"></a>dateRangeCali <span class="ot">&lt;-</span> <span class="fu">as.Date</span>(<span class="fu">c</span>(<span class="st">&quot;2003-01-01&quot;</span>, <span class="st">&quot;2012-12-31&quot;</span>), <span class="at">format =</span> <span class="st">&quot;%Y-%m-%d&quot;</span>)</span>
<span id="cb1-49"><a href="#cb1-49" tabindex="-1"></a><span class="co"># </span><span class="al">NOTE</span><span class="co">: if you want to extract for many reaches (e.g., for the first 100 reaches), create variable for th</span></span>
<span id="cb1-50"><a href="#cb1-50" tabindex="-1"></a></span>
<span id="cb1-51"><a href="#cb1-51" tabindex="-1"></a>reach <span class="ot">&lt;-</span> <span class="fu">paste</span>(<span class="fu">as.character</span>(<span class="fu">c</span>(<span class="dv">1</span><span class="sc">:</span><span class="dv">100</span>)), <span class="at">collapse =</span> <span class="st">&quot;,&quot;</span>)</span>
<span id="cb1-52"><a href="#cb1-52" tabindex="-1"></a></span>
<span id="cb1-53"><a href="#cb1-53" tabindex="-1"></a><span class="co"># 11. Number of parallel runs (</span><span class="al">TODO</span><span class="co">: change this)</span></span>
<span id="cb1-54"><a href="#cb1-54" tabindex="-1"></a>ncores <span class="ot">&lt;-</span> <span class="dv">2</span></span>
<span id="cb1-55"><a href="#cb1-55" tabindex="-1"></a></span>
<span id="cb1-56"><a href="#cb1-56" tabindex="-1"></a><span class="co"># 12. Generate parameter samples using Latin Hypercube Sampling (</span><span class="al">TODO</span><span class="co">: change this)</span></span>
<span id="cb1-57"><a href="#cb1-57" tabindex="-1"></a>parameterValue <span class="ot">&lt;-</span> <span class="fu">as.matrix</span>(<span class="fu">read.table</span>(<span class="at">file =</span> <span class="st">&quot;C:/data/user_parameter_values.txt&quot;</span>,</span>
<span id="cb1-58"><a href="#cb1-58" tabindex="-1"></a> <span class="at">header =</span> <span class="cn">TRUE</span>, <span class="at">sep =</span><span class="st">&quot;&quot;</span>))</span>
<span id="cb1-53"><a href="#cb1-53" tabindex="-1"></a></span>
<span id="cb1-54"><a href="#cb1-54" tabindex="-1"></a><span class="co"># 10. Date range for extraction (</span><span class="al">TODO</span><span class="co">: change this)</span></span>
<span id="cb1-55"><a href="#cb1-55" tabindex="-1"></a>dateRangeCali <span class="ot">&lt;-</span> <span class="fu">as.Date</span>(<span class="fu">c</span>(<span class="st">&quot;2003-01-01&quot;</span>, <span class="st">&quot;2012-12-31&quot;</span>), <span class="at">format =</span> <span class="st">&quot;%Y-%m-%d&quot;</span>)</span>
<span id="cb1-56"><a href="#cb1-56" tabindex="-1"></a></span>
<span id="cb1-57"><a href="#cb1-57" tabindex="-1"></a><span class="co"># 11. Number of parallel runs (</span><span class="al">TODO</span><span class="co">: change this)</span></span>
<span id="cb1-58"><a href="#cb1-58" tabindex="-1"></a>ncores <span class="ot">&lt;-</span> <span class="dv">2</span></span>
<span id="cb1-59"><a href="#cb1-59" tabindex="-1"></a></span>
<span id="cb1-60"><a href="#cb1-60" tabindex="-1"></a><span class="co"># Here is the content of my user_parameter_values.txt&quot;</span></span>
<span id="cb1-61"><a href="#cb1-61" tabindex="-1"></a><span class="co">#cn2.hru canmax.hru</span></span>
<span id="cb1-62"><a href="#cb1-62" tabindex="-1"></a><span class="co">#0.10 1.5</span></span>
<span id="cb1-63"><a href="#cb1-63" tabindex="-1"></a><span class="co">#-0.20 3.0</span></span>
<span id="cb1-64"><a href="#cb1-64" tabindex="-1"></a><span class="co">#-0.10 0.2</span></span>
<span id="cb1-65"><a href="#cb1-65" tabindex="-1"></a><span class="co">#0.22 1.0</span></span>
<span id="cb1-66"><a href="#cb1-66" tabindex="-1"></a><span class="co">#</span></span>
<span id="cb1-67"><a href="#cb1-67" tabindex="-1"></a></span>
<span id="cb1-68"><a href="#cb1-68" tabindex="-1"></a><span class="co"># Remove the column names and number these parametersets from 1 to n. DONOT change this</span></span>
<span id="cb1-69"><a href="#cb1-69" tabindex="-1"></a>parameterValue <span class="ot">&lt;-</span> <span class="fu">cbind</span>(<span class="fu">c</span>(<span class="dv">1</span><span class="sc">:</span><span class="fu">nrow</span>(parameterValue)),parameterValue)</span>
<span id="cb1-70"><a href="#cb1-70" tabindex="-1"></a><span class="fu">colnames</span>(parameterValue) <span class="ot">&lt;-</span> <span class="cn">NULL</span></span>
<span id="cb1-71"><a href="#cb1-71" tabindex="-1"></a><span class="fu">rownames</span>(parameterValue) <span class="ot">&lt;-</span> <span class="cn">NULL</span></span></code></pre></div>
<span id="cb1-60"><a href="#cb1-60" tabindex="-1"></a><span class="co"># 12. Generate parameter samples using Latin Hypercube Sampling (</span><span class="al">TODO</span><span class="co">: change this)</span></span>
<span id="cb1-61"><a href="#cb1-61" tabindex="-1"></a>parameterValue <span class="ot">&lt;-</span> <span class="fu">as.matrix</span>(<span class="fu">read.table</span>(<span class="at">file =</span> <span class="st">&quot;C:/data/user_parameter_values.txt&quot;</span>,</span>
<span id="cb1-62"><a href="#cb1-62" tabindex="-1"></a> <span class="at">header =</span> <span class="cn">TRUE</span>, <span class="at">sep =</span><span class="st">&quot;&quot;</span>))</span>
<span id="cb1-63"><a href="#cb1-63" tabindex="-1"></a></span>
<span id="cb1-64"><a href="#cb1-64" tabindex="-1"></a><span class="co"># Here is the content of my user_parameter_values.txt&quot;</span></span>
<span id="cb1-65"><a href="#cb1-65" tabindex="-1"></a><span class="co">#cn2.hru canmax.hru</span></span>
<span id="cb1-66"><a href="#cb1-66" tabindex="-1"></a><span class="co">#0.10 1.5</span></span>
<span id="cb1-67"><a href="#cb1-67" tabindex="-1"></a><span class="co">#-0.20 3.0</span></span>
<span id="cb1-68"><a href="#cb1-68" tabindex="-1"></a><span class="co">#-0.10 0.2</span></span>
<span id="cb1-69"><a href="#cb1-69" tabindex="-1"></a><span class="co">#0.22 1.0</span></span>
<span id="cb1-70"><a href="#cb1-70" tabindex="-1"></a><span class="co">#</span></span>
<span id="cb1-71"><a href="#cb1-71" tabindex="-1"></a></span>
<span id="cb1-72"><a href="#cb1-72" tabindex="-1"></a><span class="co"># Remove the column names and number these parametersets from 1 to n. DONOT change this</span></span>
<span id="cb1-73"><a href="#cb1-73" tabindex="-1"></a>parameterValue <span class="ot">&lt;-</span> <span class="fu">cbind</span>(<span class="fu">c</span>(<span class="dv">1</span><span class="sc">:</span><span class="fu">nrow</span>(parameterValue)),parameterValue)</span>
<span id="cb1-74"><a href="#cb1-74" tabindex="-1"></a><span class="fu">colnames</span>(parameterValue) <span class="ot">&lt;-</span> <span class="cn">NULL</span></span>
<span id="cb1-75"><a href="#cb1-75" tabindex="-1"></a><span class="fu">rownames</span>(parameterValue) <span class="ot">&lt;-</span> <span class="cn">NULL</span></span></code></pre></div>
</div>
<div id="run-swat" class="section level3">
<h3>4. Run SWAT+</h3>
Expand Down

0 comments on commit c7f8cd2

Please sign in to comment.