genEpc, changemulline -> creation, bugfix
This commit is contained in:
parent
92cbd78854
commit
2607a19741
@ -37,7 +37,7 @@ Imports:
|
|||||||
rpart,
|
rpart,
|
||||||
rpart.plot
|
rpart.plot
|
||||||
Maintainer: Roland Hollo's <hollorol@gmail.com>
|
Maintainer: Roland Hollo's <hollorol@gmail.com>
|
||||||
RoxygenNote: 7.1.0
|
RoxygenNote: 7.2.0
|
||||||
Suggests: knitr,
|
Suggests: knitr,
|
||||||
rmarkdown,
|
rmarkdown,
|
||||||
VignetteBuilder: knitr
|
VignetteBuilder: knitr
|
||||||
|
|||||||
@ -11,6 +11,7 @@ export(copyMusoExampleTo)
|
|||||||
export(corrigMuso)
|
export(corrigMuso)
|
||||||
export(createSoilFile)
|
export(createSoilFile)
|
||||||
export(flatMuso)
|
export(flatMuso)
|
||||||
|
export(genEpc)
|
||||||
export(getAnnualOutputList)
|
export(getAnnualOutputList)
|
||||||
export(getConstMatrix)
|
export(getConstMatrix)
|
||||||
export(getDailyOutputList)
|
export(getDailyOutputList)
|
||||||
|
|||||||
@ -273,7 +273,8 @@ musoGlue <- function(presCalFile, w, delta = 0.17, settings=setupMuso(), paramet
|
|||||||
maxParValues <- unlist(preservedCalibtop5[which.max(preservedCalibtop5$combined),])[1:length(paramIndex)]
|
maxParValues <- unlist(preservedCalibtop5[which.max(preservedCalibtop5$combined),])[1:length(paramIndex)]
|
||||||
maxParIndexes <- paramIndex
|
maxParIndexes <- paramIndex
|
||||||
maxLikelihoodParameters <- data.frame(parameter_index=maxParIndexes,parameter_value=maxParValues)
|
maxLikelihoodParameters <- data.frame(parameter_index=maxParIndexes,parameter_value=maxParValues)
|
||||||
write.csv(cbind.data.frame(calibrationPar=maxParValues,parameters=maxParIndexes),"maxLikelihood.csv")
|
write.csv(cbind.data.frame(parameters=maxParIndexes, calibrationPar=maxParValues),
|
||||||
|
"maxlikelihood_parameters.csv")
|
||||||
cat("\n\n- A file containing the parameters with the maximum likelihood (maxlikelihood_parameters.csv) has been created.\n")
|
cat("\n\n- A file containing the parameters with the maximum likelihood (maxlikelihood_parameters.csv) has been created.\n")
|
||||||
write.csv(optRanges,"optRanges.csv")
|
write.csv(optRanges,"optRanges.csv")
|
||||||
cat("- GLUE interval values have been written into optRanges.csv\n")
|
cat("- GLUE interval values have been written into optRanges.csv\n")
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
#' @author Roland Hollos
|
#' @author Roland Hollos
|
||||||
#' @export
|
#' @export
|
||||||
|
|
||||||
changemulline <- function(filePaths, calibrationPar, contents, src, outFiles=filePaths){
|
changemulline <- function(filePaths, calibrationPar, contents, src=NULL, outFiles=filePaths){
|
||||||
# browser()
|
# browser()
|
||||||
if(is.null(src)){
|
if(is.null(src)){
|
||||||
src <- filePaths
|
src <- filePaths
|
||||||
|
|||||||
@ -33,3 +33,18 @@ randEpc <- function(parameterFile = "parameters.csv", location = "./epcDir",
|
|||||||
}
|
}
|
||||||
setwd(currDir)
|
setwd(currDir)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#' genEpc
|
||||||
|
#'
|
||||||
|
#' randEpc is a random epc creator based on musoMonte
|
||||||
|
#' @author Roland HOLLOS
|
||||||
|
#' @param sourceEpc the original epc file-the template
|
||||||
|
#' @param parameters dataframe where in the first column there are the indices and the second column the values
|
||||||
|
#' @param location output location directory
|
||||||
|
#' @export
|
||||||
|
|
||||||
|
genEpc <- function (sourceEpc, targetEpc, parameters) {
|
||||||
|
changemulline(filePaths=sourceEpc,outFiles=targetEpc,
|
||||||
|
calibrationPar=parameters[,1],contents=parameters[,2])
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@ -275,28 +275,29 @@ plotMusoWithData <- function(mdata, plotName=NULL,
|
|||||||
modellSettings = settings,
|
modellSettings = settings,
|
||||||
startDate = startDate,
|
startDate = startDate,
|
||||||
endDate = endDate, leapYear = leapYearHandling, continious = continious),envir=environment())
|
endDate = endDate, leapYear = leapYearHandling, continious = continious),envir=environment())
|
||||||
mesData <- numeric(settings$numYears*365)
|
# mesData <- numeric(settings$numYears*365)
|
||||||
k <- 1
|
# k <- 1
|
||||||
for(i in seq(mesData)){
|
# for(i in seq(mesData)){
|
||||||
if(i %in% modIndex){
|
# if(i %in% modIndex){
|
||||||
mesData[i] <- measuredData[k]
|
# mesData[i] <- measuredData[k]
|
||||||
k <- k + 1
|
# k <- k + 1
|
||||||
} else {
|
# } else {
|
||||||
mesData[i] <- NA
|
# mesData[i] <- NA
|
||||||
}
|
# }
|
||||||
}
|
# }
|
||||||
rm(k)
|
# rm(k)
|
||||||
# modIndex and measuredData are created.
|
# modIndex and measuredData are created.
|
||||||
## measuredData is created
|
## measuredData is created
|
||||||
## baseData <- calibMuso(settings = settings, silent = silent, prettyOut = TRUE)[modIndex,]
|
## baseData <- calibMuso(settings = settings, silent = silent, prettyOut = TRUE)[modIndex,]
|
||||||
baseData <- calibMuso(settings = settings, silent = silent, prettyOut = TRUE)
|
baseData <- calibMuso(settings = settings, silent = silent, prettyOut = TRUE)[modIndex,]
|
||||||
baseData[,1] <- as.Date(baseData[,1],format = "%d.%m.%Y")
|
baseData[,1] <- as.Date(baseData[,1],format = "%d.%m.%Y")
|
||||||
selVarName <- colnames(baseData)[selVar]
|
selVarName <- colnames(baseData)[selVar]
|
||||||
if(!all.equal(colnames(baseData),unique(colnames(baseData)))){
|
if(!all.equal(colnames(baseData),unique(colnames(baseData)))){
|
||||||
notUnique <- setdiff((unlist(settings$dailyVarCodes)),unique(unlist(settings$dailyVarCodes)))
|
notUnique <- setdiff((unlist(settings$dailyVarCodes)),unique(unlist(settings$dailyVarCodes)))
|
||||||
stop(paste0("Error: daily output variable list in the ini file must contain unique numbers. Check your ini files! Not unique codes: ",notUnique))
|
stop(paste0("Error: daily output variable list in the ini file must contain unique numbers. Check your ini files! Not unique codes: ",notUnique))
|
||||||
}
|
}
|
||||||
mesData<-cbind.data.frame(baseData[,1],mesData)
|
# mesData<-cbind.data.frame(baseData[,1],mesData)
|
||||||
|
mesData<-cbind.data.frame(baseData[,1],measuredData)
|
||||||
colnames(mesData) <- c("date", "measured")
|
colnames(mesData) <- c("date", "measured")
|
||||||
p <- baseData %>%
|
p <- baseData %>%
|
||||||
ggplot(aes_string("date",selVarName)) +
|
ggplot(aes_string("date",selVarName)) +
|
||||||
|
|||||||
@ -24,7 +24,7 @@ calibrateMuso(
|
|||||||
naVal = NULL,
|
naVal = NULL,
|
||||||
postProcString = NULL,
|
postProcString = NULL,
|
||||||
thread_prefix = "thread",
|
thread_prefix = "thread",
|
||||||
numCores = (parallel::detectCores() - 1),
|
numCores = max(c(parallel::detectCores() - 1, 1)),
|
||||||
pb = txtProgressBar(min = 0, max = iterations, style = 3),
|
pb = txtProgressBar(min = 0, max = iterations, style = 3),
|
||||||
maxLikelihoodEpc = TRUE,
|
maxLikelihoodEpc = TRUE,
|
||||||
pbUpdate = setTxtProgressBar,
|
pbUpdate = setTxtProgressBar,
|
||||||
|
|||||||
@ -4,7 +4,13 @@
|
|||||||
\alias{changemulline}
|
\alias{changemulline}
|
||||||
\title{changemulline}
|
\title{changemulline}
|
||||||
\usage{
|
\usage{
|
||||||
changemulline(filePaths, calibrationPar, contents, src, outFiles = filePaths)
|
changemulline(
|
||||||
|
filePaths,
|
||||||
|
calibrationPar,
|
||||||
|
contents,
|
||||||
|
src = NULL,
|
||||||
|
outFiles = filePaths
|
||||||
|
)
|
||||||
}
|
}
|
||||||
\description{
|
\description{
|
||||||
The function uses the previous changspecline function to operate.
|
The function uses the previous changspecline function to operate.
|
||||||
|
|||||||
@ -11,7 +11,9 @@ readObservedData(
|
|||||||
leapYearHandling = TRUE,
|
leapYearHandling = TRUE,
|
||||||
convert.var = NULL,
|
convert.var = NULL,
|
||||||
convert.scalar = 1,
|
convert.scalar = 1,
|
||||||
convert.fun = (function(x) { x * convert.scalar }),
|
convert.fun = (function(x) {
|
||||||
|
x * convert.scalar
|
||||||
|
}),
|
||||||
convert.file = NULL,
|
convert.file = NULL,
|
||||||
filterCol = NULL,
|
filterCol = NULL,
|
||||||
filterVal = 1,
|
filterVal = 1,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user