Why is something missing from my figures on screen or when I try to save them?

posted Oct 2, 2014, 3:07 AM by Aslak Grinsted   [ updated Oct 20, 2014, 11:42 PM ]

This is usually caused by an incompatibility bug between Matlab and your graphics driver. There is unfortunately not any single method to resolve this issue, since it depends on your system. However, the problems can in some cases be resolved by changing the renderer property on the figure. In some cases it is caused by the shaded rendering of the COI. Here are some options you may try:
.. and additionally make sure you have the latest (open gl) drivers for your graphics card. 

How do I change the Y-axis to frequency instead of period?

posted Oct 2, 2014, 3:05 AM by Aslak Grinsted   [ updated Oct 2, 2014, 3:05 AM ]

Here is a short example that does just that. The sampling frequency is 100 MHz, and the signal is 5Mhz. figure('color',[1 1 1]) t=(0:1e-8:500e-8)'; X=sin(t*2*pi*5e6)+randn(size(t))*.1; Y=sin(t*2*pi*5e6+.4)+randn(size(t))*.1; wtc([t X],[t Y]) freq=[128 64 32 16 8 4 2 1]*1e6; set(gca,'ytick',log2(1./freq),'yticklabel',freq/1e6) ylabel('Frequency (MHz)')

How do I avoid the slow Monte Carlo significance test in WTC?

posted Oct 2, 2014, 3:03 AM by Aslak Grinsted   [ updated Oct 2, 2014, 3:04 AM ]

You can do that by simply specifying the MonteCarloCount to be zero. Example: figure('color',[1 1 1]) t=(0:1:500)'; X=sin(t*2*pi/11)+randn(size(t))*.1; Y=sin(t*2*pi/11+.4)+randn(size(t))*.1; wtc([t X],[t Y],'mcc',0); %MCC:MonteCarloCount Note that the significance contour can not be trusted with out running the Monte Carlo test.

How do I determine if a point is inside the COI or not?

posted Oct 2, 2014, 3:01 AM by Aslak Grinsted

Here is an example that does just that:

[Wx,period,scale,coi,sig95]=wt([t X]);
p=[100 64; 100 10; 50 64]; %are these points in the COI?

How do I calculate the average phase angle?

posted Oct 2, 2014, 3:01 AM by Aslak Grinsted

You can use anglemean.m provided with the package. Here is a small example that calculates the mean angle at the period closest to 11:
[Wxy,period,scale,coi,sig95]=xwt([t X],[t Y]);
[mn,rowix]=min(abs(period-11)); %row with period closest to 11.
If you want to restrict the mean to be calculated over significant regions outside the COI then you can do like this:

How do I convert a phase-angle to a time lag?

posted Oct 2, 2014, 2:59 AM by Aslak Grinsted   [ updated Oct 2, 2014, 3:00 AM ]

This can not always be done and when it can, it should be done with care. A 90deg lead might as well be a 90deg lag to the anti-phase. There is therefore a non-uniqueness problem when doing the conversion. A phase angle can also only be converted to a time lag for a specific wavelength. This equation works best for determining the time lag when the series are near in-phase.
A visual inspection of the time series at the wavelength in question should make it clear if the time lag is right. I also recommend calculating the time lag with other methods for support.

How should the phase arrows be interpreted?

posted Oct 2, 2014, 2:58 AM by Aslak Grinsted

The phase arrows show the relative phasing of two time series in question. This can also be interpreted as a lead/lag. How it should be interpreted is best illustrated by example:
figure('color',[1 1 1])
Y=sin(t-1); %X leads Y.
xwt([t X],[t Y]); % phase arrows points south east

Phase arrows pointing
  • left: anti-phase
  • right: in-phase
  • down: X leading Y by 90deg
  • up: Y leading X by 90deg
Note: interpreting the phase as a lead(/lag) should always be done with care. A lead of 90deg can also be interpreted as a lag of 270deg or a lag of 90deg relative to the anti-phase (opposite sign).

What does a peak in XWT tell?

posted Oct 2, 2014, 2:53 AM by Aslak Grinsted   [ updated Oct 2, 2014, 2:53 AM ]

You have to be very careful interpreting XWT peaks. If you take the WTC of a signal with pure white noise then the XWT will look very similar to the WT of the signal. The same problem exists in 'normal' power spectral analysis. If you calculate the cross Power spectral density of a periodic signal with a white noise signal then you will get a peak. It does not mean that the series have any kind of connection just because there is a peak. I recommend examining the WTC and the phase arrows. If there is a connection then you would expect the phenomena to be phase-locked. i.e. that the phase-arrows point only in one direction for a given wavelength.
So, if they vary between in-phase and anti-phase then it is a clue that they probably not are linked.

How important is the AR1 coefficient for WTC significance levels?

posted Oct 2, 2014, 2:51 AM by Aslak Grinsted   [ updated Oct 2, 2014, 2:51 AM ]

The definition of Wavelet coherence (WTC) effectively normalizes by the local power in time frequency space. Therefore WTC is very insensitive to the noise colour used in the null-hypothesis (see Grinsted et al. 2004). It can easily be demonstrated by example:

figure('color',[1 1 1])
wtc(X2,Y2,'ar1',[0 0]) 

The three figures are very similar.

When is the probability distribution of the data important?

posted Oct 2, 2014, 2:45 AM by Aslak Grinsted   [ updated Oct 2, 2014, 2:45 AM ]

The null-hypothesis in the significance tests for WT, XWT and WTC is normally distributed AR1 noise. The AR1 coefficient and process variance
is chosen so that it best fits the observed data. It is therefore quite important that the data is close to normal and is reasonably well
modeled by a Gaussian AR1 process. Otherwise we can trivially reject the null-hypothesis and the significance level calculated by the program
is not appropriate. However, the Central Limit Theorem tells us that the distribution tends towards normality as we convolute with longer and longer
wavelets (in the absence of long-range persistence). This means that the data distribution is only really important on the shortest scales.
So, if we are primarily looking at longer scales we do not need to worry so much about the distribution. However, for the WT and XWT the
color of the noise is very important and a very non-normal distribution will affect the performance of the ar1 estimators (ar1.m & ar1nv.m).
The WTC is relatively insensitive to the colour of the noise in the significance test (see also xxxx).

1-10 of 11