コード例 #1
0
def Q(malha, field):
    N = len(field)
    Qr = zeros([N, N])

    prog = progress.progressBar(0, N * N, 50)
    print prog, "\r",
    for i in range(N):
        for k in range(N):
            if i <= k:
                Qr[i, k] = innerproduct(malha, field[i], field[k])
            else:
                Qr[i, k] = Qr[k, i]
        prog.updateAmount(i * N + N)
        print prog, "\r",
        sys.stdout.flush()
    return Qr
コード例 #2
0
def RMS(malha, field):
    N = len(field)
    RMS = fields(len(malha.triangles))
    mean = average(malha, field)
    kk = 1.0 / sqrt(N)
    prog = progress.progressBar(0, N, 50)
    print prog, "\r",
    for i in range(N):
        for j in range(len(malha.triangles)):
            RMS.uvw[j, 0] = RMS.uvw[j, 0] + (field[i].uvw[j, 0] - mean.uvw[j, 0]) ** 2
            RMS.uvw[j, 1] = RMS.uvw[j, 1] + (field[i].uvw[j, 1] - mean.uvw[j, 1]) ** 2
            RMS.uvw[j, 2] = RMS.uvw[j, 2] + (field[i].uvw[j, 2] - mean.uvw[j, 2]) ** 2
        prog.updateAmount(i * N + N)
        print prog, "\r",
        sys.stdout.flush()

    for j in range(len(malha.triangles)):
        RMS.uvw[j, 0] = kk * sqrt(RMS.uvw[j, 0])
        RMS.uvw[j, 1] = kk * sqrt(RMS.uvw[j, 1])
        RMS.uvw[j, 2] = kk * sqrt(RMS.uvw[j, 2])

    return RMS, innerproduct(malha, RMS, RMS)
コード例 #3
0
def main(B, N, inputdir, outputdir):
    # -------------------------------
    # SYGMA POD
    # -------------------------------
    print ("# SYGMA POD RC1")
    # -------------------------------
    # Reading mesh
    # -------------------------------
    print "\nCleaning output dir: \t", outputdir
    print "\nOpening input dir: \t", inputdir
    os.system("rm " + outputdir + "*")
    f = loadtxt(inputdir + "/Export000.dat", skiprows=4)
    malha = grid(f, B)
    field = []
    KE = []
    # -------------------------------
    # Interpolating each field to the created mesh
    # -------------------------------
    print "\nReading and interpolating each field:"
    prog = progress.progressBar(0, N, 50)
    for i in range(N):
        if i < 10:
            file = inputdir + "Export00" + str(i) + ".dat"
        elif i >= 10:
            file = inputdir + "Export0" + str(i) + ".dat"

        f = loadtxt(file, skiprows=4)
        xr = f[:, 0].copy() * 1e-3
        yr = f[:, 1].copy() * 1e-3
        r = (xr ** 2 + yr ** 2) ** 0.5
        data = []
        for k in range(len(xr)):
            if r[k] < 0.5 * B:
                data.append(f[k, :])
        data = array(data)
        field.append(fields(len(malha.triangles)))
        itpu = malha.mesh.linear_interpolator(data[:, 3])
        itpv = malha.mesh.linear_interpolator(data[:, 4])
        itpw = malha.mesh.linear_interpolator(data[:, 5])

        # 		print 'Field:\t', i
        for j in range(len(malha.triangles)):
            x = malha.centroids[j, 0]
            y = malha.centroids[j, 1]
            field[i].uvw[j, 0] = itpu.planes[j, 0] * x + itpu.planes[j, 1] * y + itpu.planes[j, 2]
            field[i].uvw[j, 1] = itpv.planes[j, 0] * x + itpv.planes[j, 1] * y + itpv.planes[j, 2]
            field[i].uvw[j, 2] = itpw.planes[j, 0] * x + itpw.planes[j, 1] * y + itpw.planes[j, 2]

        prog.updateAmount(i + 1)
        print prog, "\r",
        sys.stdout.flush()
        KE.append(innerproduct(malha, field[i], field[i]))

    print "\n Computing covariance matrix:"
    COV = Q(malha, field)
    print "\n Computing eigenvalues. Printing energy fraction of each mode: \n"
    w, v = eig(COV)
    ind = w.argsort()
    frac = w[ind] / sum(w)
    savetxt(outputdir + "../" + "eigenvalues.dat", w)
    savetxt(outputdir + "../" + "energy_fraction.dat", frac)
    KE = array(KE)
    TKE = sum(KE)

    # 	spectrum=fft(KE)
    print frac[:]
    print "\n kinetic energy (eigenvalue) [J/m/kg] =\t\t", sum(w)
    print " kinetic energy (flow integral) [J/m/kg] =\t", TKE
    print "\n Writing POD modes to files."
    PODmodes(outputdir, malha, B, field, v, w, 0.95)
コード例 #4
0
ファイル: aviToWav.py プロジェクト: Becktor/speech
        try:
            preProcess.process(newpath + str(sample_rates[k]) + "_" + nName,
                               time,
                               newpath + str(sample_rates[k]) + "_" + nName)
        except:
            pass


if __name__ == "__main__":
    createFolder("enfDB_Audio")
    path = '/home/Jobe/Git/speech/'
    feeling = ['anger', 'disgust', 'fear', 'happiness', 'sadness', 'surprise']
    sentence = range(1, 6)
    subject = range(1, 42)
    max = 42 * 6 * 6
    pBar = progress.progressBar(max)
    devnull = open(os.devnull, 'w')
    sample_rate = 8000
    cntr = 1
    for sub in subject:
        cntr += 1
        name = 's' + str(sub)
        tmpAudio = 'enfDB_Audio/subject ' + str(sub)
        tmpVideo = 'enfDB/subject ' + str(sub)
        subPathAudio = path + tmpAudio
        subPathVideo = path + tmpVideo
        wav_length = 3
        createFolder(subPathAudio)
        for feel in feeling:
            cntr += 1
            nameF = name + '_' + feel[:2]
コード例 #5
0
# coding: utf-8
from time import sleep, time

import pylab as p

import tti
import Tektronix
import saving
import progress

loader = saving.loader(quiet=True)
siggen = tti.TG5011()
scope = Tektronix.DPO2024B()
pbar = progress.progressBar()

scope.write("ACQUIRE:STATE STOP")
scope.write("ACQUIRE:STOPAFTER SEQuence")

amp = 0.1
siggen.amp(amp)
fresponce = []
start = 300000
end = 500
freqRange = p.arange(start, end, -500)
starttime = time()
siggen.on()
for i in freqRange:
    pbar.simpleBar(int(100 * end / i), starttime)
    siggen.freq(i)
    #    scope.write("HORIZONTAL:SCALE %f" %(1./i))
    scope.waitOPC()