From 8ec86c78baeab44e7483a8dd71d0f60237f2a36e Mon Sep 17 00:00:00 2001 From: vwmaus Date: Mon, 18 Sep 2023 16:47:06 +0200 Subject: [PATCH] Adds tests --- tests/testthat/test-twdtw_classify.R | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/tests/testthat/test-twdtw_classify.R b/tests/testthat/test-twdtw_classify.R index 4eabedd..f20166c 100644 --- a/tests/testthat/test-twdtw_classify.R +++ b/tests/testthat/test-twdtw_classify.R @@ -26,8 +26,7 @@ dc <- read_stars(tif_files, # Create a knn1-twdtw model m <- knn1_twdtw(x = dc, y = samples, - formula = band ~ s(time), - sampling_freq = 16) + formula = band ~ s(time)) # Visualize model patterns plot(m) @@ -42,11 +41,30 @@ system.time( time_weight = c(steepness = 0.1, midpoint = 50)) ) -# Test get freq from data +### OTHER TESTS +# split time first +dc <- read_stars(tif_files, + proxy = FALSE, + along = list(time = acquisition_date), + RasterIO = list(bands = 1:6)) |> + st_set_dimensions(3, c("EVI", "NDVI", "RED", "BLUE", "NIR", "MIR")) |> + split(c("time")) |> + split(c("band")) + m <- knn1_twdtw(x = dc, y = samples, - formula = band ~ s(time)) + formula = band ~ s(time), + sampling_freq = 60) + +system.time( + lu <- predict(dc, + model = m, + drop_dimensions = TRUE, + cycle_length = 'year', + time_scale = 'day', + time_weight = c(steepness = 0.1, midpoint = 50)) +) -# Test without samples reduction +# Test model without samples reduction m <- knn1_twdtw(x = dc, y = samples)