From: Benjamin Auder Date: Tue, 25 Apr 2017 21:15:45 +0000 (+0200) Subject: Merge branch 'master' of auder.net:talweg X-Git-Url: https://git.auder.net/?p=talweg.git;a=commitdiff_plain;h=2201696688c637888b0bf9dcabf45908520fa488;hp=9dbd32d9f73bbc91c65c2c6a05095f084c6fdb16 Merge branch 'master' of auder.net:talweg --- diff --git a/pkg/R/plot.R b/pkg/R/plot.R index ad0ed4e..2b74117 100644 --- a/pkg/R/plot.R +++ b/pkg/R/plot.R @@ -83,7 +83,7 @@ plotError <- function(err, cols=seq_along(err)) plotPredReal <- function(data, pred, index) { prediction = pred$getForecast(index) - measure = data$getSerie( pred$getIndexInData(index) )[length(prediction)] + measure = data$getSerie( pred$getIndexInData(index) )[1:length(prediction)] yrange = range(measure, prediction) par(mar=c(4.7,5,1,1), cex.axis=1.5, cex.lab=1.5, lwd=3) plot(measure, type="l", ylim=yrange, xlab="Time (hours)", ylab="PM10") @@ -208,8 +208,9 @@ plotFilamentsBox = function(data, fil, predict_from) stop("Functional boxplot requires the rainbow package") series_matrix = rbind( - data$getSeries(fil$neighb_indices), data$getSeries(fil$neighb_indices+1) ) + data$getSeries(fil$neighb_indices-1), data$getSeries(fil$neighb_indices) ) series_fds = rainbow::fds(seq_len(nrow(series_matrix)), series_matrix) + par(mar=c(4.7,5,1,1), cex.axis=1.5, cex.lab=1.5) rainbow::fboxplot(series_fds, "functional", "hdr", xlab="Time (hours)", ylab="PM10", plotlegend=FALSE, lwd=2) @@ -234,8 +235,8 @@ plotFilamentsBox = function(data, fil, predict_from) #' @export plotRelVar = function(data, fil, predict_from) { - ref_var = c( apply(data$getSeries(fil$neighb_indices),1,sd), - apply(data$getSeries(fil$neighb_indices+1),1,sd) ) + ref_var = c( apply(data$getSeries(fil$neighb_indices-1),1,sd), + apply(data$getSeries(fil$neighb_indices),1,sd) ) tdays = .getNoNA2(data, 2, fil$index) global_var = c( apply(data$getSeries(tdays-1),1,sd), diff --git a/pkg/tests/testthat/test-computeFilaments.R b/pkg/tests/testthat/test-computeFilaments.R index 6ddd2c5..6169a77 100644 --- a/pkg/tests/testthat/test-computeFilaments.R +++ b/pkg/tests/testthat/test-computeFilaments.R @@ -4,15 +4,22 @@ test_that("output is as expected on simulated series", { data = getDataTest(150) + + + +#TODO: debug + + + # index 144-1 == 143 : serie type 2 - pred = computeForecast(data, 144, "Neighbors", "Zero", predict_from=8, + pred = computeForecast(data, 143, "Neighbors", "Zero", predict_from=8, horizon=length(data$getSerie(1)), simtype="endo", local=FALSE, h_window=1) f = computeFilaments(data, pred, 1, 8, limit=60, plot=FALSE) # Expected output: 50-3-10 series of type 2, then 23 series of type 3 (closest next) expect_identical(length(f$neighb_indices), as.integer(60)) expect_identical(length(f$colors), as.integer(60)) - expect_equal(f$index, 144) + expect_equal(f$index, 143) expect_true(all(I(f$neighb_indices) >= 2)) for (i in 1:37) { diff --git a/reports/Experiments.gj b/reports/Experiments.gj index d7ade40..9fd7af7 100644 --- a/reports/Experiments.gj +++ b/reports/Experiments.gj @@ -189,7 +189,7 @@ plotRelVar(data, f_np1, predict_from=P); title(paste("StdDev p1 day",i_np)) plotRelVar(data, f_p1, predict_from=P); title(paste("StdDev p1 day",i_p)) plotRelVar(data, f_np2, predict_from=P); title(paste("StdDev p2 day",i_np)) -plotRelVar(data, f_p2, preidct_from=P); title(paste("StdDev p2 day",i_p)) +plotRelVar(data, f_p2, predict_from=P); title(paste("StdDev p2 day",i_p)) # Variabilité globale en rouge ; sur les voisins (+ lendemains) en noir -----