-
Notifications
You must be signed in to change notification settings - Fork 25
Expand file tree
/
Copy pathIMF2RecPlot.py
More file actions
executable file
·56 lines (43 loc) · 1.27 KB
/
IMF2RecPlot.py
File metadata and controls
executable file
·56 lines (43 loc) · 1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# -*- coding: utf-8 -*-
"""
Created on Mon Jun 10 08:33:53 2013
@author: jz026613
"""
from __future__ import division
import numpy as np
import pylab as plt
import os
from plot_recurrence import rec_plot
example = 'chainsaw' # 'chainsaw', 'disconnect'
os.chdir(os.path.join('examples', example))
IMF = np.load(example+'.npy')
S = np.sum(IMF, axis=0)
t = np.arange(0, S.size).astype(np.float32)
# Params
eps = 0.005
steps = 20
if example == 'disconnect':
n_start, N = 2000, 5000
else:
n_start, N = 15000, 3000
norm = lambda X: (X-X.mean())/np.max(np.abs(X-X.mean()))
# From now on everythin is in images dir
os.chdir('images')
# Plot recurrence plot
print("Original signal - recurrence plot")
fig = plt.figure()
rec = rec_plot(norm(S)[n_start:n_start+N], eps=eps, steps=steps)
plt.imshow(rec, extent=[n_start,n_start+N,n_start+N,n_start])
plt.savefig(example+'_orgRec',dpi=200)
plt.close()
# Plot each imf figure
for imfNum in range(IMF.shape[0]):
F = IMF[imfNum]
fNorm = norm(F)
# Plot recurrence plot
print("IMF %i - recurrence plot" %imfNum)
fig = plt.figure()
rp = rec_plot(fNorm[n_start:n_start+N], eps=eps, steps=steps)
plt.imshow(rp,extent=[n_start,n_start+N,n_start+N,n_start])
plt.savefig(example+'_imfR_'+str(imfNum),dpi=200)
plt.close()