None, None, 'monthly', anom=False) pool = Pool(20) net.wavelet(1, 'y', pool=pool, cut=1) net.get_continuous_phase(pool=pool) print "wavelet done" net.get_phase_fluctuations(rewrite=True, pool=pool) print "fluctuations done" pool.close() pool.join() net.phase_fluctuations -= np.nanmean(net.phase_fluctuations, axis=0) net.get_adjacency_matrix(net.phase_fluctuations, method="L2", pool=None, use_queue=True, num_workers=20) net.save_net('networks/NCEP-SATannual-phase-fluctuations-adjmatL2.bin', only_matrix=True) print "L2 done" ## PHASE FLUCTUATIONS NETWORK correlation print "Computing MI knn..." net = ScaleSpecificNetwork(fname, 'air', date(1950, 1, 1), date(2016, 1, 1), None, None, None,
# cPickle.dump({'mean_phase_diff' : np.mean(phase_diffs, axis = 0).flatten(), # 'std_phase_diff' : np.std(phase_diffs, axis = 0, ddof = 1).flatten(), # 'var_phase_diff' : np.var(phase_diffs, axis = 0, ddof = 1).flatten()}, f, protocol = cPickle.HIGHEST_PROTOCOL) to_do = [['MIGAU', 8], ['MIGAU', 6]] 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(1958,1,1), date(2014,1,1), None, None, 0, 'monthly', anom = True) pool = Pool(WORKERS) net.wavelet(PERIOD, get_amplitude = False, pool = pool) print "wavelet on data done" pool.close() net.get_adjacency_matrix(net.phase, method = METHOD, pool = None, use_queue = True, num_workers = WORKERS) print "estimating adjacency matrix done" net.save_net('networks/NCEP-SATAsurface-phase-span-as-ERA-adjmat%s-scale%dyears.bin' % (METHOD, PERIOD), only_matrix = True) # print phase_diffs.shape # net.get_adjacency_matrix(phase_diffs, method = METHOD, pool = None, use_queue = True, num_workers = WORKERS) # net.save_net('networks/NCEP-ERA-phase-diff-adjmat%s-scale%dyears.bin' % (METHOD, PERIOD), only_matrix = True) # net.get_adjacency_matrix(net.phase, method = METHOD, pool = None, use_queue = True, num_workers = WORKERS) # print "estimating adjacency matrix done" # net.save_net('networks/ERA-SATAsurface-phase-adjmat%s-scale%dyears.bin' % (METHOD, PERIOD), only_matrix = True)
[-60, 0], [40, 100], level=0, dataset="NCEP", sampling="monthly", anom=False, ) surrs = SurrogateField() a = net.get_seasonality(detrend=True) surrs.copy_field(net) net.return_seasonality(a[0], a[1], a[2]) pool = Pool(20) net.wavelet(8, "y", cut=1, pool=pool) net.get_adjacency_matrix(net.phase, method="MIEQQ", num_workers=0, pool=pool, use_queue=False) pool.close() pool.join() data_adj_matrix = net.adjacency_matrix.copy() surrs_adj_matrices = [] for i in range(NUM_SURR): print("surr %d/%d computing..." % (i + 1, NUM_SURR)) pool = Pool(20) surrs.construct_fourier_surrogates(pool=pool) surrs.add_seasonality(a[0], a[1], a[2]) net.data = surrs.get_surr() net.wavelet(8, "y", cut=1, pool=pool)
for scale in SCALES: print("Computing networks using %s method..." % (method)) # phase if method in ['MIEQQ', 'MIGAU', 'MPC']: # net = ScaleSpecificNetwork(fname, 'air', date(1948,1,1), date(2016,1,1), None, None, level = 0, dataset = "NCEP", # sampling = 'monthly', anom = False) net = ScaleSpecificNetwork(fname, 't2m', date(1958,1,1), date(2014,1,1), None, None, level=None, pickled=True, sampling='monthly', anom=False) pool = Pool(NUM_WORKERS) # net.get_hilbert_phase_amp(period = 90, width = 12, pool = pool, cut = 1) net.wavelet(scale, period_unit='m', cut=2, pool=pool) pool.close() pool.join() net.get_adjacency_matrix(net.phase, method = method, pool = None, use_queue = True, num_workers = NUM_WORKERS) net.save_net('networks/ERA-SATsurface-scale%dmonths-phase-adjmat%s.bin' % (scale, method), only_matrix = True) # amplitude if method in ['MIEQQ', 'MIGAU', 'CORR']: # net = ScaleSpecificNetwork(fname, 'air', date(1948,1,1), date(2016,1,1), None, None, level = 0, dataset = "NCEP", # sampling = 'monthly', anom = False) net = ScaleSpecificNetwork(fname, 't2m', date(1958,1,1), date(2014,1,1), None, None, level=None, pickled=True, sampling='monthly', anom=False) pool = Pool(NUM_WORKERS) # net.get_hilbert_phase_amp(period = 90, width = 12, pool = pool, cut = 1) net.wavelet(scale, period_unit='m', cut=2, pool=pool) pool.close() pool.join() net.get_adjacency_matrix(net.amplitude, method = method, pool = None, use_queue = True, num_workers = NUM_WORKERS) net.save_net('networks/ERA-SATsurface-scale%dmonths-amplitude-adjmat%s.bin' % (scale, method), only_matrix = True)
fname = '/home/nikola/Work/phd/data/air.mon.mean.sig995.nc' # fname = "/Users/nikola/work-ui/data/air.mon.mean.sig995.nc" ## PHASE FLUCTUATIONS NETWORK L2 dist. print "Computing L2 distance..." net = ScaleSpecificNetwork(fname, 'air', date(1950,1,1), date(2016,1,1), None, None, None, 'monthly', anom = False) pool = Pool(20) net.wavelet(1, 'y', pool = pool, cut = 1) net.get_continuous_phase(pool = pool) print "wavelet done" net.get_phase_fluctuations(rewrite = True, pool = pool) print "fluctuations done" pool.close() pool.join() net.phase_fluctuations -= np.nanmean(net.phase_fluctuations, axis = 0) net.get_adjacency_matrix(net.phase_fluctuations, method = "L2", pool = None, use_queue = True, num_workers = 20) net.save_net('networks/NCEP-SATannual-phase-fluctuations-adjmatL2.bin', only_matrix = True) print "L2 done" ## PHASE FLUCTUATIONS NETWORK correlation print "Computing MI knn..." net = ScaleSpecificNetwork(fname, 'air', date(1950,1,1), date(2016,1,1), None, None, None, 'monthly', anom = False) pool = Pool(20) net.wavelet(1, 'y', pool = pool, cut = 1) net.get_continuous_phase(pool = pool) print "wavelet done" net.get_phase_fluctuations(rewrite = True, pool = pool) print "fluctuations done" pool.close() pool.join() net.get_adjacency_matrix(net.phase_fluctuations, method = "CORR", pool = None, use_queue = True, num_workers = 20)
None, level=0, dataset="NCEP", sampling='monthly', anom=False) surrs = SurrogateField() a = net.get_seasonality(detrend=True) surrs.copy_field(net) net.return_seasonality(a[0], a[1], a[2]) pool = Pool(20) net.wavelet(8, 'y', cut=1, pool=pool) net.get_adjacency_matrix(net.phase, method="MIEQQ", num_workers=20, pool=None, use_queue=True) pool.close() pool.join() data_adj_matrix = net.adjacency_matrix.copy() surrs_adj_matrices = [] for i in range(NUM_SURR): print("surr %d/%d computing..." % (i + 1, NUM_SURR)) pool = Pool(20) surrs.construct_fourier_surrogates(pool=pool) surrs.add_seasonality(a[0], a[1], a[2])
'/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=False, save_wavelet=True, pool=pool) print "wavelet on data done" pool.close() net.get_adjacency_matrix(net.wave, method=METHOD, pool=None, use_queue=True, num_workers=WORKERS) print "estimating adjacency matrix done" net.save_net('networks/NCEP-SATsurface-wave-adjmat%s-scale%dyears.bin' % (METHOD, PERIOD), only_matrix=True) print "computing SATA wavelet coherence..." to_do = [['WCOH', 4], ['WCOH', 6], ['WCOH', 8], ['WCOH', 11], ['WCOH', 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',
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)
'/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]