-
Notifications
You must be signed in to change notification settings - Fork 0
/
30_model_LiDAR.R
executable file
·112 lines (105 loc) · 4.32 KB
/
30_model_LiDAR.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
# Description:
# Author: Alice Ziegler
# Date: 2018-12-06 10:26:41
# to do:
rm(list=ls())
########################################################################################
###Presettings
########################################################################################
#####
###load packages
#####
library(CAST)
library(caret)
library(doParallel)
library(foreach)
library(parallel)
if(machine == "local"){
setwd(dirname(rstudioapi::getSourceEditorContext()[[2]])) # lokal
}else if(machine == "server"){
setwd("/mnt/sd19006/data/users/aziegler/src") # 60er
}else if(machine == "cluster"){
setwd("/home/ziegler5/src") # marc2
}
# sub <- "oct19/"
# sub <- "apr19/"#paper
sub <- "feb20_allresp/"
inpath <- paste0("../data/", sub)
inpath_general <- "../data/"
outpath <- paste0("../data/", sub)
set <- c("frst", "nofrst", "allplts")
# set <- c("frst")
###settings from pre-models
set_dir <- "2018-12-13nofrst_frst_allplts/"
inpath_pre <- paste0(inpath, set_dir)
########################################################################################
###Settings
########################################################################################
# comm <- "elev"
comm <- "noelev"
# comm <- "flt_elev"
# comm <- "flt_noelev"
method <- "pls"
type <- "ffs"
# cv <- "cv_index"
cv <- "cv_20"
# cv <- "cv_50"
cv_fold_in <- 4
cv_times_in <- 20
# resp_set <- c("SR", "resid") #m <- "SR" #loop model for SR and resid
resp_set <- c("lidarSR", "lidarelevSR", "lidarRES") #m <- "SR" #loop model for SR and resid
# resp_set <- c("SR")
#####
###read files
#####
set_lst <- lapply(set, function(o){
readRDS(file = paste0(outpath, "20_master_lst_resid_", o, ".rds"))
})
names(set_lst) <- set
set_dir <- paste0(Sys.Date(), paste(set, collapse = "_"), "_", comm, "/")
if (file.exists(paste0(outpath, set_dir))==F){
dir.create(file.path(paste0(outpath, set_dir)))
}
if(grepl("flt", comm)){
preds_flt <- readRDS(file = paste0(inpath_pre, "80_preds_flt.rds"))
}
source("fun_model.R")
########################################################################################
########################################################################################
########################################################################################
###Do it (Don't change anything past this point except you know what you are doing!) ###
########################################################################################
########################################################################################
########################################################################################
if (machine == "local"){
set_lst_ldr <- lapply(seq(length(set_lst)), function(i){# i <- 1 , set_lst[[i]]
model(i = i, set_lst = set_lst, cv = cv, comm = comm, sub = sub,
inpath = inpath, inpath_general = inpath_general,
outpath = outpath, set = set, set_dir = set_dir,
method = method, type = type, cv_fold_in = cv_fold_in,
cv_times_in = cv_times_in, resp_set = resp_set)
}
)
}
if (machine == "server"){ # not tested yet
registerDoParallel(core_num)
set_lst_ldr <- lapply(seq(length(set_lst)), function(i){# i <- 1 , set_lst[[i]]
model(i = i, set_lst = set_lst, cv = cv, comm = comm, sub = sub,
inpath = inpath, inpath_general = inpath_general,
outpath = outpath, set = set, set_dir = set_dir,
method = method, type = type, cv_fold_in = cv_fold_in,
cv_times_in = cv_times_in, resp_set = resp_set)}
)
}
if (machine == "cluster"){
cmd_input <- base::commandArgs(trailingOnly =TRUE)
i <- as.numeric(cmd_input[1])
cl <- makeCluster(core_num, type = "FORK", outfile = paste0("/home/ziegler5/data/", sub, set_dir, "out.txt"))
registerDoParallel(cl)
model(i = i, set_lst = set_lst, cv = cv, comm = comm, sub = sub,
inpath = inpath, inpath_general = inpath_general,
outpath = outpath, set = set, set_dir = set_dir,
method = method, type = type, cv_fold_in = cv_fold_in,
cv_times_in = cv_times_in, resp_set = resp_set)
}
stopCluster(cl)