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]:
[<matplotlib.lines.Line2D at 0x11d504b38>]

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.

Leftmost peak


In [71]:
get_peak_data(ch2, [0.025, 0.0282]);


Maximum found at: t = 0.028124
Maximum value occurs at index: 2803
Maximum value: 0.738

In [72]:
get_peak_data(ch2, [0.0282, 0.0285]);


Maximum found at: t = 0.028412
Maximum value occurs at index: 2875
Maximum value: 0.694

In [73]:
get_peak_data(ch2, [0.0287, 0.0291]);


Maximum found at: t = 0.028876
Maximum value occurs at index: 2991
Maximum value: 0.486

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()


+----------+-------------+----------------+------------------------------------------+------------------------------+
| Time (s) | Voltage (V) | Difference (s) | Number of Interferometer Distances Apart | Separation of Features (MHz) |
+----------+-------------+----------------+------------------------------------------+------------------------------+
| 0.028124 |    0.738    |       0        |                   0.0                    |             0.0              |
| 0.028412 |    0.694    |    0.00029     |           0.18354430379746836            |       69.5632911392405       |
| 0.028876 |    0.486    |    0.00046     |            0.2911392405063291            |      110.34177215189874      |
+----------+-------------+----------------+------------------------------------------+------------------------------+

Second to leftmost peak (left2)


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]);


Maximum found at: t = 0.03266
Maximum value occurs at index: 3937
Maximum value: 0.53

In [78]:
get_peak_data(ch2, [0.03275, 0.0329]);


Maximum found at: t = 0.032768
Maximum value occurs at index: 3964
Maximum value: 0.444

In [79]:
get_peak_data(ch2, [0.0329, 0.0331]);


Maximum found at: t = 0.032984
Maximum value occurs at index: 4018
Maximum value: 0.316

In [82]:
get_peak_data(ch2, [0.0329, 0.0345]);


Maximum found at: t = 0.034032
Maximum value occurs at index: 4280
Maximum value: 0.338

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()


+----------+-------------+----------------+------------------------------------------+------------------------------+
| Time (s) | Voltage (V) | Difference (s) | Number of Interferometer Distances Apart | Separation of Features (MHz) |
+----------+-------------+----------------+------------------------------------------+------------------------------+
| 0.03266  |   0.03266   |       0        |                   0.0                    |             0.0              |
| 0.032768 |   0.032768  |    0.00011     |           0.06962025316455696            |      26.386075949367086      |
| 0.032984 |   0.032984  |    0.00022     |           0.13924050632911392            |      52.77215189873417       |
| 0.034032 |   0.034032  |    0.00105     |            0.6645569620253164            |      251.86708860759492      |
+----------+-------------+----------------+------------------------------------------+------------------------------+

Right 2


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]);


Maximum found at: t = 0.042628
Maximum value occurs at index: 6429
Maximum value: 0.686

In [95]:
get_peak_data(ch2, [0.041, 0.0429]);


Maximum found at: t = 0.042744
Maximum value occurs at index: 6458
Maximum value: 0.716

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()


+----------+-------------+----------------+------------------------------------------+------------------------------+
| Time (s) | Voltage (V) | Difference (s) | Number of Interferometer Distances Apart | Separation of Features (MHz) |
+----------+-------------+----------------+------------------------------------------+------------------------------+
| 0.042628 |   0.042628  |       0        |                   0.0                    |             0.0              |
| 0.042744 |   0.042744  |    0.00012     |            0.0759493670886076            |      28.78481012658228       |
+----------+-------------+----------------+------------------------------------------+------------------------------+

In [ ]: