add randomization feature to sensitivity and calibration with musoMonte
This commit is contained in:
parent
216f2109fe
commit
b9e829951e
@ -12,6 +12,7 @@ calibrateMuso <- function(measuredData, parameters =read.csv("parameters.csv", s
|
|||||||
skipSpinup = TRUE, plotName = "calib.jpg",
|
skipSpinup = TRUE, plotName = "calib.jpg",
|
||||||
modifyOriginal=TRUE, likelihood, uncertainity = NULL,
|
modifyOriginal=TRUE, likelihood, uncertainity = NULL,
|
||||||
naVal = NULL, postProcString = NULL,
|
naVal = NULL, postProcString = NULL,
|
||||||
|
sourceFile=NULL, # bases for musoRand if dependecy group is not fully defined by parameters.csv
|
||||||
thread_prefix="thread", numCores = max(c(parallel::detectCores()-1,1)), pb = txtProgressBar(min=0, max=iterations, style=3),
|
thread_prefix="thread", numCores = max(c(parallel::detectCores()-1,1)), pb = txtProgressBar(min=0, max=iterations, style=3),
|
||||||
maxLikelihoodEpc=TRUE,
|
maxLikelihoodEpc=TRUE,
|
||||||
pbUpdate = setTxtProgressBar, outputLoc="./", method="GLUE",lg = FALSE, w=NULL, ...){
|
pbUpdate = setTxtProgressBar, outputLoc="./", method="GLUE",lg = FALSE, w=NULL, ...){
|
||||||
@ -127,6 +128,14 @@ calibrateMuso <- function(measuredData, parameters =read.csv("parameters.csv", s
|
|||||||
switch(method,
|
switch(method,
|
||||||
"GLUE"={
|
"GLUE"={
|
||||||
musoGlue(results, parameters=parameters,settings=settings, w=w, lg=lg)
|
musoGlue(results, parameters=parameters,settings=settings, w=w, lg=lg)
|
||||||
|
liks <- results[,sprintf("%s_likelihood",names(likelihood))]
|
||||||
|
epcIndexes <- future::value(fut[[1]], stdout = FALSE, signal=FALSE)
|
||||||
|
epcVals <- results[which.max(liks),1:length(epcIndexes)]
|
||||||
|
epcPlace <- file.path(dirname(settings$inputFiles),settings$epc)[2]
|
||||||
|
changemulline(filePaths= epcPlace, epcIndexes,
|
||||||
|
epcVals, src =epcPlace,# settings$epcInput[2],
|
||||||
|
outFiles = file.path(outputLoc, "maxLikelihood_epc.epc"))
|
||||||
|
names(epcVals) <- epcIndexes
|
||||||
},
|
},
|
||||||
"agromo"={
|
"agromo"={
|
||||||
liks <- results[,sprintf("%s_likelihood",names(likelihood))]
|
liks <- results[,sprintf("%s_likelihood",names(likelihood))]
|
||||||
@ -234,7 +243,7 @@ musoSingleThread <- function(measuredData, parameters = NULL, startDate = NULL,
|
|||||||
## row numbers
|
## row numbers
|
||||||
print("optiMuso is randomizing the epc parameters now...",quote = FALSE)
|
print("optiMuso is randomizing the epc parameters now...",quote = FALSE)
|
||||||
if(iterations < 3000){
|
if(iterations < 3000){
|
||||||
randVals <- musoRand(parameters = parameters,constrains = NULL, iterations = 3000)
|
randVals <- musoRand(parameters = parameters,constrains = NULL, iterations = 3000,sourceFile=sourceFile)
|
||||||
randVals[[2]]<- randVals[[2]][sample(1:3000,iterations),]
|
randVals[[2]]<- randVals[[2]][sample(1:3000,iterations),]
|
||||||
} else {
|
} else {
|
||||||
randVals <- musoRand(parameters = parameters,constrains = NULL, iterations = iterations)
|
randVals <- musoRand(parameters = parameters,constrains = NULL, iterations = iterations)
|
||||||
|
|||||||
@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
musoMonte <- function(settings=NULL,
|
musoMonte <- function(settings=NULL,
|
||||||
parameters=NULL,
|
parameters=NULL,
|
||||||
|
sourceFile=NULL,
|
||||||
inputDir = "./",
|
inputDir = "./",
|
||||||
outLoc = "./calib",
|
outLoc = "./calib",
|
||||||
iterations = 10,
|
iterations = 10,
|
||||||
@ -100,7 +101,7 @@ musoMonte <- function(settings=NULL,
|
|||||||
##reading the original epc file at the specified
|
##reading the original epc file at the specified
|
||||||
## row numbers
|
## row numbers
|
||||||
if(iterations < 3000){
|
if(iterations < 3000){
|
||||||
randVals <- musoRand(parameters = parameters,fileType="epc", iterations = 3000)
|
randVals <- musoRand(parameters = parameters,fileType="epc", iterations = 3000,sourceFile=sourceFile)
|
||||||
randVals[[2]]<- randVals[[2]][sample(1:3000,iterations),]
|
randVals[[2]]<- randVals[[2]][sample(1:3000,iterations),]
|
||||||
} else {
|
} else {
|
||||||
randVals <- musoRand(parameters = parameters,fileType="epc", iterations = iterations)
|
randVals <- musoRand(parameters = parameters,fileType="epc", iterations = iterations)
|
||||||
|
|||||||
@ -31,6 +31,7 @@ musoSensi <- function(monteCarloFile = NULL,
|
|||||||
plotTitle = "Sensitivity",
|
plotTitle = "Sensitivity",
|
||||||
skipSpinup = TRUE,
|
skipSpinup = TRUE,
|
||||||
skipZero = TRUE,
|
skipZero = TRUE,
|
||||||
|
sourceFile=NULL,
|
||||||
postProcString=NULL,
|
postProcString=NULL,
|
||||||
modifyOut=TRUE,
|
modifyOut=TRUE,
|
||||||
dpi=300){
|
dpi=300){
|
||||||
@ -87,6 +88,7 @@ musoSensi <- function(monteCarloFile = NULL,
|
|||||||
if(is.null(monteCarloFile)){
|
if(is.null(monteCarloFile)){
|
||||||
M <- musoMonte(parameters = parameters,
|
M <- musoMonte(parameters = parameters,
|
||||||
settings = settings,
|
settings = settings,
|
||||||
|
sourceFile=NULL,
|
||||||
inputDir = inputDir,
|
inputDir = inputDir,
|
||||||
outLoc = outLoc,
|
outLoc = outLoc,
|
||||||
iterations = iterations,
|
iterations = iterations,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user