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