/
NCEP_phase_coherence.py
executable file
·131 lines (115 loc) · 6.07 KB
/
NCEP_phase_coherence.py
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
from scale_network import ScaleSpecificNetwork
from datetime import date
from multiprocessing import Pool
import matplotlib.pyplot as plt
import numpy as np
methods = ['MIEQQ', 'MPC']
periods = [15, 11]
for METHOD in methods:
for PERIOD in periods:
net = ScaleSpecificNetwork('/home/nikola/Work/phd/data/air.mon.mean.levels.nc', 'air',
date(1948,1,1), date(2014,1,1), None, None, 0, 'monthly', anom = True)
pool = Pool(3)
net.wavelet(PERIOD, get_amplitude = False, pool = pool)
pool.close()
print "wavelet on data done"
net.get_adjacency_matrix(net.phase, method = METHOD, pool = None, use_queue = True, num_workers = 3)
print "estimating adjacency matrix done"
net.save_net('networks/NCEP-SATAsurface-adjmat%s-scale%dyears.bin' % (METHOD, PERIOD), only_matrix = True)
WORKERS = 10
print "computing SAT amplitude data networks..."
to_do = [['MIEQQ', 4], ['MIEQQ', 6], ['MIEQQ', 8], ['MIEQQ', 11], ['MIEQQ', 15],
['MIGAU', 4], ['MIGAU', 6], ['MIGAU', 8], ['MIGAU', 11], ['MIGAU', 15]]
for do in to_do:
METHOD = do[0]
PERIOD = do[1]
print("computing for %d period using %s method" % (PERIOD, METHOD))
net = ScaleSpecificNetwork('/home/nikola/Work/phd/data/air.mon.mean.levels.nc', 'air',
date(1948,1,1), date(2014,1,1), None, None, 0, 'monthly', anom = False)
pool = Pool(WORKERS)
net.wavelet(PERIOD, get_amplitude = True, pool = pool)
print "wavelet on data done"
pool.close()
net.get_adjacency_matrix(net.amplitude, method = METHOD, pool = None, use_queue = True, num_workers = WORKERS)
print "estimating adjacency matrix done"
net.save_net('networks/NCEP-SATsurface-amplitude-adjmat%s-scale%dyears.bin' % (METHOD, PERIOD), only_matrix = True)
print "computing SATA amplitude data networks..."
to_do = [['MIEQQ', 4], ['MIEQQ', 6], ['MIEQQ', 8], ['MIEQQ', 11], ['MIEQQ', 15],
['MIGAU', 4], ['MIGAU', 6], ['MIGAU', 8], ['MIGAU', 11], ['MIGAU', 15]]
for do in to_do:
METHOD = do[0]
PERIOD = do[1]
print("computing for %d period using %s method" % (PERIOD, METHOD))
net = ScaleSpecificNetwork('/home/nikola/Work/phd/data/air.mon.mean.levels.nc', 'air',
date(1948,1,1), date(2014,1,1), None, None, 0, 'monthly', anom = True)
pool = Pool(WORKERS)
net.wavelet(PERIOD, get_amplitude = True, pool = pool)
print "wavelet on data done"
pool.close()
net.get_adjacency_matrix(net.amplitude, method = METHOD, pool = None, use_queue = True, num_workers = WORKERS)
print "estimating adjacency matrix done"
net.save_net('networks/NCEP-SATAsurface-amplitude-adjmat%s-scale%dyears.bin' % (METHOD, PERIOD), only_matrix = True)
print "computing SAT covariance data network..."
to_do = [['COV', 4]]
for do in to_do:
METHOD = do[0]
PERIOD = do[1]
print("computing using %s method" % (METHOD))
net = ScaleSpecificNetwork('/home/nikola/Work/phd/data/air.mon.mean.levels.nc', 'air',
date(1948,1,1), date(2014,1,1), None, None, 0, 'monthly', anom = False)
# pool = Pool(WORKERS)
# net.wavelet(PERIOD, get_amplitude = True, pool = pool)
# print "wavelet on data done"
# pool.close()
net.get_adjacency_matrix(net.data, method = METHOD, pool = None, use_queue = True, num_workers = WORKERS)
print "estimating adjacency matrix done"
net.save_net('networks/NCEP-SATsurface-adjmat%s.bin' % (METHOD), only_matrix = True)
print "computing SATA covariance data network..."
to_do = [['COV', 4]]
for do in to_do:
METHOD = do[0]
PERIOD = do[1]
print("computing using %s method" % (METHOD))
net = ScaleSpecificNetwork('/home/nikola/Work/phd/data/air.mon.mean.levels.nc', 'air',
date(1948,1,1), date(2014,1,1), None, None, 0, 'monthly', anom = True)
# pool = Pool(WORKERS)
# net.wavelet(PERIOD, get_amplitude = True, pool = pool)
# print "wavelet on data done"
# pool.close()
net.get_adjacency_matrix(net.data, method = METHOD, pool = None, use_queue = True, num_workers = WORKERS)
print "estimating adjacency matrix done"
net.save_net('networks/NCEP-SATAsurface-adjmat%s.bin' % (METHOD), only_matrix = True)
print "computing SAT filtered covariance data networks..."
to_do = [['COV', 4], ['COV', 6], ['COV', 8], ['COV', 11], ['COV', 15]]
for do in to_do:
METHOD = do[0]
PERIOD = do[1]
print("computing for %d period using %s method" % (PERIOD, METHOD))
net = ScaleSpecificNetwork('/home/nikola/Work/phd/data/air.mon.mean.levels.nc', 'air',
date(1948,1,1), date(2014,1,1), None, None, 0, 'monthly', anom = False)
pool = Pool(WORKERS)
net.wavelet(PERIOD, get_amplitude = True, pool = pool)
print "wavelet on data done"
net.get_filtered_data(pool = pool)
print "filtered data acquired"
pool.close()
net.get_adjacency_matrix(net.filtered_data, method = METHOD, pool = None, use_queue = True, num_workers = WORKERS)
print "estimating adjacency matrix done"
net.save_net('networks/NCEP-SATsurface-filtered-AcosPHI-adjmat%s-scale%dyears.bin' % (METHOD, PERIOD), only_matrix = True)
print "computing SATA filtered covariance data networks..."
to_do = [['COV', 4], ['COV', 6], ['COV', 8], ['COV', 11], ['COV', 15]]
for do in to_do:
METHOD = do[0]
PERIOD = do[1]
print("computing for %d period using %s method" % (PERIOD, METHOD))
net = ScaleSpecificNetwork('/home/nikola/Work/phd/data/air.mon.mean.levels.nc', 'air',
date(1948,1,1), date(2014,1,1), None, None, 0, 'monthly', anom = True)
pool = Pool(WORKERS)
net.wavelet(PERIOD, get_amplitude = True, pool = pool)
print "wavelet on data done"
net.get_filtered_data(pool = pool)
print "filtered data acquired"
pool.close()
net.get_adjacency_matrix(net.filtered_data, method = METHOD, pool = None, use_queue = True, num_workers = WORKERS)
print "estimating adjacency matrix done"
net.save_net('networks/NCEP-SATAsurface-filtered-AcosPHI-adjmat%s-scale%dyears.bin' % (METHOD, PERIOD), only_matrix = True)