In [1]:
# -*- coding: utf-8 -*-
# !/usr/bin/python
# Cross Wavelet Analysis (CWA) based on Maraun and Kurths(2004).
# http://www.nonlin-processes-geophys.net/11/505/2004/npg-11-505-2004.pdf
# author: Mabel Calim Costa
# INPE
# 23/01/2013
# reviewed --- 02/03/2018
"""
Created on Mon Jun 17 2013
@author: Mabel Calim Costa
"""
import numpy as np
import pylab
from pylab import *
import matplotlib.pyplot as plt
import cmath
import pandas as pd
In [2]:
# using the example : example_python3.6.ipynb
import numpy as np
from pylab import *
import waipy
z = np.linspace(0,2048,2048)
x = np.sin(50*np.pi*z)
data_norm_x = waipy.normalize(x)
result_x = waipy.cwt(data_norm_x, 1, 1, 0.125, 2, 4/0.125, 0.72, 6,mother='Morlet',name='x')
waipy.wavelet_plot('x', z, x, 0.03125, result_x)
In [3]:
#let's create another artificial signal to compare with that!
z2 = np.linspace(0,1024,1024)
y = np.concatenate((np.sin(30*np.pi*z2),np.sin(10*np.pi*z2)),axis=0)
data_norm_y = waipy.normalize(y)
result_y = waipy.cwt(data_norm_y, 1, 1, 0.125, 2, 4/0.125, 0.72, 6,mother='Morlet',name='x')
waipy.wavelet_plot('y', z, y, 0.03125, result_y)
In [4]:
cross_power, coherence, phase_angle = waipy.cross_wavelet(result_x['wave'],result_y['wave'])
figname = 'cp_freqchange.png'
waipy.plot_cross('signals', cross_power, phase_angle, z, result_x, result_y,figname)
#Arrows indicate in phase when pointing to the right and out of phase when pointing left.
In [6]:
cross_power, coherence, phase_angle = waipy.cross_wavelet(result_x['wave'],result_y['wave'])
figname = 'cohere_freqchange.png'
waipy.plot_cohere('signals',coherence,z,result_x, result_y,figname)
In [ ]: