Example #1
0
def main():
	
	#print "what is start time?, 0"
	start = 0 # input()
	#print "what is end time?, 1"
	end = 1 # input()
	#print "what is slow time?, .01"
	slow = 0.01 # input()
	#print "what is fast time?, .001"
	fast = 0.001 # input()
	#print "what is sample rate?, 1, 6"
	SampleRateRedux = 1 # input()    

	cfd = os.path.abspath(__file__)	# gets the path to this current file
	baseP= cfd 
	basePa = str(baseP.split('\\')[0:-1])# removes the last folder of the path
	basePat = '\\'.join(baseP.split('\\')[0:-1])
	basepath = os.path.join(basePat,"DataJustTwo")
	print "  "
	print "the data is taken from:"
	print basepath
	
	os.chdir(basepath)  
	fillist =  os.listdir(basepath) 
	
	nbr = len([name for name in os.listdir(basepath) if os.path.isfile(os.path.join(basepath,name))]) 
	print "  "
	print 'the files in the folder are:'
	print fillist
	print "  "
	print "start time: {0}".format(start)
	print "end time: {0}".format(end)
	print "slow time: {0}".format(slow)
	print "fast time: {0}".format(fast)
	print "sample rate redux: {0}".format(SampleRateRedux)
	
	fafotr1 = {}
	ttMat, fftt, fafotr1['fftt1'] = syntheticAperture(start, end, slow, fast, (read(fillist[0])), SampleRateRedux)
	ttMat, fftt, fafotr1['fftt2'] = syntheticAperture(start, end, slow, fast, (read(fillist[1])), SampleRateRedux)

	print '  '
	print "the number of files in the full directory is: {0}".format(nbr)
	print 'the first file : {0}'.format(fillist[0])
	print 'the the second file: {0}'.format(fillist[1])

	row1 = fafotr1['fftt1'].shape[0] 
	col1 = fafotr1['fftt1'].shape[1]  
	
	energyMat = np.zeros((row1,col1), dtype=complex)
	for i in range(0, row1):	
		for j in range(0, col1):  
			mat1 = fafotr1['fftt1'] 
			mat2 = fafotr1['fftt2'] 
			energyMat[i,j] = 20*np.abs((np.log10(np.linalg.norm(mat1[i,j]))-np.log10(np.linalg.norm(mat2[i,j]))))
	eAvgMatn = np.average(energyMat) 
	print '  '
	print 'the energy difference is:'
	print eAvgMatn
def compareAperture(start, end, slow, fast, SampleRateRedux, sound1, sound2):

    cc1, fftt1, fftlog1 = syntheticAperture(start, end, slow, fast, sound1,
                                            SampleRateRedux)
    cc2, fftt2, fftlog2 = syntheticAperture(start, end, slow, fast, sound2,
                                            SampleRateRedux)

    row1 = fftt1.shape[0]
    col1 = fftt1.shape[1]
    row2 = fftt2.shape[0]
    col2 = fftt2.shape[1]

    energyMat = np.zeros((row1, col1), dtype=complex)
    for i in range(0, row1):
        for j in range(0, col1):
            energyMat[i, j] = 20 * np.abs(
                (np.log10(np.linalg.norm(fftt1[i, j])) -
                 np.log10(np.linalg.norm(fftt2[i, j]))))
    energyAvg = np.average(energyMat)
    return energyMat, energyAvg
