Example #1
0
    timestart = time.time()
    F = fp.loadfile_frequency('frequency.txt')
    files = glob.glob('*.txt')
    files.sort(key=os.path.getmtime)
    files.remove('frequency.txt')
    bar = Bar('Processing', max=len(files) * 100)
    iteration = 0
    with open('data.csv', 'a') as data_file:
        data_file.write(
            'Timestamp,Delay1[m],Delay1_amplitude[dB],Delay2[m],Delay2_amplitude[dB]\n'
        )

    for filename in files:
        #print 'File %i out of %i being processed...' % (iteration+1,len(files))
        timestamps_temp, temp_sdata = fp.loadfile_multisweep(filename)
        heights1 = []
        heights2 = []
        loop_timestart = time.time()
        for n, i in enumerate(temp_sdata):
            delay1, delay2, height1, height2 = td.transform(
                F, i, verbose=0, overs=oversampling_factor)
            heights1.append(height1)
            heights2.append(height2)
            #sys.stdout.write('.')
            #sys.stdout.flush()
            bar.next()
            with open('data.csv', 'a') as data_file:
                data_file.write(
                    '%f,%3.10f,%2.2f,%3.10f,%2.2f\n' %
                    (timestamps_temp[n], delay1, height1, delay2, height2))
Example #2
0
import sys
import library.timedomain as td
import library.fileprocessing as fp
import matplotlib

if __name__ == '__main__':
    if len(sys.argv) == 3:
        filename1 = sys.argv[1]
        filename2 = sys.argv[2]
    else:
        print "USAGE: python Filequality <Phasedata_file> <frequency file>"
        sys.exit()
    F = fp.loadfile_frequency(filename2)
    timestamp, X = fp.loadfile_multisweep(filename1)
    td.plotresponse(F, X[0])
    A, B, C, D = td.transform(F, X[0], verbose=3)
    print "Peak 1 level %0.2fdB, Peak 2 level %0.2f" % (C, D)
    matplotlib.pyplot.show()
    starttime = time.time()

    files = glob.glob(directory + '/*.txt')
    files.sort(key=os.path.getmtime)
    files.remove(directory + '/frequency.txt')

    #array storing delta length changes and time_stamps for files in directory
    delta_length = np.empty(0)
    delta_length2 = np.empty(0)
    timestamps = np.empty(0)
    pulse_peak1 = np.empty(0)
    pulse_peak2 = np.empty(0)

    #Determine peakindex with one run of transform code
    temptime, S = fp.loadfile_multisweep(files[0])
    temp1, temp2, temp3, temp4, peak1, peak2 = td.transform(F,
                                                            S[0],
                                                            verbose=0,
                                                            overs=oversampling)

    #Enumerate through each files and solve for the reference delay and store into delta_length
    #Only taking the first sweep in the file
    for n, fname in enumerate(files[::file_skipping_factor]):
        timest, S = fp.loadfile_multisweep(fname)
        Xpeak, Xpeak2, pulse_height1, pulse_height2, temp1, temp2 = td.transform(
            F,
            S[0],
            verbose=0,
            overs=oversampling,
            peak1_index=peak1,
Example #4
0
	files = glob.glob(directory+'/*.txt')
	files.sort(key=os.path.getmtime)
	files.remove(directory+'/frequency.txt')

	#array storing delta length changes and time_stamps for files in directory
	delta_length = np.empty(0)
	delta_length2 = np.empty(0)
	timestamps = np.empty(0)
	pulse_peak1 = np.empty(0)
	pulse_peak2 = np.empty(0)

	#Enumerate through each files and solve for the reference delay and store into delta_length
	#Only taking the first sweep in the file
	for n,fname in enumerate(files[::file_skipping_factor]):
    		timest,S = fp.loadfile_multisweep(fname)
    		Xpeak,Xpeak2,pulse_height1,pulse_height2 = td.transform(F,S[0],verbose=0,overs=oversampling)
    		if n==0:
        		Xfirstpeak=Xpeak
			Xfirstpeak2=Xpeak2
    		delta_length = np.append(delta_length,(Xpeak-Xfirstpeak)*1000)
		delta_length2 = np.append(delta_length2,(Xpeak2-Xfirstpeak2)*1000)
    		timestamps = np.append(timestamps,timest[0])
		print 'peak at %8.3f m and %8.3f m, Delta1 =  %+6.10f ps, Delta2 = %+6.10f ps SWEEP FILE %4.0f/%4.0f' % (Xpeak,Xpeak2,(Xpeak-Xfirstpeak)/c*1e12,(Xpeak2-Xfirstpeak2)/c*1e12,n,len(files))
		pulse_peak1 = np.append(pulse_peak1,pulse_height1)
		pulse_peak2 = np.append(pulse_peak2,pulse_height2)
	print 'Sampling rate = %3.1f seconds\n' % (timestamps[2] - timestamps[1])
	
	

	plt.plot(timestamps,0.5*(delta_length/1000/c)*1e12,'b',timestamps,0.5*(delta_length2/c)*1e12,'r')
Example #5
0
import sys, os, glob, time
import numpy as np
#import matplotlib.pyplot as plt
import library.timedomain as td
import library.fileprocessing as fp



if __name__ == '__main__':
	if len(sys.argv) == 3:
		#directory = sys.argv[1]
		filename = sys.argv[1]
		filename2 = sys.argv[2]
	time_stamps,sdata = fp.loadfile_multisweep(filename)
	F = fp.loadfile_frequency(filename2)
	#F = f[::10]
	td.transform(F,sdata[0],verbose=1,overs=50)
	starttime = time.time()

	#files = glob.glob(directory+'/*.txt')
	#files.sort(key=os.path.getctime)
	#files.remove(directory+'/frequency.txt')

	#array storing delta length changes and time_stamps for files in directory
	#delta_length = np.empty(0)
	#timestamps = np.empty(0)

	#Enumerate through each files and solve for the reference delay and store into delta_length
	#Only taking the first sweep in the file

	#for n,fname in enumerate(files[::10]):