예제 #1
0
def make_model_geofield(S, ts):

    M, N = S.shape
    T = ts.shape[0]

    gf = GeoField()
    gf.lats = np.arange(M)
    gf.lons = np.arange(N)
    gf.tm = np.arange(T)
    gf.d = np.reshape(ts, [T, M, N])

    return gf
def make_model_geofield(S, ts):

    M, N = S.shape
    T = ts.shape[0]

    gf = GeoField()
    gf.lats = np.arange(M)
    gf.lons = np.arange(N)
    gf.tm = np.arange(T)
    gf.d = np.reshape(ts, [T, M, N])

    return gf
예제 #3
0
plt.figure()
plt.imshow(v.A, interpolation='nearest')
plt.colorbar()
plt.title('AR structural')

plt.figure()
plt.plot(ts)
plt.title('Simulated time series')

C = np.corrcoef(ts, None, rowvar=0)

plt.figure()
plt.imshow(C, interpolation='nearest')
plt.title('Correlation matrix')
plt.colorbar()

gf = GeoField()
gf.lons = np.arange(S.shape[1])
gf.lats = np.arange(S.shape[0])
gf.tm = np.arange(768)
gf.d = np.reshape(ts, [768, S.shape[0], S.shape[1]])

plt.figure()
plt.plot(ts2[:, 0])
plt.plot(gf.d[:, 0, 0])

with open('data/test_gf.bin', 'w') as f:
    cPickle.dump(gf, f)

plt.show()
예제 #4
0
            lon1 = (lon + 1) % num_lons
            cc = np.corrcoef(gf.d[:, lat, lon], gf.d[:, lat, lon1], rowvar = 0)[0,1]
            y[pt_1, pt_2] = 1.0 - cc*cc
            dfC[0, 2*lat, lon] = cc

            pt_2 = (lat + 1) * num_lons + lon
            cc = np.corrcoef(gf.d[:, lat, lon], gf.d[:, lat+1, lon], rowvar = 0)[0,1]
            y[pt_1, pt_2] = 1.0 - cc*cc
            dfC[0, 2*lat+1, lon] = cc
            
    ndx = np.triu_indices(num_gpoints, k = 1)
    ytri = y[ndx]
            
    print("Plotting ...")
    gfC = GeoField()
    gfC.d = dfC
    gfC.tm = np.array([0])
    gfC.lons = gf.lons
    gfC.lats = np.array(Clats)
    
    plt.figure()
    plt.hist(dfC.flatten(), bins = 50)
    plt.title('Histogram of neighbor correlations')
    
    plt.figure()
    plt.imshow(dfC[0, :, :])
    plt.colorbar()
    plt.title('Image show of the correlation lattice')
    
    plt.figure()
    plt.imshow(dfC[0, 0::2, :])
예제 #5
0
plt.figure()
plt.imshow(v.A, interpolation = 'nearest')
plt.colorbar()
plt.title('AR structural')

plt.figure()
plt.plot(ts)
plt.title('Simulated time series')

C = np.corrcoef(ts, None, rowvar = 0)

plt.figure()
plt.imshow(C, interpolation = 'nearest')
plt.title('Correlation matrix')
plt.colorbar()

gf = GeoField()
gf.lons = np.arange(S.shape[1])
gf.lats = np.arange(S.shape[0])
gf.tm = np.arange(768)
gf.d = np.reshape(ts, [768, S.shape[0], S.shape[1]])

plt.figure()
plt.plot(ts2[:,0])
plt.plot(gf.d[:, 0, 0])

with open('data/test_gf.bin', 'w') as f:
    cPickle.dump(gf, f)

plt.show()