In [1]:
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
%matplotlib inline
In [2]:
time = np.loadtxt('20171003_ch2_interference_w_sas_nodop_leftmost.isf', delimiter=',')[:,0]
ch2 = np.loadtxt('20171003_ch2_interference_w_sas_nodop_leftmost.isf', delimiter=',')[:,1]
ch3 = np.loadtxt('20171003_ch2_interference_w_sas_nodop_leftmost.isf', delimiter=',')[:,1]
In [12]:
plt.plot(time, ch2)
Out[12]:
In [69]:
##Defining function to pull desired information from the data
def get_peak_data(array, plotrange):
peak = []
maximum = 0
maximum_loc = 0
max_ind = 0
inds = []
for i in range(len(time)):
if (time[i] >= plotrange[0]) and (time[i] <= plotrange[1]):
peak.append(array[i])
inds.append(i)
if array[i] >= maximum:
maximum = array[i]
maximum_loc = time[i]
max_ind = i
print("Maximum found at: t = {}".format(maximum_loc))
print("Maximum value occurs at index: {}".format(max_ind))
print("Maximum value: {}".format(np.max(peak)))
plt.title("Voltage vs. Time")
plt.ylabel("Voltage (V)")
plt.xlabel("Time (s)")
plt.plot([time[j] for j in inds], peak)
plt.plot(maximum_loc, maximum, 'rp')
return peak
In [70]:
##Defining function to pull desired information from the data
def show_local_peaks(array, plotrange):
peak = []
inds = []
for i in range(len(time)):
if (time[i] >= plotrange[0]) and (time[i] <= plotrange[1]):
peak.append(array[i])
inds.append(i)
plt.title("Voltage vs. Time")
plt.ylabel("Voltage (V)")
plt.xlabel("Time (s)")
plt.plot([time[j] for j in inds], peak)
Extracting the information for local peaks separations.
In [71]:
get_peak_data(ch2, [0.025, 0.0282]);
In [72]:
get_peak_data(ch2, [0.0282, 0.0285]);
In [73]:
get_peak_data(ch2, [0.0287, 0.0291]);
In [74]:
local_maximums_voltages = [0.738, 0.694, 0.486]
local_maximums_times = [0.028124, 0.028412, 0.028876]
plt.plot(local_maximums_times, local_maximums_voltages, 'rp')
show_local_peaks(ch2, [0.025, 0.032])
In [85]:
differences = [0]
for i in range(1,len(local_maximums_times)):
differences.append(local_maximums_times[i]-local_maximums_times[i-1])
from prettytable import PrettyTable
x = PrettyTable()
x.add_column("Time (s)", local_maximums_times)
x.add_column("Voltage (V)", local_maximums_voltages)
x.add_column("Difference (s)", [round(i, 5) for i in differences])
x.add_column("Number of Interferometer Distances Apart", [round(i, 5)/0.00158 for i in differences])
x.add_column("Separation of Features (MHz)", [round(i, 5)/0.00158 *379 for i in differences])
print(x)
file = open('leftmost_peak.txt', 'w')
file.write(str(x))
file.close()
In [76]:
show_local_peaks(ch2, [0.031, 0.037]);
I see four potential peaks here.
In [77]:
get_peak_data(ch2, [0.032, 0.0327]);
In [78]:
get_peak_data(ch2, [0.03275, 0.0329]);
In [79]:
get_peak_data(ch2, [0.0329, 0.0331]);
In [82]:
get_peak_data(ch2, [0.0329, 0.0345]);
In [83]:
left2_maximum_times = [0.03266, 0.032768, 0.032984, 0.034032]
left2_maximum_voltages = [0.53, 0.444, 0.316, 0.338]
plt.plot(left2_maximum_times, left2_maximum_voltages, 'rp')
show_local_peaks(ch2, [0.031, 0.037])
In [86]:
differences = [0]
for i in range(1,len(left2_maximum_times)):
differences.append(left2_maximum_times[i]-left2_maximum_times[i-1])
from prettytable import PrettyTable
x = PrettyTable()
x.add_column("Time (s)", left2_maximum_times)
x.add_column("Voltage (V)", left2_maximum_times)
x.add_column("Difference (s)", [round(i, 5) for i in differences])
x.add_column("Number of Interferometer Distances Apart", [round(i, 5)/0.00158 for i in differences])
x.add_column("Separation of Features (MHz)", [round(i, 5)/0.00158 *379 for i in differences])
print(x)
file = open('leftmost2_peak.txt', 'w')
file.write(str(x))
file.close()
In [89]:
show_local_peaks(ch2, [0.038, 0.047])
Here, we see two potential maxima within this broader feature.
In [93]:
get_peak_data(ch2, [0.041, 0.0427]);
In [95]:
get_peak_data(ch2, [0.041, 0.0429]);
In [96]:
right2_maximum_times = [0.042628, 0.042744]
right2_maximum_voltages = [0.686, 0.716]
plt.plot(right2_maximum_times, right2_maximum_voltages, 'rp')
show_local_peaks(ch2, [0.0385, 0.045])
In [98]:
differences = [0]
for i in range(1,len(right2_maximum_times)):
differences.append(right2_maximum_times[i]-right2_maximum_times[i-1])
from prettytable import PrettyTable
x = PrettyTable()
x.add_column("Time (s)", right2_maximum_times)
x.add_column("Voltage (V)", right2_maximum_times)
x.add_column("Difference (s)", [round(i, 5) for i in differences])
x.add_column("Number of Interferometer Distances Apart", [round(i, 5)/0.00158 for i in differences])
x.add_column("Separation of Features (MHz)", [round(i, 5)/0.00158 *379 for i in differences])
print(x)
file = open('rightmost2_peak.txt', 'w')
file.write(str(x))
file.close()
In [ ]: