Question

Could anyone suggest why the following example code does not work:

require(biwavelet)
t <- seq(1/24, 365, 1/24)
A <- 2
fs <- 1/24
y <- A + sin(2*pi*fs*t)
d = cbind(t,y)
wt.t1 <- wt(d)
plot(wt.t1)

It generates an error stating:

Error in image.default(x$t, yvals, t(zvals), zlim = zlims, ylim = rev(range(yvals)),  : 
  invalid z limits

How would I fix this problem?

Additional:

In response to Gavin Simpsons answer: If I keep the data to only include one frequency but alter the time vector, the code works fine.

require(biwavelet)
A <- 2
fs <- 1/24
y <- A + sin(2*pi*fs*t)
d <- cbind(seq(1,8760), y) 
wt.t1 <- wt(d)
plot(wt.t1)
Was it helpful?

Solution

I suspect this is due to the fact that you have only a single frequency here and the function isn't set up for that. I can get a plot by adding white noise to y:

require(biwavelet)
t <- seq(1/24, 365, 1/24)
A <- 2
fs <- 1/24
y <- A + sin(2*pi*fs*t)
d <- cbind(t, y + rnorm(length(y))) ## add some white noise to y
wt.t1 <- wt(d)
plot(wt.t1)

You might wish to contact the maintainers to report the issue. I got the plot to do something when I debugged it and reversed zlim so that diff(zlim) was positive, so it might be that the author of the plot() method was making an assumption that doesn't hold in all cases.

OTHER TIPS

You discovered a bug in the wt.R function (errant parentheses). The bug has been fixed in version 0.12 of the biwavelet package, so both versions of your code above should now work.

Thanks for spotting the error. Please don't hesitate to email the maintainer of the package (i.e., me) about bugs in the future.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top