fix Data acquisition; TODO: check CV for local method
authorBenjamin Auder <benjamin.auder@somewhere>
Thu, 29 Jun 2017 15:27:41 +0000 (17:27 +0200)
committerBenjamin Auder <benjamin.auder@somewhere>
Thu, 29 Jun 2017 15:27:41 +0000 (17:27 +0200)
pkg/R/Data.R
pkg/R/getData.R

index 8aa149d..4b1e1f3 100644 (file)
@@ -75,7 +75,7 @@ Data = R6::R6Class("Data",
                                        # Complete current cell
                                        private$.tvp[[L]]$time <- c(private$.tvp[[L]]$time, time)
                                        private$.tvp[[L]]$serie <- c(private$.tvp[[L]]$serie, value)
-                                       private$.tvp[[L]]$level_hat <- c(private$.tvp[[L]]$levem_hat, level_hat)
+                                       private$.tvp[[L]]$level_hat <- c(private$.tvp[[L]]$level_hat, level_hat)
                                }
                        }
                        if (strftime( tail(private$.tvp[[length(private$.tvp)]]$time,1),
index f1f8861..d0e69d7 100644 (file)
@@ -62,11 +62,14 @@ getData = function(ts_data, exo_data, date_format="%d/%m/%Y %H:%M", limit=Inf)
        {
                time = c()
                serie = c()
+               level_hat = c()
                repeat
                {
                        {
                                time = c(time, ts_df[line,1])
                                serie = c(serie, ts_df[line,2])
+                               level_hat = c(level_hat, #in case of data file is incomplete...
+                                       ifelse(ncol(ts_df) > 2, ts_df[line,3], mean(serie,na.rm=TRUE)))
                                line = line + 1
                        };
                        if (line >= nb_lines + 1
@@ -76,8 +79,7 @@ getData = function(ts_data, exo_data, date_format="%d/%m/%Y %H:%M", limit=Inf)
                        }
                }
 
-               # TODO: 2 modes, "operational" and "testing"; would need PM10 predictions
-               data$append(time=time, value=serie, level_hat=mean(serie,na.rm=TRUE),
+               data$append(time=time, value=serie, level_hat=level_hat,
                        exo=exo_df[i,2:(1+nb_exos)], exo_hat=exo_df[i,(1+nb_exos+1):(1+2*nb_exos)])
                if (i >= limit)
                        break