This commit is contained in:
2024-09-16 18:29:31 +02:00
parent 92c0d889cc
commit a11d4d9d6f
6 changed files with 230 additions and 186 deletions

View File

@@ -1,4 +1,5 @@
import h5py as hdf
import math
import numpy as np
from scipy import signal
from scipy.signal import hilbert
@@ -19,9 +20,14 @@ file.close()
t = []
y1 = []
y2 = []
idx = []
t_stepsize = 0.0000000004*50
t_stepsize = 0.00000002
yall1 = []
yall2 = []
idxall = []
#t_stepsize = 0.0000000004*50
t_stepsize = 1/(50.6328*10**6)/50 # 0.00000002
print(t_stepsize)
print(1/(2.5*10**9))
#t_stepsize = 1/(2.5*10**9)
t_offset = 2500002/2
t_inc = 0
@@ -52,9 +58,9 @@ for count, entry in enumerate(content[5:]):
#else:
# val[2]=0
y1.append(float(val[1])*(-1))
y2.append(float(val[2]))
idx.append(t_inc) #count
yall1.append(float(val[1])*(-1))
yall2.append(float(val[2]))
idxall.append(t_inc) #count
#if count < 200:
# break
# print(val[1], val[2], count, t_inc )
@@ -69,14 +75,17 @@ count = 0
t_inc = 0
idx = []
for val in range(start,stop,50):
_test1_array = y1[val : val+50]
_test2_array = y2[val : val+50]
_test1_array = yall1[val : val+50]
_test2_array = yall2[val : val+50]
_y1.append(np.array(_test1_array).max())
_y2.append(np.array(_test2_array).max())
count += 1
t_inc += t_stepsize
idx.append(t_inc)
idx = np.array(idx) - t_offset*t_stepsize
y1 = _y1
y2 = _y2
print(y1[0:50], y2[0:50] )
@@ -92,8 +101,8 @@ print(y1[0:50], y2[0:50] )
]
y2= [ i*5 for i in y2]
'''
f1 = hdf.File('/hipa/bd/data/measurements/Tina_2024-07-03_15:44:14.h5','a') #5Tina_2024-08-07_10:41:04.h5','a')
f1 = hdf.File('/hipa/bd/data/measurements/Tina_2024-09-13_15:57:07.h5','a')
#f1 = hdf.File('/hipa/bd/data/measurements/Tina_2024-07-03_15:44:14.h5','a') #5Tina_2024-08-07_10:41:04.h5','a')
grp = f1.require_group('Raw_data')
if 't' in grp:
del grp['t']
@@ -103,14 +112,19 @@ if 't_idx' in grp:
del grp['t_idx']
if 'y2' in grp:
del grp['y2']
if 'yall1' in grp:
del grp['yall1']
if 'yall2' in grp:
del grp['yall2']
dset_yall1 = grp.create_dataset('yall1', data=yall1)
dset_yall2 = grp.create_dataset('yall2', data=yall2)
dset_t = grp.create_dataset("t", data=t)
dset_y1 = grp.create_dataset('y1', data=y1)
dset_y2 = grp.create_dataset('y2', data=y2)
dset_t = grp.create_dataset("t", data=t)
dset_t_idx = grp.create_dataset("t_idx", data=idx)
print(dset_y1.name)
f1.close()
idx = np.array(idx) - t_offset*t_stepsize
analytic_signal_1 = y1 #hilbert(y1)
amplitude_envelope_1 = np.abs(analytic_signal_1) #analytic_signal_1 #
@@ -243,7 +257,7 @@ print("time index", idx[np.argmax(corr)])
#0.000433, 0.000206, 0.000231, 0.000130]
subplots = 4
ln=100
ln=500
ln2=1239770
ln3=1260230
@@ -255,10 +269,12 @@ if subplots == 4:
ax[0,0].ticklabel_format(useOffset=False, style='plain')
#ax[0,0].plot(idx[0:ln], amplitude_envelope_1[0:ln], 'b')
#y1
ax[0,0].plot(idx[0:ln], normalized_amplitude_envelope_1[0:ln], 'ro')
ax[0,0].plot(idxall[0:ln], yall1[0:ln], 'ro')
###ax[0,0].plot(idx[0:ln2], normalized_amplitude_envelope_1[0:ln2], 'ro')
#ax1.set_ylim([-0.05, 0.05])
#y2
ax[1,0].plot(idx[0:ln], normalized_amplitude_envelope_2[0:ln], 'ro')
###ax[1,0].plot(idx[0:ln2], normalized_amplitude_envelope_2[0:ln2], 'ro')
ax[1,0].plot(idxall[0:ln], yall2[0:ln], 'ro')
#ax[1,0].plot(idx[0:ln], amplitude_envelope_2[0:ln], 'g')
#else:
# fig, (ax3, ax4) = plt.subplots(2, figsize=(20,12))