Example #1
0
corrSample = np.loadtxt('%s/corrSample%s_nSeeds%d_lagMax%dyr.txt' \
                        % (corrSamplePath, corrSamplePostfix, nSeeds, cfg.stat.lagMax))
lags = np.loadtxt('%s/lags%s_nSeeds%d_lagMax%dyr.txt' \
                  % (corrSamplePath, corrSamplePostfix, nSeeds, cfg.stat.lagMax))
powerSample = np.loadtxt('%s/powerSample%s_nSeeds%d_chunk%dyr.txt' \
                         % (corrSamplePath, corrSamplePostfix, nSeeds, cfg.stat.chunkWidth))
freq = np.loadtxt('%s/freq%s_nSeeds%d_chunk%dyr.txt' \
                  % (corrSamplePath, corrSamplePostfix, nSeeds, cfg.stat.chunkWidth))

angFreq = freq * 2*np.pi
cfg0 = ((f - (f * statDist).sum()) * statDist * (g - (g * statDist).sum())).sum()
powerSample /= 2 * np.pi * cfg0

# Reconstruct correlation and power spectrum
# Get normalized weights
weights = ergoPlot.getSpectralWeights(f, g, eigVecForward, eigVecBackward, statDist, skipMean=True)
# Remove components with heigh condition number
weights[eigenCondition > maxCondition] = 0.
eigenCondition[eigenCondition > maxCondition] = maxCondition
(corrRec, compCorrRec) = ergoPlot.spectralRecCorrelation(lags, f, g, eigValGen, weights,
                                                         statDist, skipMean=True, norm=True)
(powerRec, compPowerRec) = ergoPlot.spectralRecPower(angFreq, f, g, eigValGen, weights, statDist, norm=True)

# Plot correlation reconstruction
ergoPlot.plotRecCorrelation(lags, corrSample, corrRec, plotPositive=True,
                            ylabel=corrLabel)
plt.savefig('%s/spectrum/reconstruction/%sRec_lag%d_nev%d%s.%s'\
            % (cfg.general.plotDir, corrName, int(cfg.stat.lagMax),
               nev, postfix, ergoPlot.figFormat),
            dpi=ergoPlot.dpi, bbox_inches=ergoPlot.bbox_inches)
Example #2
0
lags = np.loadtxt('%s/lags%s_nSeeds%d_lagMax%dyr.txt' % (corrSamplePath, corrSamplePostfix, nSeeds, lagMax))
powerSample = np.loadtxt('%s/powerSample%s_nSeeds%d_chunk%dyr.txt' % (corrSamplePath, corrSamplePostfix, nSeeds, chunkWidth))
powerSampleSTD = np.loadtxt('%s/powerSampleSTD%s_nSeeds%d_chunk%dyr.txt' % (corrSamplePath, corrSamplePostfix, nSeeds, chunkWidth))
freq = np.loadtxt('%s/freq%s_nSeeds%d_chunk%dyr.txt' % (corrSamplePath, corrSamplePostfix, nSeeds, chunkWidth))

angFreq = freq * 2*np.pi
cfg0 = ((f - (f * statDist).sum()) * statDist * (g - (g * statDist).sum())).sum()
powerSample /= 2 * np.pi * cfg0
powerSampleSTD /= 2 * np.pi * cfg0

powerSampleDown = powerSample - powerSampleSTD / 2
powerSampleUp = powerSample + powerSampleSTD / 2

# Reconstruct correlation and power spectrum
# Get normalized weights
weights = ergoPlot.getSpectralWeights(f, g, eigVecForward, eigVecBackward, statDist, skipMean=True)
# Remove components with heigh condition number
weights[eigenCondition > 5] = 0.
(corrRec, compCorrRec) = ergoPlot.spectralRecCorrelation(lags, f, g, eigValGen, weights,
                                                         statDist, skipMean=True, norm=True)
(powerRec, compPowerRec) = ergoPlot.spectralRecPower(angFreq, f, g, eigValGen, weights, statDist, norm=True)

# Plot correlation reconstruction
ergoPlot.plotRecCorrelation(lags, corrSample, corrRec, plotPositive=True,
                            ylabel=corrLabel)
plt.savefig('%s/spectrum/reconstruction/%sRec_lag%d_nev%d%s.%s'\
            % (cfg.general.plotDir, corrName, int(lagMax),
               nev, postfix, ergoPlot.figFormat),
            dpi=ergoPlot.dpi, bbox_inches=ergoPlot.bbox_inches)

# PLot spectrum, powerSampledogram and spectral reconstruction
Example #3
0
    obsLabel = [r'$S_{x, x}$', r'$S_{x^2, x^2}$', r'$S_{x^3, x^3}$']
    g = f
    nObs = len(f)
    angFreq = np.linspace(ylim[0], ylim[1], 1000)
    weights = []
    power = []
    cPow = rcParams['axes.prop_cycle'].by_key()['color']
    while len(cPow) < nObs:
        cPow = np.concatenate((cPow, rcParams['axes.prop_cycle'].by_key()['color']))
    lsPow = ['-'] * nObs
    lwPow = [2] * nObs
    for obs in np.arange(nObs):
        # Get weights of the spectral projections of the observables
        # let the forward eigenvectors carry the measure.
        weightsObs = ergoPlot.getSpectralWeights(f[obs], g[obs],
                                                 eigVecForward[:, :nevRec],
                                                 eigVecBackward[:, :nevRec])
        weights.append(weightsObs)
        # Get power spectrum
        powerObs, powerCompObs = ergoPlot.spectralRecPower(angFreq, f[obs], g[obs],
                                                           eigValForward[:nevRec],
                                                           weights[obs], norm=True,
                                                           statDist=statDist)
        power.append(powerObs)

        
    # Calculate analytical eigenvalues
    if mu <= 0:
        eigValAnaPoint = (J + J.T) * mu \
                         + 1j * (J - J.T) * gam
    if mu > 0: