genEpc, changemulline -> creation, bugfix
This commit is contained in:
parent
92cbd78854
commit
2607a19741
@ -37,7 +37,7 @@ Imports:
|
||||
rpart,
|
||||
rpart.plot
|
||||
Maintainer: Roland Hollo's <hollorol@gmail.com>
|
||||
RoxygenNote: 7.1.0
|
||||
RoxygenNote: 7.2.0
|
||||
Suggests: knitr,
|
||||
rmarkdown,
|
||||
VignetteBuilder: knitr
|
||||
|
||||
@ -11,6 +11,7 @@ export(copyMusoExampleTo)
|
||||
export(corrigMuso)
|
||||
export(createSoilFile)
|
||||
export(flatMuso)
|
||||
export(genEpc)
|
||||
export(getAnnualOutputList)
|
||||
export(getConstMatrix)
|
||||
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)]
|
||||
maxParIndexes <- paramIndex
|
||||
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")
|
||||
write.csv(optRanges,"optRanges.csv")
|
||||
cat("- GLUE interval values have been written into optRanges.csv\n")
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
#' @author Roland Hollos
|
||||
#' @export
|
||||
|
||||
changemulline <- function(filePaths, calibrationPar, contents, src, outFiles=filePaths){
|
||||
changemulline <- function(filePaths, calibrationPar, contents, src=NULL, outFiles=filePaths){
|
||||
# browser()
|
||||
if(is.null(src)){
|
||||
src <- filePaths
|
||||
|
||||
@ -33,3 +33,18 @@ randEpc <- function(parameterFile = "parameters.csv", location = "./epcDir",
|
||||
}
|
||||
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,
|
||||
startDate = startDate,
|
||||
endDate = endDate, leapYear = leapYearHandling, continious = continious),envir=environment())
|
||||
mesData <- numeric(settings$numYears*365)
|
||||
k <- 1
|
||||
for(i in seq(mesData)){
|
||||
if(i %in% modIndex){
|
||||
mesData[i] <- measuredData[k]
|
||||
k <- k + 1
|
||||
} else {
|
||||
mesData[i] <- NA
|
||||
}
|
||||
}
|
||||
rm(k)
|
||||
# mesData <- numeric(settings$numYears*365)
|
||||
# k <- 1
|
||||
# for(i in seq(mesData)){
|
||||
# if(i %in% modIndex){
|
||||
# mesData[i] <- measuredData[k]
|
||||
# k <- k + 1
|
||||
# } else {
|
||||
# mesData[i] <- NA
|
||||
# }
|
||||
# }
|
||||
# rm(k)
|
||||
# modIndex and measuredData are created.
|
||||
## measuredData is created
|
||||
## 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")
|
||||
selVarName <- colnames(baseData)[selVar]
|
||||
if(!all.equal(colnames(baseData),unique(colnames(baseData)))){
|
||||
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))
|
||||
}
|
||||
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")
|
||||
p <- baseData %>%
|
||||
ggplot(aes_string("date",selVarName)) +
|
||||
|
||||
@ -24,7 +24,7 @@ calibrateMuso(
|
||||
naVal = NULL,
|
||||
postProcString = NULL,
|
||||
thread_prefix = "thread",
|
||||
numCores = (parallel::detectCores() - 1),
|
||||
numCores = max(c(parallel::detectCores() - 1, 1)),
|
||||
pb = txtProgressBar(min = 0, max = iterations, style = 3),
|
||||
maxLikelihoodEpc = TRUE,
|
||||
pbUpdate = setTxtProgressBar,
|
||||
|
||||
@ -4,7 +4,13 @@
|
||||
\alias{changemulline}
|
||||
\title{changemulline}
|
||||
\usage{
|
||||
changemulline(filePaths, calibrationPar, contents, src, outFiles = filePaths)
|
||||
changemulline(
|
||||
filePaths,
|
||||
calibrationPar,
|
||||
contents,
|
||||
src = NULL,
|
||||
outFiles = filePaths
|
||||
)
|
||||
}
|
||||
\description{
|
||||
The function uses the previous changspecline function to operate.
|
||||
|
||||
@ -11,7 +11,9 @@ readObservedData(
|
||||
leapYearHandling = TRUE,
|
||||
convert.var = NULL,
|
||||
convert.scalar = 1,
|
||||
convert.fun = (function(x) { x * convert.scalar }),
|
||||
convert.fun = (function(x) {
|
||||
x * convert.scalar
|
||||
}),
|
||||
convert.file = NULL,
|
||||
filterCol = NULL,
|
||||
filterVal = 1,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user