-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstartupscriptMC.R
60 lines (54 loc) · 1.98 KB
/
startupscriptMC.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# Author: B.P. Ottow
# installs
install.packages("raster")
install.packages("sp")
install.packages("gdistance")
install.packages("maptools")
install.packages("RSAGA")
install.packages("rgeos")
install.packages("rgdal")
install.packages("topmodel")
install.packages("spacetime")
install.packages("doParallel")
install.packages("foreach")
install.packages("gdalUtils")
install.packages("animation")
install.packages("plotKML")
# parameters
channelLength = 500
minimumHead = 25
minimumDebiet = 0.1
minimumPotential = 10000
coord <- matrix(c(125.175278, 6.383889), nrow=1)
require(RSAGA)
work_env = rsaga.env(path="C:/Program Files (x86)/SAGA_GIS") # windows
# files
#setwd("/media/boukepieter/schijfje_ottow/thesis/workspace") # linux
i <- 1
sourceCode <- "E:/thesis/workspace/thesis" # gaia windows
sourceCode <- "D:/MCAnalyse/scripts"
setwd("E:/thesis/workspace/MCAnalyse/")
dir.create(sprintf("run%03d", i))
setwd(sprintf("run%03d", i))
ETdir <- "../input/ET"
Pdir <- "../input/P"
DEMfile <- "../input/DEM/DEM001.tif"
flist <- list.files(sourceCode, ".+[.]R$", full.names = TRUE)
dir.create(paste(getwd(), "scripts", sep="/"))
file.copy(flist, paste(getwd(), "scripts", sep="/"))
# model
source("scripts/MCmodel.R")
#HydroPowerMonthly(DEMfile, Pdir, ETdir, coord=coord, minimumPotential = minimumPotential, minimumDebiet = minimumDebiet,
# minimumHead = minimumHead, channelLength = channelLength, work_env=work_env, plotMethod="None")
for (i in 1:20){
setwd("D:/MCAnalyse")
dir.create(sprintf("run%03d", i))
setwd(sprintf("run%03d", i))
DEMfile <- sprintf("../input/DEM/DEM%03d.tif", i)
dir.create(paste(getwd(), "scripts", sep="/"))
file.copy(flist, paste(getwd(), "scripts", sep="/"))
HydroPowerMonthly(DEMfile, Pdir, ETdir, coord=coord, minimumPotential = minimumPotential, minimumDebiet = minimumDebiet,
minimumHead = minimumHead, channelLength = channelLength, work_env=work_env, plotMethod="None")
unlink("../step", recursive=TRUE)
unlink("../scripts", recursive=TRUE)
}