Compare commits
	
		
			2 Commits
		
	
	
		
			a0bfb24a57
			...
			8ebc6a36bc
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 8ebc6a36bc | |||
| 02512129e2 | 
							
								
								
									
										40
									
								
								epoxy_transducer/tof_data.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										40
									
								
								epoxy_transducer/tof_data.py
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,40 @@ | ||||
| import numpy as np | ||||
| import matplotlib.pyplot as plt | ||||
| 
 | ||||
| num_meas = 4 | ||||
| 
 | ||||
| # speed of sound m/s | ||||
| sos = 1500 | ||||
| 
 | ||||
| # depth of the tub in mm | ||||
| tub_depth = 690 | ||||
| 
 | ||||
| # distances from the top measured at in mm | ||||
| distance = [0,138,276,414] | ||||
| 
 | ||||
| # distance from the bottom | ||||
| distance_to_bot = np.empty(num_meas) | ||||
| for i in range(num_meas): | ||||
|     distance_to_bot[i] = tub_depth - distance[i] | ||||
| 
 | ||||
| # time from pulse to reflection measuredin uS | ||||
| tof = [912,758,614,486] | ||||
| 
 | ||||
| # tot distance traveled | ||||
| distance_traveled = np.empty(num_meas) | ||||
| for i in range(num_meas): | ||||
|     distance_traveled[i] = (690*2) - (distance[i] * 2) | ||||
| 
 | ||||
| # ideal time from pulse to reflection measured uS | ||||
| tof_expected = np.empty(num_meas) | ||||
| for i in range(num_meas): | ||||
|     tof_expected[i] = ((distance_traveled[i] * 1e-3) / sos) * 1e6 | ||||
| 
 | ||||
| plt.figure(1) | ||||
| plt.plot(distance_to_bot, tof, label = 'tof measured in uS') | ||||
| plt.plot(distance_to_bot, tof_expected, label = 'tof expected in uS') | ||||
| plt.xlabel('Distance to bottom [mm]') | ||||
| plt.ylabel('Time [uS]') | ||||
| plt.title('Tof Data') | ||||
| plt.xlim(max(distance_to_bot),min(distance_to_bot)) | ||||
| plt.legend() | ||||
							
								
								
									
										45
									
								
								scope_fft/scope_fft.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										45
									
								
								scope_fft/scope_fft.py
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,45 @@ | ||||
| import numpy as np | ||||
| import matplotlib.pyplot as plt | ||||
| 
 | ||||
| def sig_fft(file1, file2): | ||||
|     # Load data from CSV files | ||||
|     data = np.genfromtxt(file1, delimiter=',')[2:] | ||||
|     data2 = np.genfromtxt(file2, delimiter=',')[2:] | ||||
|      | ||||
|     # find where data is nan | ||||
|     n_index = np.argmax(np.isnan(data[:,1])) | ||||
|     n_index2 = np.argmax(np.isnan(data2[:,1])) | ||||
|     # Define each column | ||||
|     time = data[:n_index, 0] | ||||
|     rx_signal = data[:n_index, 1] | ||||
|     tx_signal = data[:n_index, 2] | ||||
|     num_samples = time.size | ||||
|     fs1 = 1 / (time[1] - time[0])  # Set sampling frequency | ||||
|      | ||||
|     # Define each column for data 2 | ||||
|     time2 = data2[:n_index2, 0] | ||||
|     rx_signal2 = data2[:n_index2, 1] | ||||
|     tx_signal2 = data2[:n_index2, 2] | ||||
|     num_samples2 = time2.size | ||||
|     fs2 = 1 / (time2[1] - time2[0])  # Set sampling frequency | ||||
|     # Plot raw data | ||||
|     plt.figure(1) | ||||
|     plt.plot(time, rx_signal, label='Data 1') | ||||
|     plt.plot(time2, rx_signal2, label='Data 2') | ||||
|     plt.title('Unfiltered Data') | ||||
|     plt.legend() | ||||
|      | ||||
|     # fft for data 1 | ||||
|     sigfft = np.fft.fft(rx_signal) | ||||
|     freq = np.fft.fftfreq(rx_signal.shape[-1], 1/(fs1)) | ||||
|     # fft for data 2 | ||||
|     sigfft2 = np.fft.fft(rx_signal2) | ||||
|     freq2 = np.fft.fftfreq(rx_signal2.shape[-1], 1/(fs2)) | ||||
|     # plot fft | ||||
|     plt.figure(2) | ||||
|     plt.plot(freq, np.abs(sigfft), label='Data 1') | ||||
|     plt.plot(freq2, np.abs(sigfft2), label='Data 2') | ||||
|     plt.title('FFT of Data') | ||||
|     plt.xlim(0, 20000) | ||||
|      | ||||
|     plt.show() | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user