modifyOriginal possibility
This commit is contained in:
parent
035bfe12c6
commit
907b41b993
@ -105,14 +105,14 @@ calibMuso <- function(settings=NULL, calibrationPar=NULL,
|
||||
|
||||
toModif<-c(epc[2],iniInput[2])
|
||||
|
||||
if(!modifyOriginal & (!is.null(parameters) | !is.null(outVars)))
|
||||
{
|
||||
# if(!modifyOriginal & (!is.null(parameters) | !is.null(outVars)))
|
||||
# {
|
||||
|
||||
toModif <- sapply(toModif, function (x){
|
||||
paste0(tools::file_path_sans_ext(basename(x)),"-tmp.",tools::file_ext(x))
|
||||
})
|
||||
|
||||
}
|
||||
# }
|
||||
|
||||
##change the epc file if and only if there are given parameters
|
||||
if(!is.null(parameters)){
|
||||
@ -138,6 +138,7 @@ calibMuso <- function(settings=NULL, calibrationPar=NULL,
|
||||
writeLines(tmp,iniInput[2])
|
||||
rm(list=c("tmp","tmpInd"))
|
||||
}
|
||||
|
||||
if(!is.null(outVars)){
|
||||
outputVarChanges <- putOutVars(iniInput[2], outputVars = outVars, modifyOriginal = !modifyOriginal)
|
||||
settings$outputVars[[1]]<-outputVarChanges[[1]]
|
||||
|
||||
@ -37,6 +37,7 @@ optiMuso <- function(measuredData, parameters = NULL, startDate = NULL,
|
||||
skipSpinup = TRUE,
|
||||
constrains = NULL,
|
||||
plotName = "calib.jpg",
|
||||
modifyOriginal=TRUE,
|
||||
likelihood = function(x, y){
|
||||
exp(-sqrt(mean((x-y)^2)))
|
||||
},
|
||||
@ -115,7 +116,7 @@ optiMuso <- function(measuredData, parameters = NULL, startDate = NULL,
|
||||
|
||||
modellOut <- numeric(iterations + 1) # single variable solution
|
||||
rmse <- numeric(iterations + 1)
|
||||
origModellOut <- calibMuso(settings=settings,silent=TRUE, skipSpinup = skipSpinup,postProcString=postProcString)
|
||||
origModellOut <- calibMuso(settings=settings,silent=TRUE, skipSpinup = skipSpinup,postProcString=postProcString, modifyOriginal=modifyOriginal)
|
||||
|
||||
|
||||
write.csv(x=origModellOut, file=paste0(pretag,1,".csv"))
|
||||
@ -138,7 +139,7 @@ optiMuso <- function(measuredData, parameters = NULL, startDate = NULL,
|
||||
tmp <- tryCatch(calibMuso(settings = settings,
|
||||
parameters = randValues[(i-1),],
|
||||
silent= TRUE,
|
||||
skipSpinup = skipSpinup, postProcString = postProcString)[modIndex,colNumb], error = function (e) NULL )
|
||||
skipSpinup = skipSpinup, modifyOriginal=modifyOriginal, postProcString = postProcString)[modIndex,colNumb], error = function (e) NULL )
|
||||
if(is.null(tmp)){
|
||||
tmp <- rmse[i] <- modellOut[i] <- NA
|
||||
} else {
|
||||
|
||||
@ -33,6 +33,10 @@ changemulline <- function(filePaths, calibrationPar, contents, fileOut, fileToCh
|
||||
changeMusoC(inFile = filePaths[selectFileToWrite(filePaths, fileToChange)],
|
||||
outFile = fileOut[selectFileToWrite(filePaths, fileToChange)],
|
||||
parMat)
|
||||
if(modifyOriginal){
|
||||
# browser()
|
||||
file.copy(fileOut[selectFileToWrite(filePaths, fileToChange)],filePaths[selectFileToWrite(filePaths, fileToChange)],overwrite = TRUE)
|
||||
}
|
||||
}
|
||||
|
||||
if(fileToChange == "both"){
|
||||
|
||||
Loading…
Reference in New Issue
Block a user