TODO: comprendre pkoi pas mêmes voisins
[talweg.git] / pkg / R / utils.R
index bb76996..bc80030 100644 (file)
@@ -78,6 +78,8 @@ getSimilarDaysIndices = function(index, data, limit, same_season,
                j = index + 1
        while (length(days) < min( limit, ifelse(is.null(days_in),Inf,length(days_in)) ))
        {
+               if (i < 1 && j > data$getSize())
+                       break
                if (i >= 1)
                {
                        dt = as.POSIXlt(data$getTime(i)[1])
@@ -111,6 +113,8 @@ getSimilarDaysIndices = function(index, data, limit, same_season,
 #
 .isSameSeason = function(month, month_ref)
 {
+       if (month_ref == 3) #TODO: same as Bruno (but weird)
+               return (month %in% c(2,3,4,9,10))
        if (month_ref %in% c(11,12,1,2)) #~= mid-polluted
                return (month %in% c(11,12,1,2))
        if (month_ref %in% c(3,4,9,10)) #~= high-polluted