Adding element to setupmuso, oneCsv option in musoMonte
This commit is contained in:
parent
8a85325ff6
commit
32657c7330
@ -1,2 +1,2 @@
|
|||||||
GPP_mes <- read.csv("hhs_GPP_measured.csv", stringAsFactors)
|
## GPP_mes <- read.csv("hhs_GPP_measured.csv", stringAsFactors)
|
||||||
head(GPP_mes$year)
|
## head(GPP_mes$year)
|
||||||
|
|||||||
@ -181,27 +181,69 @@ musoMonte <- function(settings=NULL,
|
|||||||
## csv files for each run
|
## csv files for each run
|
||||||
|
|
||||||
oneCsv <- function () {
|
oneCsv <- function () {
|
||||||
stop("This function is not implemented yet")
|
# stop("This function is not implemented yet")
|
||||||
## numDays <- settings$numdata[1]
|
settings$iniInput[2] %>%
|
||||||
## if(!onDisk){
|
(function(x) paste0(dirname(x),"/",tools::file_path_sans_ext(basename(x)),"-tmp.",tools::file_ext(x))) %>%
|
||||||
## for(i in 1:iterations){
|
unlink
|
||||||
|
randValues <- randVals[[2]]
|
||||||
|
settings$calibrationPar <- randVals[[1]]
|
||||||
|
## randValues <- randValues[,randVals[[1]] %in% parameters[,2]][,rank(parameters[,2])]
|
||||||
|
modellOut <- matrix(ncol = numVars, nrow = iterations + 1)
|
||||||
|
|
||||||
## parVar <- apply(parameters,1,function (x) {
|
origModellOut <- calibMuso(settings=settings,silent=TRUE)
|
||||||
## runif(1, as.numeric(x[3]), as.numeric(x[4]))})
|
write.csv(x=origModellOut, file=paste0(pretag,".csv"))
|
||||||
|
|
||||||
## preservedEpc[(i+1),] <- parVar
|
if(!is.list(fun)){
|
||||||
## exportName <- paste0(preTag,".csv")
|
funct <- rep(list(fun), numVars)
|
||||||
## write.csv(parvar,"preservedEpc.csv",append=TRUE)
|
}
|
||||||
## calibMuso(settings,debugging = "stamplog",
|
|
||||||
## parameters = parVar,keepEpc = TRUE) %>%
|
|
||||||
## {mutate(.,iD = i)} %>%
|
|
||||||
## {write.csv(.,file=exportName,append=TRUE)}
|
|
||||||
## }
|
|
||||||
|
|
||||||
## return(preservedEpc)
|
tmp2 <- numeric(numVars)
|
||||||
## } else {
|
|
||||||
|
|
||||||
## }
|
for(j in 1:numVars){
|
||||||
|
tmp2[j]<-funct[[j]](origModellOut[,j])
|
||||||
|
}
|
||||||
|
modellOut[1,]<- tmp2
|
||||||
|
|
||||||
|
for(i in 2:(iterations+1)){
|
||||||
|
tmp <- tryCatch(calibMuso(settings = settings,
|
||||||
|
parameters = randValues[(i-1),],
|
||||||
|
silent= TRUE,
|
||||||
|
skipSpinup = skipSpinup,
|
||||||
|
keepEpc = keepEpc,
|
||||||
|
debugging = debugging,
|
||||||
|
outVars = outVars), error = function (e) NA)
|
||||||
|
|
||||||
|
if(!is.na(tmp)){
|
||||||
|
for(j in 1:numVars){
|
||||||
|
tmp2[j]<-funct[[j]](tmp[,j])
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for(j in 1:numVars){
|
||||||
|
tmp2[j]<-rep(NA,length(settings$outputVars[[1]]))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
modellOut[i,]<- tmp2
|
||||||
|
write.table(x=tmp, file=paste0(pretag,".csv"), append = TRUE,col.names = FALSE, sep = ",")
|
||||||
|
setTxtProgressBar(progBar,i)
|
||||||
|
}
|
||||||
|
|
||||||
|
paramLines <- parameters[,2]
|
||||||
|
paramLines <- order(paramLines)
|
||||||
|
randInd <- randVals[[1]][(randVals[[1]] %in% parameters[,2])]
|
||||||
|
randInd <- order(randInd)
|
||||||
|
|
||||||
|
|
||||||
|
epcStrip <- rbind(origEpc[order(parameters[,2])],
|
||||||
|
randValues[,randVals[[1]] %in% parameters[,2]][,randInd])
|
||||||
|
|
||||||
|
|
||||||
|
preservedEpc <- cbind(epcStrip,
|
||||||
|
modellOut)
|
||||||
|
colnames(preservedEpc) <- c(parameterNames[paramLines], sapply(outVarNames, function (x) paste0("mod.", x)))
|
||||||
|
return(preservedEpc)
|
||||||
}
|
}
|
||||||
|
|
||||||
netCDF <- function () {
|
netCDF <- function () {
|
||||||
|
|||||||
@ -273,7 +273,9 @@ setupMuso <- function(executable=NULL,
|
|||||||
numYears=numYears,
|
numYears=numYears,
|
||||||
outputVars=outputVars,
|
outputVars=outputVars,
|
||||||
dailyVarCodes= gsub("\\s.*","",dailyVarCodes),
|
dailyVarCodes= gsub("\\s.*","",dailyVarCodes),
|
||||||
annualVarCodes = gsub("\\s.*","",annualVarCodes)
|
annualVarCodes = gsub("\\s.*","",annualVarCodes),
|
||||||
|
numVarY = length(outputVars[[2]]),
|
||||||
|
numVarD = length(outputVars[[1]])
|
||||||
)
|
)
|
||||||
|
|
||||||
if(writep!=nrow(grepHelper)){
|
if(writep!=nrow(grepHelper)){
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user