Esempio n. 1
0
    # Get grid points and steps
    x = []
    dx = np.empty((dim,))
    nx = np.ones((dim,), dtype=int) * nx0
    for d in np.arange(dim):
        x.append(np.linspace(-xlim[d], xlim[d], nx[d]))
        dx[d] = x[d][1] - x[d][0]
    N = np.prod(nx)
    idx = np.indices(nx).reshape(dim, -1)
    X, Y = np.meshgrid(*x, indexing='xy') # ! Different that for numerical
    # -> Need transpose vectors !

    # Read eigenvalues
    print 'Reading backward eigenvalues'
    eigValBackward = np.empty((nev,), dtype=complex)
    ergoPlot.loadtxt_complex('%s/eigValBackward%s.txt' \
                             % (resDir, postfix), eigValBackward)
    isortBackward = np.argsort(-eigValBackward.real)
    eigValBackward = eigValBackward[isortBackward]

    # Read eigenvectors
    print 'Reading backward eigenvectors'
    eigVecBackward = np.empty((nx0**2, nev), dtype=complex)
    ergoPlot.loadtxt_complex('%s/eigVecBackward%s.txt' % (resDir, postfix),
                             eigVecBackward)
    eigVecBackward = eigVecBackward[:, isortBackward]

    # Convert second eigenvectors to phase and amplitude
    if eigValBackward[1].imag > 0:
        eigVec2 = eigVecBackward[:, 1]
    else:
        eigVec2 = eigVecBackward[:, 2]
Esempio n. 2
0
        meanPoints = (points * rho0_tile).sum(1)
        stdPoints = np.sqrt(((points - np.tile(meanPoints, (N, 1)).T)**2 * rho0_tile).sum(1))
        #print 'Mean points = ', meanPoints
        #print 'Std points = ', stdPoints

        print 'Saving eigenvalues'
        np.savetxt('../results/numericalFP/w_hopf%s.txt' % postfix, w)
        np.savetxt('../results/numericalFP/ev_hopf%s.txt' % postfix, v)
        np.savetxt('../results/numericalFP/statDist_hopf%s.txt' % postfix, rho0)
                   

    else:
        print 'Reading eigenvalues'
        srcFileEigVal = '../results/numericalFP/w_hopf%s.txt' % postfix
        w = np.empty((nev,), dtype=complex)
        ergoPlot.loadtxt_complex(srcFileEigVal, w)
        srcFileEigVec = '../results/numericalFP/ev_hopf%s.txt' % postfix
        print 'Reading eigenvectors'
        v = np.empty((N, nev), dtype=complex)
        ergoPlot.loadtxt_complex(srcFileEigVec, v)
        rho0 = np.loadtxt('../results/numericalFP/statDist_hopf%s.txt' % postfix)
                
    print 'Plotting'
    fig = plt.figure()
    #fig.set_visible(False)
    ax = fig.add_subplot(111)
    ax.scatter(w.real, w.imag, c='b', edgecolors='face')
    ax.set_xlim(-30, 0.1)
    ax.set_ylim(-10, 10)
    ax.set_xlabel(r'$\Re(\lambda_1)$', fontsize=ergoPlot.fs_latex)
    ax.set_ylabel(r'$\Im(\lambda_1)$', fontsize=ergoPlot.fs_latex)
Esempio n. 3
0
    mu = muRng[imu]
    mu += 1.e-8
    if mu < 0:
        signMu = 'm'
    else:
        signMu = 'p'
    for ieps in np.arange(epsRng.shape[0]):
        eps = epsRng[ieps]
        postfix = '_%s_mu%s%02d_beta%s%03d_eps%03d_nx%d_nSTD%d_nev%d' \
                  % (model, signMu, int(round(np.abs(mu) * 10)),
                     signBeta, int(round(np.abs(beta) * 100)), int(round(eps * 100)),
                     nx0, nSTD, nev)

        # Read eigenvalues
        eigValii = np.empty((nev,), dtype=complex)
        ergoPlot.loadtxt_complex('%s/eigValForward%s.txt' \
                                 % (resDir, postfix), eigValii)
        isort = np.argsort(-eigValii.real)
        eigValii = eigValii[isort]
        eigVal[ieps, imu] = eigValii

# Comparison with analytics of real part of the second eigenvalue versus the noise
fig = plt.figure()
ax = fig.add_subplot(111)
xplot = np.linspace(0., epsRng[-1], 1000)
XP = np.matrix(xplot).T
evMin = []
muLineStyle = ['-', '--']
muMarker = ['x', '+']
muMarkerSize = [6, 9]
lw = 2
colors = rcParams['axes.prop_cycle'].by_key()['color']
Esempio n. 4
0
yticks = np.concatenate((yticksNeg, yticksPos))
zticks = np.logspace(np.log10(zlimEig[0]), np.log10(zlimEig[1]),
                    int(np.round(np.log10(zlimEig[1]/zlimEig[0]) + 1)))
zticks = np.logspace(np.log10(zlimEig[0]), np.log10(zlimEig[1]),
                     int(np.round(np.log10(zlimEig[1]/zlimEig[0])/2 + 1)))

maxCondition = 10
# maxCondition = 10

Analytical eigenvalues
if cfg.model.delaysDays[1] == 90:
    eigAna = []
    eigDrift = np.empty((2,), dtype=complex)
    stabFile = '../../Transfer/transferSDDE/results/stability/stabilitySpectrum_Battisti1989_Zero_tau1%d.txt' \
               % (int(cfg.model.delaysDays[1] * 1. / 365 * 1000),)
    ergoPlot.loadtxt_complex(stabFile, eigDrift)
    for ii in np.arange(20):
        for jj in np.arange(20):
            eigAna.append(eigDrift[0] * ii + eigDrift[1] * jj)
    eigAna = np.array(eigAna, dtype=complex)
    eigAna = eigAna[np.argsort(-np.abs(eigAna))]

# # Read grid
coord = ergoPlot.readGrid(gridFile, dimObs)
if dimObs == 1:
    X = coord[0]
elif dimObs == 2:
    X, Y = np.meshgrid(coord[0], coord[1])
    coord = (X.flatten(), Y.flatten())
elif dimObs == 3:
    X, Y, Z = np.meshgrid(coord[0], coord[1], coord[2], indexing='ij')