coeffs_chunk
}
-#NOTE: always keep ID in first column (...? is it good ?!)
curvesToCoeffs = function(series, wf)
{
if (!require(wavelets, quietly=TRUE))
stop("Couldn't load wavelets library")
L = length(series[1,])
- D = ceiling( log2(L-1) )
+ D = ceiling( log2(L) )
nb_sample_points = 2^D
#TODO: parallel::parApply() ?!
- res = apply(series, 1, function(x) {
- interpolated_curve = spline(1:(L-1), x[2:L], n=nb_sample_points)$y
+ as.data.frame( apply(series, 1, function(x) {
+ interpolated_curve = spline(1:L, x, n=nb_sample_points)$y
W = wavelets::dwt(interpolated_curve, filter=wf, D)@W
- nrj_coeffs = rev( sapply( W, function(v) ( sqrt( sum(v^2) ) ) ) )
- return ( c(x[1], nrj_coeffs) )
- })
- return (as.data.frame(res))
+ rev( sapply( W, function(v) ( sqrt( sum(v^2) ) ) ) )
+ }) )
}
#TODO: appendCoeffs() en C --> serialize et append to file
}
-deserialize = function(file, range, serie_length)
+deserialize = function(file, range, ncoefs)
{
#......
#C function (from file name)