Closed yesdavid closed 2 years ago
Hey!
This is because the data in your objects only has one dimension. @vwmaus, I'm not sure if that is expected (in that case there should be an error message) or if that was an oversight.
I can replicate this when adjusting the README:
ts <- twdtwTimeSeries(MOD13Q1.ts[,1])
MOD13Q1.patterns.list[[1]] <- MOD13Q1.patterns.list[[1]][,1]
patt <- twdtwTimeSeries(MOD13Q1.patterns.list)
matches <- twdtwApply(x = ts, y = patt, weight.fun = log_fun, keep = TRUE)
When patt
is unchanged (from the README) the error message is: dim(X) must have a positive length.
As a temporary fix you can try the following:
ts <- twdtwTimeSeries(MOD13Q1.ts[,1])
MOD13Q1.patterns.list[[1]] <- MOD13Q1.patterns.list[[1]][,1]
MOD13Q1.patterns.list[[2]] <- MOD13Q1.patterns.list[[2]][,1]
MOD13Q1.patterns.list[[3]] <- MOD13Q1.patterns.list[[3]][,1]
patt <- twdtwTimeSeries(MOD13Q1.patterns.list)
ts <- resampleTimeSeries(ts, 93L)
patt <- resampleTimeSeries(patt, 23L)
matches <- twdtwApply(x = ts, y = patt, weight.fun = log_fun, keep = TRUE)
This works because you specifically provide the length - the data is then transformed to have two dimensions (e.g. from 23 to 23, 1).
subseting with [ ]
drops a dimention from zoo
objects if only one column is left. Just add drop=FALSE
e.g.,
library(dtwSat)
ts <- twdtwTimeSeries(MOD13Q1.ts[,1,drop=FALSE])
MOD13Q1.patterns.list[[1]] <- MOD13Q1.patterns.list[[1]][,1,drop=FALSE]
MOD13Q1.patterns.list[[2]] <- MOD13Q1.patterns.list[[2]][,1,drop=FALSE]
MOD13Q1.patterns.list[[3]] <- MOD13Q1.patterns.list[[3]][,1,drop=FALSE]
patt <- twdtwTimeSeries(MOD13Q1.patterns.list)
matches <- twdtwApply(x = ts, y = patt, weight.fun = logisticWeight(-0.1, 100), keep = TRUE)
Dear Victor,
I am trying to execute your dtwSat::twdtwApply() function but I run into the following problem:
matches <- dtwSat::twdtwApply(x = abc, y = patt, weight.fun = log_fun, keep = TRUE)
with:
str(abc)
and:
str(patt)
I already noticed that the structure of my data differs from yours, as far as both your zoo-files have character format data (and not num and Date as mine).
Is this the problem?
Best, David