KatyB
KatyB

Reputation: 3980

continuous wavelet transform

This question is rather vague but has anyone used the biwavelet package in R and been successful? I have the following code:

require(biwavelet)
t1 <- cbind(DecTime,Temp)    
## continuous wavelet transform
wt1 <- wt(t1)
plot(wt1)

and it returns the error:

Error in image.default(x$t, yvals, t(zvals), zlim = zlims, ylim = rev(range(yvals)), : 'x' and 'y' values must be finite and non-missing

I dont understand this error because my data does not contain any missing values and they are all finite.

When trying to reproduce the example:

require(biwavelet)
Date = seq(from=as.POSIXct("2011-01-01 00:00"), 
           to=as.POSIXct("2011-12-31 23:00"), length=8760)
DecTime = julian(Date, Date[1])

data=cbind(as.numeric(DecTime), rnorm(8760))
## Continuous wavelet transform
wt.t1=wt(data)
plot(wt.t1)

It annoyingly works, therefore I do not know why my data fails in this package. The data in the above example is the same class as my data i.e. 'matrix'. Any help or advise would be appreciated.

Altered:

require(biwavelet)
Date = seq(from=as.POSIXct("2011-01-01 00:00"), 
           to=as.POSIXct("2011-12-31 23:00"), length=8760)
DecTime = julian(Date, Date[1])
D <- c(4.0267, 4.0211, 4.0005,4.0042,4.0042,4.0191)
data=cbind(as.numeric(DecTime[1:6]),as.numeric(D))
## Continuous wavelet transform
wt.t1=wt(data)
plot(wt.t1)


> data
           [,1]   [,2]
[1,] 0.00000000 4.0267
[2,] 0.04166667 4.0211
[3,] 0.08333333 4.0005
[4,] 0.12500000 4.0042
[5,] 0.16666667 4.0042
[6,] 0.20833333 4.0191
> class(data)
[1] "matrix"
> class(data[,1])
[1] "numeric"
> class(data[,2])
[1] "numeric"
> wt.t1=wt(data)
> plot(wt.t1)
Error in image.default(x$t, yvals, t(zvals), zlim = zlims, ylim = rev(range(yvals)),  : 
  invalid z limits

Upvotes: 3

Views: 2338

Answers (2)

Tarik
Tarik

Reputation: 61

In case you missed my reply to your other post, you discovered a bug in the wt.R function (errant parentheses). The bug has been squashed in version 0.12 of the biwavelet package, so your code will now work.

Thanks for spotting the error!

Upvotes: 1

Ken Williams
Ken Williams

Reputation: 23975

Here's a partial answer that I'm hoping will shed a little light. If you take the first N rows of data from the example that works, then it fails when N < 2762. It works when N >= 2762 (perhaps this threshold depends on the actual random values in data?):

> wt.t1=wt(data[1:2762,])
> plot(wt.t1, plot.cb=T)
> wt.t1=wt(data[1:2761,])
> plot(wt.t1, plot.cb=T)
Error in image.default(x$t, yvals, t(zvals), zlim = zlims, ylim = rev(range(yvals)),  : 
  invalid z limits

The significant piece seems to be that all the wt.t1$power values are less than 1, which messes up the way it computes its zlims variable. I have no idea what wt.t1$power is all about, though.

Upvotes: 0

Related Questions