Example #1
0
nt = observable1.shape[0]
ntWindow = int(cfg.stat.chunkWidth * sampFreq)
time = np.arange(0, nt, cfg.simulation.printStep)


# Get ccf averaged over seeds (should add weights based on length)
print 'Calculating correlation function...'
ccf = ergoStat.ccf(observable1, observable2, lagMax=cfg.stat.lagMax,
                   sampFreq=sampFreq)


# Get perio averaged over seeds (should add weights based on length)
print 'Calculating periodogram function...'
(freq, perio, perioSTD) \
    = ergoStat.getPerio(observable1, observable2,
                        sampFreq=sampFreq, chunkWidth=cfg.stat.chunkWidth,
                        norm=False)


# Save results
np.savetxt('%s/correlation/%s_lag%d%s.txt'\
           % (cfg.general.resDir, corrName, int(cfg.stat.lagMax),
              srcPostfix), ccf)
np.savetxt('%s/correlation/lags_lag%d%s.txt'\
           % (cfg.general.resDir, int(cfg.stat.lagMax),
              srcPostfix), lags)
np.savetxt('%s/power/%s_chunk%d%s.txt'\
           % (cfg.general.resDir, powerName, int(cfg.stat.chunkWidth),
              srcPostfix), perio)
np.savetxt('%s/power/%sSTD_chunk%d%s.txt' \
           % (cfg.general.resDir, powerName, int(cfg.stat.chunkWidth),
Example #2
0
                               sampFreq=sampFreq,
                               norm=False)

    # Get common frequencies
    if s == 0:
        nChunks = int(nt / (cfg.stat.chunkWidth * sampFreq))
        freq = ergoStat.getFreqPow2(cfg.stat.chunkWidth, sampFreq=sampFreq)
        nfft = freq.shape[0]
        powerSample = np.zeros((nfft, ))
        powerSampleSTD = np.zeros((nfft, ))

    # Get powerSample averaged over seeds
    # (should add weights based on length)
    (freq, powerSampleSeed, powerSampleSTDSeed) \
        = ergoStat.getPerio(observable1, observable2,
                            freq=freq, sampFreq=sampFreq,
                            chunkWidth=cfg.stat.chunkWidth, norm=False)
    powerSample += powerSampleSeed
    powerSampleSTD += powerSampleSTDSeed**2 * nChunks

corrSample /= nSeeds
powerSample /= nSeeds
powerSampleSTD = np.sqrt(powerSampleSTD / (nSeeds * nChunks))
if cfg.stat.norm:
    cov = corrSample[(lags.shape[0] - 1) / 2]
    corrSample /= cov
    powerSample /= cov
    powerSampleSTD /= cov

# Save results
np.savetxt('%s/correlation/corrSample%s_lagMax%dyr.txt'\
Example #3
0
            observable2 = observable2[:nt]

            # Get corrSample averaged over seeds (should add weights based on length)
            corrSample += ergoStat.ccf(observable1, observable2, lagMax=cfg.stat.lagMax, sampFreq=sampFreq)

            # Get common frequencies
            if s == 0:
                nChunks = int(nt / (cfg.stat.chunkWidth * sampFreq))
                freq = ergoStat.getFreqPow2(cfg.stat.chunkWidth, sampFreq=sampFreq)
                nfft = freq.shape[0]
                powerSample = np.zeros((nfft,))
                powerSampleSTD = np.zeros((nfft,))

            # Get powerSample averaged over seeds (should add weights based on length)
            (freq, powerSampleSeed, powerSampleSTDSeed) = ergoStat.getPerio(
                observable1, observable2, freq=freq, sampFreq=sampFreq, chunkWidth=cfg.stat.chunkWidth, norm=False
            )
            powerSample += powerSampleSeed
            powerSampleSTD += powerSampleSTDSeed ** 2 * nChunks

        corrSample /= nSeeds
        powerSample /= nSeeds
        powerSampleSTD = np.sqrt(powerSampleSTD / (nSeeds * nChunks))

        # Save results
        np.savetxt(
            "%s/%s/corrSample%s_nSeeds%d_lagMax%dyr.txt"
            % (cfg.general.resDir, outDir, postfix, nSeeds, cfg.stat.lagMax),
            corrSample,
        )
        np.savetxt(