Example #3
0
def main():

        #"what is start time?, 0"
        start = 0
        #"what is end time?, 1"
        end = 1
        #"what is slow time?, .01"
        slow = 0.002 
        #"what is fast time?, .001"
        fast = 0.007 
        #"what is sample rate?, 1"
        SampleRateRedux = 1
        #"what is the pipe?, 01, 02, 03 , ... (H=01, S=02, ...)"
        pipe = 1
        #"what is the take?, 1, 2, 3, 4, 5, 6, 7 "
        inital = 1
        #"start Mic?, 1, 2, 3, 4, 5, 6"
        startPos = 1
        #"end Mic?, 1, 2, 3, 4, 5, 6"
        endPos = 6 #5

        cfd = os.path.abspath(__file__) # gets the path to this current file
        #basepath = '/media/TerraSAR-X/Acoustics/data/20171115_cropped_NNC_R'
        basepath = '/media/TerraSAR-X/Acoustics/data/20171115_cropped_NNC_JPI1'
        print "the data is taken from :"
        print basepath

        os.chdir(basepath)  
        fillist =  os.listdir(basepath)

        fillist.sort() 

        nbr = len([name for name in os.listdir(basepath) if os.path.isfile(os.path.join(basepath,name))])

        rounds = {} #creates dictionary segmented by rounds (takes)
        for x in range(1,9):
                rounds['ta{0}'.format(x)]=[k for k in fillist if 'ta{0}'.format(x) in k]

        print ' '
        print 'rounds (takes):'
        print rounds
        sub1 = rounds['ta{0}'.format(inital)] 
        print 'sub1 (initial take)'
        print sub1
        print '  '

        pipes1 = {} #creates dictionary of take 1 segmented by pipes (takes)
        for x in range(1,9):
                pipes1['pi{0}'.format(x)]=[k for k in sub1 if 'pi{0}'.format(x) in k]
        print 'pipes1:'
        print pipes1
        print '  '
        print 'the selected pipe from take 1 is:'
        print pipes1['pi{0}'.format(pipe)]
        sub11 = pipes1['pi{0}'.format(pipe)]
        print '  '
        print '(sub11) dictionary where wich specific take and pipe'
        print sub11
        print 'sub11[0]'
        print sub11[0]
        print 'sub11[1]'
        print sub11[1]

        lfile1 = {}
        for k in range(startPos-1, endPos):
                lfile1['log{0}'.format(k)] = read(sub11[k])
        print 'lfile1:'
        print lfile1

        fafotr1 = {}
        for o in range(startPos-1, endPos):
                ttMat, fftt, fafotr1['fftt{0}'.format(o)] = syntheticAperture(start, end, slow, fast, lfile1['log{0}'.format(o)], SampleRateRedux)

        print '  '
        print "the number of files in the full directory is: {0}".format(nbr)
        print '  '
        print 'the names of files in full directory are:'
        print fillist
        print '  '
        print 'the files in inital round (take) are: {0}'.format(sub1)
        print '  '
        print 'energy difference between microphones for take {0}'.format(inital)
        print '  '
        print 'start: {0}'.format(start)
        print 'end: {0}'.format(end)
        print 'slow: {0}'.format(slow)
        print 'fast: {0}'.format(fast)
        print 'SampleRateRedux: {0}'.format(SampleRateRedux)
        print 'pipe: {0}'.format(pipe)
        print 'take: {0}'.format(inital)
        print 'start microphone: {0}'.format(startPos)
        print 'end microphone: {0}'.format(endPos)
        print '  '
        print "fafotr1['fftt1']"
        print fafotr1['fftt1']
        #print 'the files in other round (take) are: {0}'.format(sub2)

        row1 = fafotr1['fftt{0}'.format(startPos)].shape[0]
        col1 = fafotr1['fftt{0}'.format(startPos)].shape[1]

        energyMat = np.zeros((row1,col1), dtype=complex)
        eAvgMat = np.zeros((endPos-startPos+1, endPos-startPos+1), dtype=complex)
        for q in range(0, endPos-startPos+1): #for q in range(1, endPos-startPos+1):
                for p in range(0, endPos-startPos+1): #for p in range(1, endPos-startPos+1):
                        for i in range(0, row1):        #(0, row1):   (startPos, endPos):
                                for j in range(0, col1):  #(0, col1): (startPos, endPos):
                                        mat1 = fafotr1['fftt{0}'.format(q)] # mat1 = fafotr1[inital]
                                        mat2 = fafotr1['fftt{0}'.format(p)] # mat2 = fafotr2[inital]
                                        energyMat[i,j] = 20*np.abs((np.log10(np.linalg.norm(mat1[i,j]))-np.log10(np.linalg.norm(mat2[i,j]))))
                        eAvgMat[q,p] = np.average(energyMat)
        print "eAvgMat"
        print eAvgMat
        im = plt.imshow(abs(eAvgMat), interpolation='none', cmap=cm.coolwarm)
        plt.clim(0,4)
        plt.suptitle('ener diff b/t microphones for take{0}'.format(inital), fontsize=15)
        plt.colorbar(im, cmap=cm.hot)
        plt.show()
