def main(): n_samples = 1024 # Ruido vermelho S3 = powernoise(2, n_samples) # Caos, usado para gerar o sinal S7 rho = 3.85 a0 = 0.001 S4 = logistic(rho, a0, n_samples) # Soma os sinais e normalizae modo que <A>=0 e std=1 S7 = pre.standardize(S3 + S4) # Sinal gerado pelo pmodel S8 = pmodel(noValues=n_samples, p=0.52, slope=-1.66) data = S8 z = np.linspace(0, 1024, 1024) data_norm = waipy.normalize(data) result = waipy.cwt(data_norm, 1, 1, 0.125, 2, 4 / 0.125, 0.72, 6, mother='h', name='S8') waipy.wavelet_plot('S8', z, data_norm, 0.03125, result)
def main(): ''' d = np.genfromtxt(INFILE).T time, data = d ''' fs, data = wavfile.read(INFILE) plt.plot(data) # plt.show() data = data[10000:11000] # data = scipy.signal.resample(data, len(data)//4) # time = np.arange(0, len(data), 1./fs) time = np.arange(len(data)) data = waipy.normalize(data) result = waipy.cwt(data, 1, 1, 0.25, 2, 4 / 0.25, alpha, 6, mother='Morlet') waipy.wavelet_plot() wavelet(time, data, True) raw_input('')
from scipy import signal import numpy as np import matplotlib.pyplot as plt import waipy datasets = (['data1.dat', 'SAR', 1800], ['data2.dat', 'BIK', 1864], ['data3.dat', 'VUS', 1609]) dt = 1 units = 'mm' for d, name, t0 in datasets: data = np.loadtxt(d) N = data.size time = np.arange(0, N) * dt + t0 label = 'Precipitation data {}'.format(name) data_norm = waipy.normalize(data) alpha = abs(np.corrcoef(data_norm[0:-1], data_norm[1:])[0, 1]) result = waipy.cwt(data_norm, 1, 1, 0.25, 2, 7 / 0.25, alpha, 6, mother='Morlet', name=name) waipy.wavelet_plot(label, time, data_norm, 1.0e-6, result)
import waipy import numpy as np z = np.linspace(0,2048,2048) x = np.sin(50*np.pi*z) y = np.cos(50*np.pi*z) data_norm = waipy.normalize(x) result = waipy.cwt(data_norm, 1, 1, 0.125, 2, 4/0.125, 0.72, 6, mother='Morlet',name='x') waipy.wavelet_plot('Sine', z, data_norm, 0.03125, result) data_norm1 = waipy.normalize(y) result1 = waipy.cwt(data_norm1, 1, 1, 0.125, 2, 4/0.125, 0.72, 6, mother='Morlet',name='y') waipy.wavelet_plot('Cosine', z, data_norm1, 0.03125, result1) cross_power, coherence, phase_angle = waipy.cross_wavelet(result['wave'], result1['wave']) waipy.plot_cross('Crosspower sine and cosine', cross_power, phase_angle, z, result, result1)
import waipy import numpy as np x = np.linspace(0, 100, 100) y1 = np.random.rand(100) # Generation of the Random Signal 1 y2 = np.random.rand(100) # Generation of the Random Signal 2 data_norm = waipy.normalize(y1) data_norm1 = waipy.normalize(y2) result = waipy.cwt(data_norm, 1, 1, 0.25, 2, 4/0.25, 0.72, 6, mother='Morlet', name='x') result1 = waipy.cwt(data_norm1, 1, 1, 0.25, 2, 4/0.25, 0.72, 6, mother='Morlet', name='y') waipy.wavelet_plot('y1-random-signal', x, data_norm, 0.03125, result) waipy.wavelet_plot('y2-random-signal', x, data_norm1, 0.03125, result1) cross_power, coherence, phase_angle = waipy.cross_wavelet(result['wave'], result1['wave']) waipy.plot_cross('Crosspower of y1 and y2', cross_power, phase_angle, x, result, result1)
import waipy from waipy import wavelet_plot tick_spacing = 4 data = np.genfromtxt("data/batch_4.txt", delimiter=",")[20000:30000] time = (data[:, 0])#/1000 x = 9.8*(data[:, 1])/2048 y = 9.8*(data[:, 2])/2048 z = 9.8*((data[:, 3]))/2048 # -- factory offset of this particular accelerometer! var = z dt = 5 data_norm = waipy.normalize(var) alpha = np.corrcoef(data_norm[0:-1], data_norm[1:])[0,1]; result = waipy.cwt(data_norm, dt, 0, 0.0625, 1, 36, alpha, 6, mother='Morlet', name="name") waipy.wavelet_plot("img/batch_4_z_start_osc", time, data_norm, 0.03125, result); """ CONTINUOUS WAVELET TRANSFORM pad = 1 # pad the time series with zeroes (recommended) dj = 0.25 # this will do 4 sub-octaves per octave s0 = 2*dt # this says start at a scale of 6 months j1 = 7/dj # this says do 7 powers-of-two with dj sub-octaves each lag1 = 0.72 # lag-1 autocorrelation for red noise background param = 6 mother = 'Morlet' """
ax.set_ylabel('Period (dekads)') ax.set_xlabel('Power') Yticks = 2 ** np.arange(np.ceil(np.log2(period.min())), np.ceil(np.log2(period.max()))) ax.set_yticks(np.log2(Yticks)) ax.set_yticklabels(Yticks) ax.invert_yaxis() ylim = ax.get_ylim() ax.set_ylim(ylim[0], -1) cbar = plt.colorbar(cf) plt.show() #%% data_norm = waipy.normalize(arsi.NDVI) result = waipy.cwt(data_norm, 1, 1, 0.125, 2, 4/0.125, 0.72, 6,mother='Morlet',name='X') waipy.wavelet_plot('Wavelet Signal', arsi.index.values, data_norm, 0.03125, result) #%% #Augmented Dickey-Fuller test #conclusion: all data are stationary result = adfuller(arsi.NDVI) print('ADF Statistic: %f' % result[0]) print('p-value: %f' % result[1]) print('Critical Values:') for key, value in result[4].items(): print('\t%s: %.3f' % (key, value))
import waipy import numpy as np x = np.linspace(0, 100, 100) y1 = np.random.rand(100) # Generation of the Random Signal 1 y2 = np.random.rand(100) # Generation of the Random Signal 2 data_norm = waipy.normalize(y1) data_norm1 = waipy.normalize(y2) result = waipy.cwt(data_norm, 1, 1, 0.25, 2, 4 / 0.25, 0.72, 6, mother='Morlet', name='x') result1 = waipy.cwt(data_norm1, 1, 1, 0.25, 2, 4 / 0.25, 0.72, 6, mother='Morlet', name='y')