musoMonte finalize

This commit is contained in:
hollorol 2018-04-18 13:58:39 +02:00
parent 3293f3ee20
commit 3645078ee0
2 changed files with 23 additions and 10 deletions

View File

@ -12,8 +12,9 @@ musoMonte <- function(settings=NULL,
onDisk=FALSE, onDisk=FALSE,
...) ...)
{ {
outLocPlain <- basename(outLoc)
currDir <- getwd() currDir <- getwd()
inputDir <- normalizePath(inputDir)
tmp <- file.path(outLoc,"tmp/") tmp <- file.path(outLoc,"tmp/")
if(!dir.exists(outLoc)){ if(!dir.exists(outLoc)){
@ -21,10 +22,13 @@ musoMonte <- function(settings=NULL,
warning(paste(outLoc," is not exists, so it was created")) warning(paste(outLoc," is not exists, so it was created"))
} }
if(dir.exists(tmp){ if(dir.exists(tmp)){
stop("There is a tmp directory inside the output location, please replace it. tmp is an important temporary directory for the function") stop("There is a tmp directory inside the output location, please replace it. tmp is an important temporary directory for the function")
} }
dir.create(tmp) dir.create(tmp)
outLoc <- normalizePath(outLoc)
tmp <- normalizePath(tmp)
inputFiles <- file.path(inputDir,grep(basename(outLoc),list.files(inputDir),invert = TRUE,value = TRUE)) inputFiles <- file.path(inputDir,grep(basename(outLoc),list.files(inputDir),invert = TRUE,value = TRUE))
@ -58,8 +62,9 @@ musoMonte <- function(settings=NULL,
## run. ## run.
preservedEpc <- matrix(nrow = (iterations +1 ), ncol = length(settings$calibrationPar)) preservedEpc <- matrix(nrow = (iterations +1 ), ncol = length(settings$calibrationPar))
preservedEpc[1,] <- origEpc preservedEpc[1,] <- origEpc
names(origEpc)<-colnames(preservedEpc)
colnames(preservedEpc) <- Otable[[1]][,1] colnames(preservedEpc) <- Otable[[1]][,1]
write.csv(preservedEpc,"preservedEpc.csv") write.table(t(origEpc),row.names = FALSE,"preservedEpc.csv",sep=",")
## Save the backupEpc, while change the settings ## Save the backupEpc, while change the settings
## variable and set the output. ## variable and set the output.
file.copy(settings$epc[2],"savedEpc",overwrite = TRUE) # do I need this? file.copy(settings$epc[2],"savedEpc",overwrite = TRUE) # do I need this?
@ -72,7 +77,7 @@ musoMonte <- function(settings=NULL,
for(i in 1:iterations){ for(i in 1:iterations){
parVar <- musoRandomizer(A,B)[,2] parVar <- musoRandomizer(A,B)[,2]
#preservedEpc[(i+1),] <- parVar #preservedEpc[(i+1),] <- parVar
write.csv(x=parVar,file="preservedEpc.csv", append=TRUE) write.table(x=t(parVar),file="preservedEpc.csv",row.names=FALSE,col.names=FALSE, append=TRUE,sep=",")
exportName <- paste0(preTag,i,".csv") exportName <- paste0(preTag,i,".csv")
tempData <- calibMuso(settings,debugging = "stamplog", tempData <- calibMuso(settings,debugging = "stamplog",
parameters = parVar, parameters = parVar,
@ -121,8 +126,16 @@ musoMonte <- function(settings=NULL,
"netCDF" = (a <- netCDF())) "netCDF" = (a <- netCDF()))
## Change back the epc file to the original ## Change back the epc file to the original
for(i in file.path("./",grep(outLocPlain, list.files(inputDir), invert = TRUE, value = TRUE))){
file.remove(i,recursive=TRUE)
}
for(i in list.files()){
file.copy(i,outLoc,recursive=TRUE,overwrite = TRUE)
}
file.copy(savedEpc,settings$epc[2],overwrite = TRUE) unlink(tmp,recursive = TRUE)
return(do.call("c",a)) setwd(currDir)
file.copy("savedEpc",settings$epc[2],overwrite = TRUE)
return(do.call("c",a))
} }

Binary file not shown.