some bugfixing

This commit is contained in:
Hollos Roland 2020-09-24 17:36:06 +02:00
parent a881e95c88
commit 3a973d0172
2 changed files with 16 additions and 10 deletions

View File

@ -16,10 +16,10 @@ calibrateMuso <- function(measuredData, parameters = NULL, startDate = NULL,
maxLikelihoodEpc=TRUE,
pbUpdate = setTxtProgressBar, method="GLUE",lg = FALSE, w=NULL, ...){
file.remove(list.files(path = settings$inputLoc, pattern="progress.txt", recursive = TRUE))
file.remove(list.files(path = settings$inputLoc, pattern="preservedCalib.csv", recursive = TRUE))
unlink("thread",recursive=TRUE)
future::plan(future::multisession)
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, full.names=TRUE))
unlink(file.path(settings$inputLoc,"thread"),recursive=TRUE)
# ____ _ _ _ _
# / ___|_ __ ___ __ _| |_ ___ | |_| |__ _ __ ___ __ _ __| |___
@ -94,9 +94,15 @@ calibrateMuso <- function(measuredData, parameters = NULL, startDate = NULL,
while(progress < iterations){
Sys.sleep(1)
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="."){
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){
threadDir <- file.path(runDir,prefix,paste0(prefix,"_",corenum))
dir.create(threadDir, showWarnings=FALSE)

View File

@ -21,7 +21,6 @@ calibrateMuso <- function(measuredData, parameters = NULL, startDate = NULL,
# \____|_| \___|\__,_|\__\___| \__|_| |_|_| \___|\__,_|\__,_|___/
copyToThreadDirs(thread_prefix, numcores = numcores, runDir = settings$inputLoc)
# ____ _ _ _
@ -33,7 +32,7 @@ calibrateMuso <- function(measuredData, parameters = NULL, startDate = NULL,
threadCount <- distributeCores(iterations, numCores)
fut <- lapply(1:numCores, function(i) {
# future({
future({
musoSingleThread(measuredData, parameters, startDate,
endDate, formatString,
dataVar, outLoc,
@ -42,7 +41,7 @@ calibrateMuso <- function(measuredData, parameters = NULL, startDate = NULL,
skipSpinup, plotName,
modifyOriginal, likelihood, uncertainity,
naVal, postProcString, i)
# })
})
})
# __ ___ _ _
@ -96,6 +95,7 @@ calibrateMuso <- function(measuredData, parameters = NULL, startDate = NULL,
}
copyToThreadDirs <- function(prefix="thread", numcores=parallel::detectCores()-1, runDir="."){
browser()
dir.create(file.path(runDir,prefix), showWarnings=TRUE)
fileNames <- grep("^thread.*", list.files(runDir), value=TRUE, invert=TRUE)
invisible(sapply(1:numcores,function(corenum){