crosstalk graphs
BIN
doc/crosstalk/img/Graph - 230 Ohm - Far end.png
Normal file
After Width: | Height: | Size: 47 KiB |
BIN
doc/crosstalk/img/Graph - 230 Ohm - Near end.png
Normal file
After Width: | Height: | Size: 51 KiB |
BIN
doc/crosstalk/img/Graph - 50 Ohm - Far end.png
Normal file
After Width: | Height: | Size: 45 KiB |
BIN
doc/crosstalk/img/Graph - 50 Ohm - Near end.png
Normal file
After Width: | Height: | Size: 47 KiB |
BIN
doc/crosstalk/img/Graph - Capacative - Far end.png
Normal file
After Width: | Height: | Size: 50 KiB |
BIN
doc/crosstalk/img/Graph - Capacative - Near end.png
Normal file
After Width: | Height: | Size: 52 KiB |
BIN
doc/crosstalk/img/Graph - Inductive - Far end.png
Normal file
After Width: | Height: | Size: 47 KiB |
BIN
doc/crosstalk/img/Graph - Inductive - Near end.png
Normal file
After Width: | Height: | Size: 48 KiB |
60
scripts/crosstalk.py
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
from matplotlib import pyplot as plt
|
||||||
|
from matplotlib import patches as pat
|
||||||
|
import numpy as np
|
||||||
|
import reader
|
||||||
|
|
||||||
|
# load data
|
||||||
|
data_reader = reader.Reader()
|
||||||
|
num = 14
|
||||||
|
data = data_reader.read_file(f".\data\T00{num}ALL.csv")
|
||||||
|
str_end = 'Near end' if num % 2 == 0 else 'Far end'
|
||||||
|
str_desc = '230 Ohm'
|
||||||
|
|
||||||
|
# FFT
|
||||||
|
np_data1 = np.array(data['CH1'])
|
||||||
|
np_data2 = np.array(data['CH2'])
|
||||||
|
np_time = np.array(data['TIME'])
|
||||||
|
X1 = np.fft.rfft(np_data1)
|
||||||
|
X2 = np.fft.rfft(np_data2)
|
||||||
|
N = np.fft.rfftfreq(len(np_data1), (np_time[1]-np_time[0]))
|
||||||
|
|
||||||
|
phi1 = np.angle(X1, True)
|
||||||
|
phi2 = np.angle(X2, True)
|
||||||
|
diff_phi = phi1[np.argmax(abs(X1))]-phi2[np.argmax(abs(X2))]
|
||||||
|
|
||||||
|
fig, ax = plt.subplots()
|
||||||
|
plt.plot(data['TIME'], data['CH1'], label='CH1')
|
||||||
|
plt.plot(data['TIME'], data['CH2'], label='CH2')
|
||||||
|
|
||||||
|
handles, labels = ax.get_legend_handles_labels()
|
||||||
|
patch = pat.Patch(
|
||||||
|
color='C0',
|
||||||
|
label='pk-pk = ${:.2f}\ V$'.format(max(data['CH1'])-min(data['CH1'])))
|
||||||
|
handles.append(patch)
|
||||||
|
patch = pat.Patch(
|
||||||
|
color='C1',
|
||||||
|
label='pk-pk = ${:.2f}\ V$'.format(max(data['CH2'])-min(data['CH2'])))
|
||||||
|
handles.append(patch)
|
||||||
|
patch = pat.Patch(
|
||||||
|
color='C0',
|
||||||
|
label='F = ${:.1f}\ MHz$'.format(N[np.argmax(abs(X1))]/1e6))
|
||||||
|
handles.append(patch)
|
||||||
|
patch = pat.Patch(
|
||||||
|
color='C1',
|
||||||
|
label='F = ${:.1f}\ MHz$'.format(N[np.argmax(abs(X2))]/1e6))
|
||||||
|
handles.append(patch)
|
||||||
|
patch = pat.Patch(
|
||||||
|
color='grey',
|
||||||
|
label='$\Delta \phi$ = ${:.1f} \degree$'.format(diff_phi))
|
||||||
|
handles.append(patch)
|
||||||
|
|
||||||
|
plt.title('Voltage vs Time, ' + str_desc + ', ' + str_end)
|
||||||
|
plt.legend(loc='upper right', handles=handles)
|
||||||
|
plt.grid()
|
||||||
|
plt.xlabel('Time [s]')
|
||||||
|
plt.ylabel('Voltage [V]')
|
||||||
|
plt.xlim(data['TIME'][0], data['TIME'][-1])
|
||||||
|
name = f'Graph - {str_desc} - {str_end}.png'
|
||||||
|
plt.savefig(f'./doc/crosstalk/img/{name}')
|
||||||
|
print('Saved:', name)
|
||||||
|
# plt.show()
|
@ -14,4 +14,4 @@ def cut_time(data : dict, start : float, end : float) -> dict:
|
|||||||
if idx_end != 0 and idx_start != 0:
|
if idx_end != 0 and idx_start != 0:
|
||||||
return {key: value[idx_start:idx_end] for key, value in data.items()}
|
return {key: value[idx_start:idx_end] for key, value in data.items()}
|
||||||
else:
|
else:
|
||||||
return None
|
raise Exception("Start or end out of range")
|
||||||
|
@ -7,7 +7,8 @@ class Reader():
|
|||||||
def read_file(self, filename) -> dict:
|
def read_file(self, filename) -> dict:
|
||||||
with open(filename, 'r') as file:
|
with open(filename, 'r') as file:
|
||||||
data = list(csv.reader(file, delimiter=','))
|
data = list(csv.reader(file, delimiter=','))
|
||||||
|
|
||||||
|
|
||||||
# Delete metadata for now
|
# Delete metadata for now
|
||||||
for i in range(15):
|
for i in range(15):
|
||||||
data.pop(0)
|
data.pop(0)
|
||||||
|
@ -6,7 +6,7 @@ import helper
|
|||||||
|
|
||||||
# load data
|
# load data
|
||||||
data_reader = reader.Reader()
|
data_reader = reader.Reader()
|
||||||
data = data_reader.read_file(r".\data\T0004CH1.csv")
|
data = data_reader.read_file(r".\data\T0001CH1.csv")
|
||||||
|
|
||||||
# slice empty space, start and end time is in seconds
|
# slice empty space, start and end time is in seconds
|
||||||
data = helper.cut_time(data, -1e-7, 5e-7)
|
data = helper.cut_time(data, -1e-7, 5e-7)
|
||||||
@ -41,5 +41,11 @@ if len(peaks) > 0:
|
|||||||
peak*step+data['TIME'][0],
|
peak*step+data['TIME'][0],
|
||||||
min(data['CH1']),
|
min(data['CH1']),
|
||||||
max(data['CH1']), 'red', 'dashed')
|
max(data['CH1']), 'red', 'dashed')
|
||||||
|
plt.xlabel('Time [s]')
|
||||||
|
plt.ylabel('Voltage [V]')
|
||||||
|
plt.title('Voltage vs Time, $75 \Omega$ cable')
|
||||||
|
plt.tight_layout()
|
||||||
|
txt="$\Delta t\ =\ {:.2f}\ ns $".format(tim_diff*1e9)
|
||||||
|
plt.figtext(0.54, 0.01, txt, wrap=True, horizontalalignment='center', fontsize=9)
|
||||||
plt.grid()
|
plt.grid()
|
||||||
plt.show()
|
plt.show()
|
||||||
|