Skip to content

Commit

Permalink
Adds tests
Browse files Browse the repository at this point in the history
  • Loading branch information
vwmaus committed Sep 18, 2023
1 parent 3d55b28 commit 8ec86c7
Showing 1 changed file with 23 additions and 5 deletions.
28 changes: 23 additions & 5 deletions tests/testthat/test-twdtw_classify.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)

0 comments on commit 8ec86c7

Please sign in to comment.