some bugfixing
This commit is contained in:
parent
a881e95c88
commit
3a973d0172
@ -16,10 +16,10 @@ calibrateMuso <- function(measuredData, parameters = NULL, startDate = NULL,
|
|||||||
maxLikelihoodEpc=TRUE,
|
maxLikelihoodEpc=TRUE,
|
||||||
pbUpdate = setTxtProgressBar, method="GLUE",lg = FALSE, w=NULL, ...){
|
pbUpdate = setTxtProgressBar, method="GLUE",lg = FALSE, w=NULL, ...){
|
||||||
|
|
||||||
|
future::plan(future::multisession)
|
||||||
file.remove(list.files(path = settings$inputLoc, pattern="progress.txt", recursive = TRUE))
|
file.remove(list.files(path = settings$inputLoc, pattern="progress.txt", recursive = TRUE, full.names=TRUE))
|
||||||
file.remove(list.files(path = settings$inputLoc, pattern="preservedCalib.csv", recursive = TRUE))
|
file.remove(list.files(path = settings$inputLoc, pattern="preservedCalib.csv", recursive = TRUE, full.names=TRUE))
|
||||||
unlink("thread",recursive=TRUE)
|
unlink(file.path(settings$inputLoc,"thread"),recursive=TRUE)
|
||||||
|
|
||||||
# ____ _ _ _ _
|
# ____ _ _ _ _
|
||||||
# / ___|_ __ ___ __ _| |_ ___ | |_| |__ _ __ ___ __ _ __| |___
|
# / ___|_ __ ___ __ _| |_ ___ | |_| |__ _ __ ___ __ _ __| |___
|
||||||
@ -94,9 +94,15 @@ calibrateMuso <- function(measuredData, parameters = NULL, startDate = NULL,
|
|||||||
while(progress < iterations){
|
while(progress < iterations){
|
||||||
Sys.sleep(1)
|
Sys.sleep(1)
|
||||||
progress <- tryCatch(getProgress(), error=function(e){progress})
|
progress <- tryCatch(getProgress(), error=function(e){progress})
|
||||||
pbUpdate(pb,as.numeric(progress))
|
if(is.null(pb)){
|
||||||
|
pbUpdate(as.numeric(progress))
|
||||||
|
} else {
|
||||||
|
pbUpdate(pb,as.numeric(progress))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(!is.null(pb)){
|
||||||
|
close(pb)
|
||||||
}
|
}
|
||||||
close(pb)
|
|
||||||
|
|
||||||
# ____ _ _
|
# ____ _ _
|
||||||
# / ___|___ _ __ ___ | |__ (_)_ __ ___
|
# / ___|___ _ __ ___ | |__ (_)_ __ ___
|
||||||
@ -164,7 +170,7 @@ calibrateMuso <- function(measuredData, parameters = NULL, startDate = NULL,
|
|||||||
|
|
||||||
copyToThreadDirs <- function(prefix="thread", numcores=parallel::detectCores()-1, runDir="."){
|
copyToThreadDirs <- function(prefix="thread", numcores=parallel::detectCores()-1, runDir="."){
|
||||||
dir.create(file.path(runDir,prefix), showWarnings=TRUE)
|
dir.create(file.path(runDir,prefix), showWarnings=TRUE)
|
||||||
fileNames <- grep("^thread.*", list.files(runDir), value=TRUE, invert=TRUE)
|
fileNames <- grep("^thread.*", list.files(runDir,full.names=TRUE), value=TRUE, invert=TRUE)
|
||||||
invisible(sapply(1:numcores,function(corenum){
|
invisible(sapply(1:numcores,function(corenum){
|
||||||
threadDir <- file.path(runDir,prefix,paste0(prefix,"_",corenum))
|
threadDir <- file.path(runDir,prefix,paste0(prefix,"_",corenum))
|
||||||
dir.create(threadDir, showWarnings=FALSE)
|
dir.create(threadDir, showWarnings=FALSE)
|
||||||
|
|||||||
@ -21,7 +21,6 @@ calibrateMuso <- function(measuredData, parameters = NULL, startDate = NULL,
|
|||||||
# \____|_| \___|\__,_|\__\___| \__|_| |_|_| \___|\__,_|\__,_|___/
|
# \____|_| \___|\__,_|\__\___| \__|_| |_|_| \___|\__,_|\__,_|___/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
copyToThreadDirs(thread_prefix, numcores = numcores, runDir = settings$inputLoc)
|
copyToThreadDirs(thread_prefix, numcores = numcores, runDir = settings$inputLoc)
|
||||||
|
|
||||||
# ____ _ _ _
|
# ____ _ _ _
|
||||||
@ -33,7 +32,7 @@ calibrateMuso <- function(measuredData, parameters = NULL, startDate = NULL,
|
|||||||
threadCount <- distributeCores(iterations, numCores)
|
threadCount <- distributeCores(iterations, numCores)
|
||||||
|
|
||||||
fut <- lapply(1:numCores, function(i) {
|
fut <- lapply(1:numCores, function(i) {
|
||||||
# future({
|
future({
|
||||||
musoSingleThread(measuredData, parameters, startDate,
|
musoSingleThread(measuredData, parameters, startDate,
|
||||||
endDate, formatString,
|
endDate, formatString,
|
||||||
dataVar, outLoc,
|
dataVar, outLoc,
|
||||||
@ -42,7 +41,7 @@ calibrateMuso <- function(measuredData, parameters = NULL, startDate = NULL,
|
|||||||
skipSpinup, plotName,
|
skipSpinup, plotName,
|
||||||
modifyOriginal, likelihood, uncertainity,
|
modifyOriginal, likelihood, uncertainity,
|
||||||
naVal, postProcString, i)
|
naVal, postProcString, i)
|
||||||
# })
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
# __ ___ _ _
|
# __ ___ _ _
|
||||||
@ -96,6 +95,7 @@ calibrateMuso <- function(measuredData, parameters = NULL, startDate = NULL,
|
|||||||
}
|
}
|
||||||
|
|
||||||
copyToThreadDirs <- function(prefix="thread", numcores=parallel::detectCores()-1, runDir="."){
|
copyToThreadDirs <- function(prefix="thread", numcores=parallel::detectCores()-1, runDir="."){
|
||||||
|
browser()
|
||||||
dir.create(file.path(runDir,prefix), showWarnings=TRUE)
|
dir.create(file.path(runDir,prefix), showWarnings=TRUE)
|
||||||
fileNames <- grep("^thread.*", list.files(runDir), value=TRUE, invert=TRUE)
|
fileNames <- grep("^thread.*", list.files(runDir), value=TRUE, invert=TRUE)
|
||||||
invisible(sapply(1:numcores,function(corenum){
|
invisible(sapply(1:numcores,function(corenum){
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user