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) # PLot spectrum, powerSampledogram and spectral reconstruction msize = np.zeros((weights.shape[0])) msize[weights.real > 0] = np.log(weights[weights.real > 0].real) msize[weights.real > 0] = (msize[weights.real > 0] + 15) * 10 # msize[weights.real > 0] = (msize[weights.real > 0] + 6) * 3 msize[msize < 0] = 0.
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 zmin = cfg.stat.yminPower zmax = cfg.stat.ymaxPower # PLot spectrum, powerSampledogram and spectral reconstruction msizeWeight = np.zeros((weights.shape[0])) msizeWeight[weights.real > 0] = np.log(weights[weights.real > 0].real)
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: eigValAnaPoint = -(J + J.T + 2) * mu \ - 1j * (J - J.T) * gam D = eps**2 * (1 + beta**2) / (2 * mu) eigValAnaOrbit = (-I**2 * D + 1j * I * omega \ - 2 * mu * J).flatten()