Example #4
0
def main():

    #"what is start time?"
    start = 0
    #"what is end time?"
    end = 2
    #"what is slow time?, .01"
    slow = 0.002  #0.01 #
    #"what is fast time?, .001"
    fast = 0.007  #0.001 #
    #"what is sample rate?, 1"
    SampleRateRedux = 1
    #"what is the pipe?, 01, 02, 03 , ... (H=01, S=02, ...)"
    pipe = 1
    #"what Mic?, 1, 2, 3, 4, 5, 6 "
    inital = 3
    #"start Take?, 1, 2, 3, 4, 5, 6, 7"
    startPos = 1
    #"end Take?, 1, 2, 3, 4, 5, 6, 7"
    endPos = 7

    cfd = os.path.abspath(__file__)
    #basepath = '/media/TerraSAR-X/Acoustics/data/20171115_cropped_NNC_R'
    basepath = '/media/TerraSAR-X/Acoustics/data/20171115_cropped_NNC_JPI1'
    print "the data is taken from :"
    print basepath

    os.chdir(basepath)
    fillist = os.listdir(basepath)
    fillist.sort()

    nbr = len([
        name for name in os.listdir(basepath)
        if os.path.isfile(os.path.join(basepath, name))
    ])

    rounds = {}  #creates dictionary segmented by mic
    for x in range(1, 9):
        rounds['mi{0}'.format(x)] = [
            k for k in fillist if 'mi{0}'.format(x) in k
        ]

    sub1 = rounds['mi{0}'.format(inital)]
    print sub1

    pipes1 = {}  #creates dictionary of take 1 segmented by pipes (takes)
    for x in range(1, 9):
        pipes1['pi{0}'.format(x)] = [k for k in sub1 if 'pi{0}'.format(x) in k]

    print pipes1['pi{0}'.format(pipe)]
    sub11 = pipes1['pi{0}'.format(pipe)]

    lfile1 = {}
    for k in range(startPos - 1, endPos):
        lfile1['log{0}'.format(k)] = read(sub11[k])

    fafotr1 = {}
    for o in range(startPos - 1, endPos):
        ttMat, fftt, fafotr1['fftt{0}'.format(o)] = syntheticAperture(
            start, end, slow, fast, lfile1['log{0}'.format(o)],
            SampleRateRedux)

    print '  '
    print "the number of files in the full directory is: {0}".format(nbr)
    print 'energy difference between takes for microphone {0}'.format(inital)
    print '  '
    print 'start: {0}'.format(start)
    print 'end: {0}'.format(end)
    print 'slow: {0}'.format(slow)
    print 'fast: {0}'.format(fast)
    print 'SampleRateRedux: {0}'.format(SampleRateRedux)
    print 'pipe: {0}'.format(pipe)
    print 'microphone: {0}'.format(inital)
    print 'start take: {0}'.format(startPos)
    print 'end take: {0}'.format(endPos)
    print '  '

    row1 = fafotr1['fftt{0}'.format(startPos)].shape[0]
    col1 = fafotr1['fftt{0}'.format(startPos)].shape[1]

    energyMat = np.zeros((row1, col1), dtype=complex)
    eAvgMat = np.zeros((endPos - startPos + 1, endPos - startPos + 1),
                       dtype=complex)
    for q in range(0, endPos - startPos + 1):
        for p in range(0, endPos - startPos + 1):
            for i in range(0, row1):
                for j in range(0, col1):
                    mat1 = fafotr1['fftt{0}'.format(q)]
                    mat2 = fafotr1['fftt{0}'.format(p)]
                    energyMat[i, j] = 20 * np.abs(
                        (np.log10(np.linalg.norm(mat1[i, j])) -
                         np.log10(np.linalg.norm(mat2[i, j]))))
            eAvgMat[q, p] = np.average(energyMat)
    print eAvgMat
    im = plt.imshow(abs(eAvgMat), interpolation='none', cmap=cm.coolwarm)
    plt.clim(0, 4)
    plt.suptitle('ner diff b/t takes for microphone {0}'.format(inital),
                 fontsize=15)
    plt.colorbar(im, cmap=cm.hot)
    plt.show()