fix Data acquisition; TODO: check CV for local method
[talweg.git] / pkg / R / getData.R
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