correct the leapYearHandling bug

This commit is contained in:
Roland Hollós 2019-03-14 12:54:15 +01:00
parent e125c1dba5
commit 2471b7138c
2 changed files with 8 additions and 8 deletions

View File

@ -81,11 +81,11 @@ alignData <- function(mdata, dataCol, modellSettings = NULL, startDate=NULL, en
dates <- do.call(c,lapply(seq(nrow(mdata)), function(i){ as.Date(paste0(mdata[i,1],sprintf("%02d",mdata[i,2]),mdata[i,3]),format = "%Y%m%d")}))
}
if(!leapYear){
casualDays <- which(format(dates,"%m%d") != "0229")
#mdata <- mdata[casualDays,]
dates <- dates[casualDays]
}
## if(!leapYear){
## casualDays <- which(format(dates,"%m%d") != "0229")
## #mdata <- mdata[casualDays,]
## dates <- dates[casualDays]
## }
mdata <- mdata[dates >= as.Date(paste0(modellSettings$startYear,"01","01"),format = "%Y%m%d"),]
dates <- dates[dates >= as.Date(paste0(modellSettings$startYear,"01","01"),format = "%Y%m%d")]
@ -102,7 +102,7 @@ alignData <- function(mdata, dataCol, modellSettings = NULL, startDate=NULL, en
}
realDate <- dates[which(format(dates,"%m%d") != "0229")]
if(leapYear){
mdata <- cbind.data.frame(realDate,mdata)
mdata <- cbind.data.frame(realDate,mdata[goodInd,])
} else {
mdata <- cbind.data.frame(dates,mdata)
}

View File

@ -252,7 +252,7 @@ plotMuso <- function(settings = NULL, variable = 1,
#' @export
plotMusoWithData <- function(mdata, plotName=NULL,
startDate = NULL, endDate = NULL,
colour=c("black","blue"), dataVar, modelVar, settings = setupMuso(), silent = TRUE, continious = FALSE){
colour=c("black","blue"), dataVar, modelVar, settings = setupMuso(), silent = TRUE, continious = FALSE, leapYearHandling = FALSE){
if(continious & (is.null(startDate) | is.null(endDate))){
stop("If your date is continuous, you have to provide both startDate and endDate. ")
@ -264,7 +264,7 @@ plotMusoWithData <- function(mdata, plotName=NULL,
list2env(alignData(mdata, dataCol = dataCol,
modellSettings = settings,
startDate = startDate,
endDate = endDate, leapYear = FALSE, continious = continious),envir=environment())
endDate = endDate, leapYear = leapYearHandling, continious = continious),envir=environment())
mesData <- numeric(settings$numYears*365)
k <- 1
for(i in seq(mesData)){