fix the cumyield hardcode bug
This commit is contained in:
parent
6a6fad0943
commit
4e338ac75b
@ -77,43 +77,55 @@ plotMuso <- function(settings=NULL,
|
|||||||
|
|
||||||
if(fromData){
|
if(fromData){
|
||||||
Reva <- tryCatch(getdailyout(settings), #(:INSIDE: getOutput.R )
|
Reva <- tryCatch(getdailyout(settings), #(:INSIDE: getOutput.R )
|
||||||
error = function (e){
|
error = function (e){
|
||||||
setwd((whereAmI))
|
setwd((whereAmI))
|
||||||
stop("Cannot read binary output, please check if the output type is set 2 in the ini files!")})
|
stop("Cannot read binary output, please check if the output type is set 2 in the ini files!")})
|
||||||
colnames(Reva) <- unlist(settings$outputVars[[1]])
|
colnames(Reva) <- unlist(settings$outputVars[[1]])
|
||||||
rownames(Reva) <- NULL
|
rownames(Reva) <- NULL
|
||||||
musoData <- cbind(musoDate(startYear = startYear,numYears = numberOfYears,combined = TRUE,corrigated=FALSE),
|
musoData <- cbind(musoDate(startYear = startYear,numYears = numberOfYears,combined = TRUE,corrigated=FALSE),
|
||||||
rep(1:365,numberOfYears),
|
rep(1:365,numberOfYears),
|
||||||
musoDate(startYear = startYear,numYears = numberOfYears,combined = FALSE,corrigated=FALSE),as.data.frame(Reva))
|
musoDate(startYear = startYear,numYears = numberOfYears,combined = FALSE,corrigated=FALSE),as.data.frame(Reva))
|
||||||
colnames(musoData)[1:5]<-c("date","yearDay","year","day","month")
|
colnames(musoData)[1:5]<-c("date","yearDay","year","day","month")
|
||||||
musoData <-musoData %>%
|
musoData <-musoData %>%
|
||||||
mutate(date=as.Date(as.character(date),"%d.%m.%Y"))
|
mutate(date=as.Date(as.character(date),"%d.%m.%Y"))
|
||||||
} else {
|
} else {
|
||||||
|
if(!is.element("cum_yieldC_HRV",unlist(settings$outputVars[[1]]))){
|
||||||
musoData <- calibMuso(settings,silent = TRUE,skipSpinup=skipSpinup) %>%
|
musoData <- calibMuso(settings,silent = TRUE,skipSpinup=skipSpinup) %>%
|
||||||
as.data.frame() %>%
|
as.data.frame() %>%
|
||||||
tibble::rownames_to_column("date") %>%
|
tibble::rownames_to_column("date") %>%
|
||||||
mutate(date2=date,date=as.Date(date,"%d.%m.%Y"),
|
mutate(date2=date,date=as.Date(date,"%d.%m.%Y")) %>%
|
||||||
yearDay=rep(1:365,numberOfYears), cum_yieldC_HRV=cum_yieldC_HRV*22.22) %>%
|
|
||||||
tidyr::separate(date2,c("day","month","year"),sep="\\.")
|
tidyr::separate(date2,c("day","month","year"),sep="\\.")
|
||||||
if(timeFrame!="day"){
|
if(timeFrame!="day"){
|
||||||
musoData <- tryCatch(groupByTimeFrame(data=musoData, timeFrame = timeFrame, groupFun = groupFun),
|
musoData <- tryCatch(groupByTimeFrame(data=musoData, timeFrame = timeFrame, groupFun = groupFun),
|
||||||
error=function(e){stop("The timeframe or the gropFun is not found")})
|
error=function(e){stop("The timeframe or the gropFun is not found")})
|
||||||
}
|
}} else {
|
||||||
|
musoData <- calibMuso(settings,silent = TRUE,skipSpinup=skipSpinup) %>%
|
||||||
|
as.data.frame() %>%
|
||||||
|
tibble::rownames_to_column("date") %>%
|
||||||
|
mutate(date2=date,date=as.Date(date,"%d.%m.%Y"),
|
||||||
|
yearDay=rep(1:365,numberOfYears), cum_yieldC_HRV=cum_yieldC_HRV*22.22) %>%
|
||||||
|
tidyr::separate(date2,c("day","month","year"),sep="\\.")
|
||||||
|
if(timeFrame!="day"){
|
||||||
|
musoData <- tryCatch(groupByTimeFrame(data=musoData, timeFrame = timeFrame, groupFun = groupFun),
|
||||||
|
error=function(e){stop("The timeframe or the gropFun is not found")})
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
## numVari <- ncol(musoData)
|
## numVari <- ncol(musoData)
|
||||||
numVari <- ncol(musoData)-5
|
numVari <- ncol(musoData)-5
|
||||||
|
|
||||||
pointOrLineOrPlot <- function(musoData, variableName, plotType="cts", expandPlot=FALSE, plotName=NULL){
|
pointOrLineOrPlot <- function(musoData, variableName, plotType="cts", expandPlot=FALSE, plotName=NULL){
|
||||||
if(!expandPlot){
|
if(!expandPlot){
|
||||||
if(plotType=="cts"){
|
if(plotType=="cts"){
|
||||||
if(length(variableName)==1){
|
if(length(variableName)==1){
|
||||||
p <- ggplot(musoData,aes_string("date",variableName))+geom_line(colour=colour)+theme(axis.title.x=element_blank())
|
p <- ggplot(musoData,aes_string("date",variableName))+geom_line(colour=colour)+theme(axis.title.x=element_blank())
|
||||||
if(!is.null(plotName)){
|
if(!is.null(plotName)){
|
||||||
ggsave(as.character(plotName), plot = p)
|
ggsave(as.character(plotName), plot = p)
|
||||||
|
p
|
||||||
|
}
|
||||||
p
|
p
|
||||||
}
|
|
||||||
p
|
|
||||||
} else {
|
} else {
|
||||||
p <- musoData %>%
|
p <- musoData %>%
|
||||||
select(c("date", variableName))%>%
|
select(c("date", variableName))%>%
|
||||||
@ -196,22 +208,22 @@ plotMuso <- function(settings=NULL,
|
|||||||
warning("Too many variables to plot, the output quality can be poor")
|
warning("Too many variables to plot, the output quality can be poor")
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
if(prod(sapply(variable,function(x){
|
if(prod(sapply(variable,function(x){
|
||||||
return(x >= 0 && x <= numVari)
|
return(x >= 0 && x <= numVari)
|
||||||
}))){
|
}))){
|
||||||
variableName <- as.character(settings$outputVars[[1]])[variable]
|
variableName <- as.character(settings$outputVars[[1]])[variable]
|
||||||
} else {
|
} else {
|
||||||
stop("Not all members of the variable parameter are among the output variables")
|
stop("Not all members of the variable parameter are among the output variables")
|
||||||
}}
|
}}
|
||||||
|
|
||||||
pointOrLineOrPlot(musoData = musoData,
|
pointOrLineOrPlot(musoData = musoData,
|
||||||
variableName = variableName,
|
variableName = variableName,
|
||||||
plotType = plotType,
|
plotType = plotType,
|
||||||
expandPlot = layerPlot,
|
expandPlot = layerPlot,
|
||||||
plotName = plotName)
|
plotName = plotName)
|
||||||
}
|
}
|
||||||
|
|
||||||
#'plot the BBGCMuso output with data
|
#'plot the BBGCMuso output with data
|
||||||
#'
|
#'
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user