Adding some comment to musotime and debugging
This commit is contained in:
parent
27a2c6ceb9
commit
1d0bc28565
@ -1,5 +1,6 @@
|
|||||||
|
|
||||||
isLeapyear <- function(year){
|
isLeapyear <- function(year){
|
||||||
|
##This Boolean function tells us whether the given year is leapyear or not
|
||||||
|
|
||||||
if(((year%%4==0)&(year%%100!=0))|(year%%400==0)){
|
if(((year%%4==0)&(year%%100!=0))|(year%%400==0)){
|
||||||
return(TRUE)
|
return(TRUE)
|
||||||
@ -9,6 +10,7 @@ isLeapyear <- function(year){
|
|||||||
}
|
}
|
||||||
|
|
||||||
dayOfMonths <- function(year){
|
dayOfMonths <- function(year){
|
||||||
|
##This function tells us how many days are in the months in the choosen year.
|
||||||
|
|
||||||
dayMonths <- c(31,28,31,30,31,30,31,31,30,31,30,31)
|
dayMonths <- c(31,28,31,30,31,30,31,31,30,31,30,31)
|
||||||
|
|
||||||
@ -20,6 +22,7 @@ dayOfMonths <- function(year){
|
|||||||
}
|
}
|
||||||
|
|
||||||
dayOfYears <- function(year){
|
dayOfYears <- function(year){
|
||||||
|
##This function tells us how many days are in the given year.
|
||||||
|
|
||||||
if(isLeapyear(year)==TRUE){
|
if(isLeapyear(year)==TRUE){
|
||||||
return(366)
|
return(366)
|
||||||
@ -30,6 +33,8 @@ dayOfYears <- function(year){
|
|||||||
}
|
}
|
||||||
|
|
||||||
sumDaysOfPeriod <- function(year, periodlen){
|
sumDaysOfPeriod <- function(year, periodlen){
|
||||||
|
##How many days are from the given date and given period length(periodlen)?
|
||||||
|
|
||||||
years <- year:(year+periodlen)
|
years <- year:(year+periodlen)
|
||||||
years100 <-length(which(years%%100==0))
|
years100 <-length(which(years%%100==0))
|
||||||
years400 <-length(which(years%%400==0))
|
years400 <-length(which(years%%400==0))
|
||||||
@ -41,6 +46,7 @@ sumDaysOfPeriod <- function(year, periodlen){
|
|||||||
|
|
||||||
|
|
||||||
musoDate <- function(settings,timestep="d",combined=TRUE, corrigate=TRUE){
|
musoDate <- function(settings,timestep="d",combined=TRUE, corrigate=TRUE){
|
||||||
|
##calculates a
|
||||||
|
|
||||||
days <- sumDaysOfPeriod(settings$startyear,settings$numyears)
|
days <- sumDaysOfPeriod(settings$startyear,settings$numyears)
|
||||||
dates <- matrix(rep(NA,days*3),ncol=3)
|
dates <- matrix(rep(NA,days*3),ncol=3)
|
||||||
@ -61,16 +67,18 @@ musoDate <- function(settings,timestep="d",combined=TRUE, corrigate=TRUE){
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(corrigate==TRUE){
|
if(corrigate==TRUE){
|
||||||
if(comined==TRUE){
|
if(combined==TRUE){
|
||||||
dates <- apply(dates,1,function(x) paste(x,collapse="."))[1:(settings$numyears*365)]
|
dates <- apply(dates,1,function(x) paste(x,collapse="."))[1:(settings$numyears*365)]
|
||||||
return(dates)
|
return(dates)
|
||||||
}
|
}
|
||||||
|
|
||||||
dates<-dates[(1:(settings$numyears*365)),]
|
dates<-dates[(1:(settings$numyears*365)),]
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(comined==TRUE){
|
if(combined==TRUE){
|
||||||
dates <- apply(dates,1,function(x) paste(x,collapse="."))
|
dates <- apply(dates,1,function(x) paste(x,collapse="."))
|
||||||
return(dates)
|
return(dates)
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user