From b94d18d710caac2157fd807a78a9dd82071891b3 Mon Sep 17 00:00:00 2001
From: biopsichas <svajunas.plunge@gmail.com>
Date: Tue, 7 Mar 2023 11:51:59 +0100
Subject: [PATCH] remove caps from headings

---
 R/helper.R          |  5 +++++
 R/run_swat_verify.R | 21 +++++++++++----------
 inst/CITATION       | 13 +++++++++++++
 3 files changed, 29 insertions(+), 10 deletions(-)
 create mode 100644 inst/CITATION

diff --git a/R/helper.R b/R/helper.R
index cec5ba4..bdfb9f1 100644
--- a/R/helper.R
+++ b/R/helper.R
@@ -113,3 +113,8 @@ remove_tail <- function(f, pattern){
   }
   return(f)
 }
+
+lwr <- function(df){
+  names(df) <- tolower(names(df))
+  return(df)
+}
diff --git a/R/run_swat_verify.R b/R/run_swat_verify.R
index 120042a..ec265e2 100644
--- a/R/run_swat_verify.R
+++ b/R/run_swat_verify.R
@@ -70,26 +70,27 @@ run_swat_verification <- function(project_path, outputs = c('wb', 'mgt', 'plt'),
   } else if(nchar(msg$stderr) == 0) {
     model_output <- list()
     if ('plt' %in% outputs) {
-      model_output$hru_pw_day <- read_tbl('hru_pw_day.txt', run_path, 3)
+      model_output$hru_pw_day <- read_tbl('hru_pw_day.txt', run_path, 3) %>% lwr
     }
     if ('wb' %in% outputs) {
-      model_output$basin_wb_day <- read_tbl('basin_wb_day.txt', run_path, 3)
-      model_output$basin_pw_day <- read_tbl('basin_pw_day.txt', run_path, 3)
-      model_output$hru_wb_aa <- read_tbl('hru_wb_aa.txt', run_path, 3)
+      model_output$basin_wb_day <- read_tbl('basin_wb_day.txt', run_path, 3) %>% lwr
+      model_output$basin_pw_day <- read_tbl('basin_pw_day.txt', run_path, 3) %>% lwr
+      model_output$hru_wb_aa <- read_tbl('hru_wb_aa.txt', run_path, 3) %>% lwr
       tryCatch({
-        model_output$recall_yr <- read_tbl('recall_yr.txt', run_path, 3)
+        model_output$recall_yr <- read_tbl('recall_yr.txt', run_path, 3) %>% lwr
       },
       error = function(e) {
         model_output$recall_yr <- NULL
       })
     }
     if ('mgt' %in% outputs) {
-      model_output$mgt_out <- read_mgt(run_path)
-      model_output$mgt_sch <- read_sch(run_path)
+      model_output$mgt_out <- read_mgt(run_path) %>% lwr
+      model_output$mgt_sch <- read_sch(run_path) %>% lwr
 
-      hru_data <- read_tbl('hru-data.hru', run_path, 2)
-      landuse_lum <- read_tbl('landuse.lum', run_path, 2)
-      model_output$lum_mgt <- left_join(hru_data, landuse_lum,
+      hru_data <- read_tbl('hru-data.hru', run_path, 2) %>% lwr
+      landuse_lum <- read_tbl('landuse.lum', run_path, 2) %>% lwr
+      model_output$lum_mgt <- left_join(hru_data,
+                                        landuse_lum,
                                         by = c("lu_mgt" = 'name')) %>%
         distinct() %>%
         select(id, topo, hydro, soil, lu_mgt, plnt_com, mgt, tile)
diff --git a/inst/CITATION b/inst/CITATION
new file mode 100644
index 0000000..452509c
--- /dev/null
+++ b/inst/CITATION
@@ -0,0 +1,13 @@
+citHeader("To cite SWATdoctR in publications use:")
+
+citEntry(
+  entry    = "Manual",
+  title    = 'SWATdoctR: SWAT+ model setup verification tool',
+  author = 'Christoph Schürz and Svajunas Plunge',
+  year     = '2023',
+  note  = 'R package',
+  url      = 'https://git.ufz.de/schuerz/swatdoctr',
+  textVersion = paste('Schürz, Christoph and Plunge, Svajunas (2023),',
+  'R package for SWAT+ model setup verification.',
+  'URL https://git.ufz.de/schuerz/swatdoctr')
+)
-- 
GitLab