Exemplo n.º 1
0
#         with open("networks/NCEP-SATAsurface-autocoherence-phase-scale%dyears-avg-to-%.1f.bin" % (PERIOD, AVG), "wb") as f:
#             cPickle.dump({'autocoherence' : autocoherence, 'lats' : net.lats, 'lons' : net.lons}, f, protocol = cPickle.HIGHEST_PROTOCOL)

if not PLOT:
    ## autocoherence filtered data - SATA
    print "computing autocoherence for SATA filtered data"
    for PERIOD in periods:
        for AVG in avg_to:
            print("computing for %d year period and averaging up to %d" %
                  (PERIOD, 12 * AVG * PERIOD))
            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"
            autocoherence = np.zeros(net.get_spatial_dims())
            job_args = [(i, j, int(AVG * 12 * PERIOD), net.filtered_data[:, i,
                                                                         j])
                        for i in range(net.lats.shape[0])
                        for j in range(net.lons.shape[0])]
            job_result = pool.map(_get_autocoherence, job_args)
Exemplo n.º 2
0
import h5py
import numpy as np
import pyclits as clt
from scale_network import ScaleSpecificNetwork
import matplotlib.pyplot as plt
from datetime import date
plt.style.use('ipython')

net = ScaleSpecificNetwork(
    '/Users/nikola/work-ui/data/NCEP/air.mon.mean.levels.nc',
    'air',
    date(1950, 1, 1),
    date(2014, 1, 1),
    None,
    None,
    level=0,
    dataset="NCEP",
    sampling='monthly',
    anom=False)

t**s = ["NAO", "NINO3.4", "sunspot #", "PDO"]
with h5py.File("networks/phase_synch_eqq_bins=8_all_periods.h5") as hf:
    to_do_periods = np.arange(2, 15.5, 0.5)
    for period in to_do_periods:
        plt.figure(figsize=(15, 7))
        synch = hf['period_%.1fy' % (period)][:]
        for i, tit in zip(range(synch.shape[0]), t**s):
            plt.subplot(2, 2, i + 1)
            vmax, vmin = np.nanmax(synch), np.nanmin(synch)
            net.quick_render(field_to_plot=synch[i, ...],
                             tit=tit,
import numpy as np
from src.data_class import DataField
import csv
import matplotlib.pyplot as plt
import src.wavelet_analysis as wvlt

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",
Exemplo n.º 4
0
    return g.phase.copy()


WORKERS = 20
to_do_periods = [4, 6, 8, 11, 15]

for period in to_do_periods:
    print("computing phase conditioned on NAO")
    nao_phase = load_NAOindex_wavelet_phase(date(1950, 1, 1), date(2014, 1, 1),
                                            period, False)
    net = ScaleSpecificNetwork(
        '/home/nikola/Work/phd/data/air.mon.mean.levels.nc',
        'air',
        date(1950, 1, 1),
        date(2014, 1, 1),
        None,
        None,
        level=0,
        dataset="NCEP",
        sampling='monthly',
        anom=False)
    pool = Pool(WORKERS)
    net.wavelet(period, period_unit="y", pool=pool, cut=2)
    print("wavelet on data done")
    pool.close()
    pool.join()
    net.get_adjacency_matrix_conditioned(nao_phase,
                                         use_queue=True,
                                         num_workers=WORKERS)
    print("estimating adjacency matrix done")
    net.save_net('networks/NCEP-SAT%dy-phase-adjmatCMIEQQcondNAOphase.bin' %
Exemplo n.º 5
0
from pathos.multiprocessing import Pool
# import matplotlib.pyplot as plt
import src.wavelet_analysis as wvlt
import numpy as np
from src.surrogates import SurrogateField

NUM_SURR = 1000

# fname = "/Users/nikola/work-ui/data/NCEP/air.mon.mean.levels.nc"
fname = "/home/nikola/Work/phd/data/air.mon.mean.levels.nc"

net = ScaleSpecificNetwork(fname,
                           'air',
                           date(1948, 1, 1),
                           date(2016, 1, 1),
                           None,
                           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,
Exemplo n.º 6
0
from src.data_class import DataField
from src.surrogates import get_single_FT_surrogate
from scipy.stats import pearsonr
import cPickle

# path_to_data = "/Users/nikola/work-ui/data/"
path_to_data = "/home/nikola/Work/phd/data/"

NUM_SURR = 1000
NUM_WORKERS = 20

net = ScaleSpecificNetwork('%sair.mon.mean.levels.nc' % path_to_data,
                           'air',
                           date(1948, 1, 1),
                           date(2015, 1, 1),
                           None,
                           None,
                           0,
                           dataset="NCEP",
                           sampling='monthly',
                           anom=False)

pool = Pool(NUM_WORKERS)
net.wavelet(1, 'y', pool=pool, cut=1)
net.get_continuous_phase(pool=pool)
net.get_phase_fluctuations(rewrite=True, pool=pool)
pool.close()
pool.join()

nao = DataField()
raw = np.loadtxt("%sWeMO.monthly.1821-2013.txt" % (path_to_data))
raw = raw[:, 1:]
Exemplo n.º 7
0
# date(1958,1,1), date(2015,1,1), None, None, None, 'monthly', anom = False, pickled = True)

# net_surrs = ScaleSpecificNetwork('%sERAconcat.t2m.mon.means.1958-2014.bin' % path_to_data, 't2m',
#                        date(1958,1,1), date(2015,1,1), None, None, None, 'monthly', anom = False, pickled = True)

# net = ScaleSpecificNetwork('%s20CR/20CR.t2m.mon.nc' % path_to_data, 't2m',
# date(1949,1,1), date(2011,1,1), None, None, dataset = "ERA", sampling = 'monthly', anom = False)

# net_surrs = ScaleSpecificNetwork('%sair.mon.mean.levels.nc' % path_to_data, 'air',
# date(1949,1,1), date(2015,1,1), None, None, 0, dataset = "NCEP", sampling = 'monthly', anom = False)

net = ScaleSpecificNetwork('%sECAD.tg.daily.nc' % path_to_data,
                           'tg',
                           date(1950, 1, 1),
                           date(2015, 1, 1),
                           None,
                           None,
                           None,
                           dataset='ECA-reanalysis',
                           anom=False)
net.get_monthly_data()
print net.data.shape
print net.get_date_from_ndx(0), net.get_date_from_ndx(-1)

# surr_field = SurrogateField()
# a = net.get_seasonality(detrend = True)
# surr_field.copy_field(net)
# net.return_seasonality(a[0], a[1], a[2])


def _hilbert_ssa(args):