From 026da5f014869199ae5233a300eb24eba14cc17d Mon Sep 17 00:00:00 2001
From: Ben Anderson <dataknut@icloud.com>
Date: Mon, 15 Mar 2021 15:12:16 +0000
Subject: [PATCH] amendments to ensure clarity

---
 impetusModel/baselineModel_v1_3.Rmd | 21 ++++++++++++---------
 impetusModel/baselineModel_v2_0.Rmd | 16 ++++++++++++----
 2 files changed, 24 insertions(+), 13 deletions(-)

diff --git a/impetusModel/baselineModel_v1_3.Rmd b/impetusModel/baselineModel_v1_3.Rmd
index d75a5d3..4f75304 100644
--- a/impetusModel/baselineModel_v1_3.Rmd
+++ b/impetusModel/baselineModel_v1_3.Rmd
@@ -1,11 +1,13 @@
 ## Introduction
 
-This version of the baseline microsimulation model uses a household dataset (n = 1800) with household size (occupancy) set to match the UK 2011 Census distributions together with regression coefficients from [@parkerThesis2014] to construct a synthetic household level micro-component water consumption dataset.
-
 ```{r Set model v1 version}
 modelVersion <- "v1_3"
 ```
 
+> Model: `r modelVersion`
+
+This version of the baseline microsimulation model uses a household dataset (n = 1800) with household size (occupancy) set to match the UK 2011 Census distributions together with regression coefficients from [@parkerThesis2014] to construct a synthetic household level micro-component water consumption dataset.
+
 
 ```{r Set model 1 paths}
 
@@ -13,7 +15,7 @@ modelVersion <- "v1_3"
 if(startsWith(userName, "ben")) # => BA laptop
   m1iPath <- paste0(iPath, "model_v1/")
 if(startsWith(userName, "ben")) # => BA laptop
-  m1oPath <- paste0(oPath, "model_v1/")
+  m1oPath <- paste0(dPath, "model_outputs/model_v1/")
 
 # set paths for DM laptop ----
 if(startsWith(userName, "despina")) # => DM laptop
@@ -25,7 +27,7 @@ print(paste0("User: ",userName))
 print(paste0("Platform: ",sysName))
 print(paste0("Model version: ",modelVersion))
 print(paste0("Input data path: ",m1iPath))
-print(paste0("Output data path: ",oPath))
+print(paste0("Output data path: ",m1oPath))
 
 ```
 
@@ -456,7 +458,7 @@ estPlot
 # Grey scale version if required
 estPlot <- estPlot + theme_bw()
 
-ggsave("Fig2_CompareModelv1_3withEST2013.pdf", dpi = 400)
+ggsave(paste0("plots_v1/Fig2_CompareModelv1_3withEST2013.pdf"), dpi = 400)
 
 ```
 
@@ -480,7 +482,7 @@ summaryDT <- hhDataFinalDaily_v1_3DT[, .(meanBasin = mean(Basin.baseline),
                                     meanWC = mean(WC.baseline),
                                     meanWashingMachine = mean(WashingMachine.baseline)
 ), by = .(occupancy, metered)]
-oFile <- paste0(oPath,"summary_output-hh-baseline-mcm-consumption_",format(Sys.time(), "%Y-%m-%d"), "_", modelVersion, ".csv")
+oFile <- paste0(m1oPath,"summary_output-hh-baseline-mcm-consumption_",format(Sys.time(), "%Y-%m-%d"), "_", modelVersion, ".csv")
 
 write.csv(summaryDT, oFile)
 
@@ -496,9 +498,10 @@ write.csv(keepDT, oFile)
 
 # compress it
 # now gzip new one
-print(paste0("gzipping file to: ", oFile, ".gz"))
-cmd <- paste0("gzip -f ", oFile) # forces over-write
-try(system(cmd)) # in case it fails (it will on windows - you will be left with a .csv file)
+# print(paste0("gzipping file to: ", oFile, ".gz"))
+# cmd <- paste0("gzip -f ", oFile) # forces over-write
+# try(system(cmd)) # in case it fails (it will on windows - you will be left with a .csv file)
+# path issue - fails
 ```
 
 Data written to:
diff --git a/impetusModel/baselineModel_v2_0.Rmd b/impetusModel/baselineModel_v2_0.Rmd
index ff12d8e..0f10760 100644
--- a/impetusModel/baselineModel_v2_0.Rmd
+++ b/impetusModel/baselineModel_v2_0.Rmd
@@ -5,14 +5,13 @@ modelVersion <- "v2_0"
 library(dplyr) # after model v1 has run (interferes with data.table)
 ```
 
-
 ```{r Set model 2 paths}
 
 # set model v2 paths for BA laptop ----
 if(startsWith(userName, "ben")) # => BA laptop
   m2iPath <- paste0(iPath, "model_v2/")
 if(startsWith(userName, "ben")) # => BA laptop
-  m2oPath <- paste0(oPath, "model_v2/")
+  m2oPath <- paste0(dPath, "model_outputs/model_v2/")
 
 # set paths for DM laptop ----
 if(startsWith(userName, "despina")) # => DM laptop
@@ -24,12 +23,15 @@ print(paste0("User: ",userName))
 print(paste0("Platform: ",sysName))
 print(paste0("Model version: ",modelVersion))
 print(paste0("Input data path: ",m2iPath))
-print(paste0("Output data path: ",oPath))
+print(paste0("Output data path: ",m2oPath))
 
 ```
 
 ## Introduction
-This code generates monthly household water demand for 1800 households, using information derived from the SPRG Survey such as frequency of use for different end uses. The code also uses information that is derived from water company and other reports such as 'At home with water' report by the Energy Saving Trust. As we do not have access to details of litres per usage for metered vs non-metered  households, this model produces estimates which do not differ substabtially between metered and non-metered households.
+
+> Model: `r modelVersion`
+
+This code generates monthly household water demand for 1800 households, using information derived from the SPRG Survey such as frequency of use for different end uses. The code also uses information that is derived from water company and other reports such as 'At home with water' report by the Energy Saving Trust. As we do not have access to details of litres per usage for metered vs non-metered  households, this model produces estimates which do not differ substantially between metered and non-metered households.
 
 Objectives:
 
@@ -788,6 +790,8 @@ plotDT <- rbind(estDT, mtDT)
 plotDT <- plotDT[, Usage := as.factor(Usage)]
 plotDT <- plotDT[, UsageRo := relevel(Usage, "Total")] # put usage at the end
 
+plotDT[, source := ifelse(source %like% "IMPETUS", "Model", source)]
+
 myPlot <- ggplot(plotDT, aes(x=UsageRo, fill = source)) +
   geom_col(aes(y = vol), position = "dodge") +
   labs(y = "Mean l/day",
@@ -796,6 +800,8 @@ myPlot <- ggplot(plotDT, aes(x=UsageRo, fill = source)) +
 
 myPlot
 
+ggsave(paste0("plots_v2/compareWithESTlitres.pdf") , dpi = 400)
+
 myPlot <- ggplot(plotDT[Usage != "Total"], aes(x=UsageRo, fill = source)) +
   geom_col(aes(y = pcTot), position = "dodge") +
   labs(y = "% total",
@@ -804,6 +810,8 @@ myPlot <- ggplot(plotDT[Usage != "Total"], aes(x=UsageRo, fill = source)) +
 
 myPlot
 
+ggsave(paste0("plots_v2/compareWithESTpercent.pdf") , dpi = 400)
+
 ```
 
 ## Save data
-- 
GitLab