#%matplotlib inline
%matplotlib notebook
import sys
import os
import matplotlib.pyplot as plt
plt.rcParams['figure.figsize'] = (10, 8)
import numpy as np
import glob
from lib_lfr.load_routines import get_lfr_decom_l1_swf, get_lfr_decom_l1_cwf, get_lfr_decom_l1_asm, \
get_lfr_decom_l1_bp2, get_lfr_decom_l1_bp1
from lib_lfr.calib_routines import calib_one_freq_sinus_swf, calib_one_freq_sinus_cwf, calib_one_freq_sinus_asm
from lib_lfr.bp_routines import sm_3b2e_bp1
from lib_lfr.global_params import *
from lib_signal.spectra import computeFFT
hostname = os.environ['HOSTNAME']
print(hostname)
dir_root = '/WIN/Users/chust/DD CHUST' if hostname == 'PC-CHUST2.lpp.polytechnnique.fr' else \
'/home/chust/DD pc-p-chust' if hostname == 'pc-p-chust' else \
'/home/thomas/Labo' if hostname == 'pc-tango2' else 'ERROR!'
dir_DATA1 = '/DATA1' if hostname == 'PC-CHUST2.lpp.polytechnnique.fr' else \
'/home/chust/DATA' if hostname in ['pc-p-chust', 'juno'] else \
'/home/thomas/Labo/DATA' if hostname == 'pc-tango2' else 'ERROR!'
dir_DATA3 = '/run/media/chust/Samsung_T5'
#dir_data = dir_root + '/Missions/Solar Orbiter/LFR/Ground Segment/Calibration/calib 3'
#dir_data = dir_DATA1 + '/SO/Tests/2022_03_10_Bruno_FSW_3.3.0.7'
dir_data = dir_DATA1 + '/SO/Tests'
dir_plots = '/home/chust/Plots'
dir_storage = '/home/chust/Storage'
print('dir_root:', dir_root)
print('dir_data:', dir_data)
/home/chust/venv_py3/lib64/python3.10/site-packages/spacepy/time.py:2365: UserWarning: Leapseconds may be out of date. Use spacepy.toolbox.update(leapsecs=True) warnings.warn('Leapseconds may be out of date.'
pc-p-chust dir_root: /home/chust/DD pc-p-chust dir_data: /home/chust/DATA/SO/Tests
import sys
print(sys.path)
#del sys.modules['lib_lfr.load_routines']
#from lib_lfr.load_routines import get_lfr_decom_l1_asm, get_lfr_decom_l1_swf
#from lib_lfr.load_routines import get_lfr_decom_l1_cwf
#from lib_lfr.load_routines import get_lfr_decom_l1_bp2, get_lfr_decom_l1_bp1
del sys.modules['lib_lfr.bp_routines']
from lib_lfr.bp_routines import sm_3b2e_bp1
#del sys.modules['lib_lfr.calib_routines']
#from lib_lfr.calib_routines import calib_one_freq_sinus_asm
#from lib_lfr.calib_routines import calib_one_freq_sinus_cwf
def df(freq, F, dtype):
if dtype == 'CWF':
if F == 1:
if freq in [0.01, 0.02, 0.03, 0.04, 0.05, 0.06, 0.07, 0.08, 0.09, 0.1]:
return 0.01/4
if freq in [0.2, 0.4, 0.6, 0.8, 1.0, 1.2, 1.4, 1.6, 1.8, 2.,]:
return 0.2/4
return 1.
if F == 2:
if freq in [0.01, 0.02, 0.03, 0.04, 0.05, 0.06, 0.07, 0.08, 0.09, 0.1]:
return 0.01/4
if freq in [0.125, 0.25, 0.375, 0.5, 0.625, 0.75, 0.875]:
return 1/32.
return 1/20.
if F == 3:
if freq in [0.01, 0.02, 0.03, 0.04, 0.05, 0.06, 0.07, 0.08, 0.09, 0.1]:
return 0.01/4
if freq in [0.125, 0.25, 0.375, 0.5, 0.625, 0.75, 0.875]:
return 1/32.
#if freq in [0.2, 0.4, 0.6, 0.8, 1., 1.2, 1.4, 1.6, 1.8]:
return 0.2/4
return 1/20.
if dtype == 'SWF':
if F == 0:
if freq in [12., 36., 60., 84.]:
return 12.
if freq in [24., 72.]:
return 24.
if freq in [48.]:
return 48.
return 96.
if F == 1:
if freq%16 == 0:
return 16.
if freq%4 == 0:
return 4.
if freq%2 == 0:
return 2.
if freq%3 == 0:
return 3.
if freq%5 == 0:
return 5.
if freq%7 == 0:
return 7.
if freq%11 == 0:
return 11.
if freq == 1.:
return 2.
if is_prime(int(freq)):
return freq
def fig_stepSWF(stepswf, signals, F, nwidth=128*2, freq_range=None):
isignals = [name2index_wf(ch) for (ch, a) in signals]
fig=plt.figure()
for i in isignals:
nn = int(nwidth) if nwidth <= 1024 else 1024
index=np.arange(1024-nn, 1024+nn)
plt.plot(index, stepswf['data_block'][1024-nn:1024+nn,i], linewidth=2, label=chs_wf[i], color=colors_wf[i])
plt.legend(loc='best')
plt.xlabel('Time (index)', fontsize=12)
plt.ylabel('Waveform (count)', fontsize=14)
plt.title("SWF @F%d for this step (zoom in the middle)"%F , fontsize=14)
fig=plt.figure()
for i in isignals:
fft = computeFFT(stepswf['data_block'][:,i], fs=LFR_Fs[F], window=False, removeMean=False)
plt.plot(fft[0], fft[1], marker=markers_wf[i],label=chs_wf[i], color=colors_wf[i])
plt.semilogy()
plt.legend(loc='best')
if freq_range == None:
xrange = (0,LFR_Fs[F]/2)
else:
xrange = freq_range
plt.xlim(freq_range)
plt.xlabel('Frequency (Hz)', fontsize=12)
plt.ylabel('Modulus (count)', fontsize=14)
plt.title("corresponding 2048-point FFT", fontsize=14)
plt.show()
def fig_stepCWF(stepcwf, signals, F, i1=None, i2=None):
isignals = [name2index_wf(ch) for (ch, a) in signals]
fig=plt.figure()
for i in isignals:
plt.plot(stepcwf['relative_time'][:], stepcwf['data_block'][:,i], linewidth=2,
label=chs_wf[i], color=colors_wf[i])
plt.legend(loc='best')
plt.xlabel('Relative time (s)', fontsize=12)
plt.ylabel('Waveform (count)', fontsize=14)
plt.title("CWF @F%d retained for this step"%F, fontsize=14)
fig=plt.figure()
for i in isignals:
fft = computeFFT(stepcwf['data_block'][i1:i2,i], fs=LFR_Fs[F], window=False, removeMean=False)
plt.plot(fft[0], fft[1], marker=markers_wf[i],label=chs_wf[i], color=colors_wf[i])
print('comp: {:2s} offset: {:.2f} counts'.format(index2name_wf(i), fft[1][0]))
plt.semilogy()
#plt.loglog()
plt.legend(loc='best')
plt.xlim((0, LFR_Fs[F]/2))
plt.xlabel('Frequency (Hz)', fontsize=12)
plt.ylabel('Modulus (count)', fontsize=14)
plt.title("corresponding %d-point FFT"%len(stepcwf['data_block'][i1:i2,0]), fontsize=14)
plt.show()
def buildCalib_Bruno(files, freqs, datatype='SWF_F0', echo=True, fig=False, icwf_offset=0, i1=0, i2=None,
signals=[('B1', 1.), ('B2', 1.), ('B3', 1.), ('E1', 1.), ('E2', 1.), ('V', 1.)]):
F = int(datatype[-1])
dtype = datatype[:3]
if echo:
print("Number of files: {}".format(len(files)))
print("Number of freqs: {}".format(len(freqs)))
calib = []
for istep, (file, freq) in enumerate(zip(files, freqs)):
if dtype == 'SWF':
swf_l1 = get_lfr_decom_l1_swf(file)
if echo:
print()
print('Snapshot/Step index: {} (freq = {}Hz)'.format(istep, freq))
if fig: fig_stepSWF(swf_l1, signals, F)
calib.append( calib_one_freq_sinus_swf(swf_l1, freq, df_asked=df(freq, F, dtype), signals=signals,
calib_max=False, echo=echo) )
elif dtype == 'CWF':
cwf_l1 = get_lfr_decom_l1_cwf(file)
cwf_l1['data_block'] = cwf_l1['data_block'][icwf_offset:, :]
cwf_l1['relative_time'] = cwf_l1['relative_time'][icwf_offset:]
if echo:
print()
print('Step index: {} (freq = {}Hz)'.format(istep, freq))
if fig: fig_stepCWF(cwf_l1, signals, F, i1=i1, i2=i2)
calib.append( calib_one_freq_sinus_cwf(cwf_l1, freq, df_asked=df(freq, F, dtype), signals=signals,
calib_max=False, echo=echo) )
elif dtype == 'ASM':
asm_l1 = get_lfr_decom_l1_asm(file)
#asm_l1['asm_idl'] = asm_l1['asm_idl'][i1:i2, ...]
#asm_l1['relative_time'] = asm_l1['relative_time'][i1:i2]
#asm_l1['packet_headers'] = asm_l1['packet_headers'][i1*3:i2*3, :]
if echo:
print()
print('Step index: {} (freq = {}Hz)'.format(istep, freq))
#if fig: fig_stepASM(cwf_l1, signals, F, i1=i1, i2=i2)
calib.append( calib_one_freq_sinus_asm(asm_l1, freq, signals=signals, echo=echo, iasm=i1) )
return calib
def fig_TF_LFR_allRel(calib, echo=True, fname=None, logx=None, dB=None, unwrap=True,
phi_range=None, rho_range=None, ampl_range=None, freq_range=None,
figsize=(14,16)):
F = int(calib[0]['datatype'][-1])
dtype = calib[0]['datatype'][:3]
if echo:
print("nb of frequencies: %d"%len(calib))
print('calib[0]:')
print(calib[0])
chs = calib[0]['comp']
icomp = [name2index_sm(ch) for ch in chs]
f_injected = np.array([cal['f_injected'] for cal in calib])
calib_V2count = np.array([cal['calib_V2count'] for cal in calib])
cross_norm = np.array([cal['cross_norm'] for cal in calib])
status_auto = [cal['status_auto'] for cal in calib]
status_param = [cal['status_param'] for cal in calib]
ncomp = len(icomp)
fig1, axarr1 = plt.subplots(3, 1, figsize=figsize)
fig1.subplots_adjust(hspace=.08)
axarr1[0].set_title("LFR Transfer Functions @F%d (%s)"%(F,dtype), fontsize=18)
for j in range(ncomp):
if dB:
axarr1[0].plot(f_injected, 20*np.log10(calib_V2count[:,j]), linewidth=2, marker=markers_sm[icomp[j]],
label=chs_sm[icomp[j]], color=colors_sm[icomp[j]])
else:
axarr1[0].plot(f_injected, calib_V2count[:,j], linewidth=2, marker=markers_sm[icomp[j]],
label=chs_sm[icomp[j]], color=colors_sm[icomp[j]])
#axarr1[0].semilogy()
#axarr1[0].loglog()
if logx:
for j in range(0,2): axarr1[j].semilogx()
xrange = (0,LFR_Fs[F]/2) if freq_range == None else freq_range
if ampl_range == None: ampl_range = [[4000,9000], [1000,9000], [10,9000]][F]
if dB:
axarr1[0].set_ylim(np.rint(20*np.log10(ampl_range)+np.array([-0.5,0.5])))
axarr1[0].set_ylabel('Amplitude (dB[count/V])', fontsize=14)
else:
axarr1[0].set_ylim(ampl_range)
axarr1[0].set_ylabel('Amplitude (count/V)', fontsize=14)
cross_names = [chs_sm[i]+chs_sm[j] for i in icomp for j in icomp if j > i ]
ncomp_cross = len(cross_names)
cross_markers = ncomp_cross*['']
phi_cross = np.array([[np.angle(cross_n[l], deg=False) for l in range(ncomp_cross)] for cross_n in cross_norm])
rho_cross = np.array([[abs(cross_n[l]) for l in range(ncomp_cross)] for cross_n in cross_norm])
for l in range(ncomp_cross):
cross_markers[l] = '8' if 'B' not in cross_names[l] else '+'
if 'B' in cross_names[l] and ('E' in cross_names[l] or 'V' in cross_names[l]): cross_markers[l] = ' '
phi_cross[:,l] = np.rad2deg(np.unwrap(phi_cross[:,l]) if unwrap else phi_cross[:,l])
axarr1[1].plot(f_injected, phi_cross[:,l], linewidth=2, label=cross_names[l], marker=cross_markers[l])
axarr1[2].plot(f_injected, rho_cross[:,l]-1+l, linewidth=2, label=cross_names[l], marker=cross_markers[l])
axarr1[1].set_ylabel('Relative phase (°)', fontsize=14)
axarr1[2].set_ylabel('Correlation coefficient (rho-1+i)', fontsize=14)
axarr1[2].set_xlabel('Frequency (Hz)', fontsize=12)
for j in range(0,3):
axarr1[j].set_xlim(xrange)
axarr1[j].legend(loc='best')
axarr1[1].set_ylim([-200,+200])
axarr1[2].set_ylim([-1, ncomp_cross])
if phi_range != None: axarr1[1].set_ylim(phi_range)
if rho_range != None: axarr1[2].set_ylim(rho_range)
if fname != None:
fname = fname.replace('.svg','_F%d.svg'%F)
fig1.savefig(fname.replace('.svg','_dBlog.svg') if (dB and logx) else \
fname.replace('.svg','_dB.svg') if dB else fname.replace('.svg','_logx.svg') if logx else \
fname, bbox_inches='tight', pad_inches=0.2)
plt.show()
if echo:
print("Transfert fonction amplitudes (count/V):")
str_head = " Freq "
str_cal = "{:9.3f} Hz => ["
str_s_auto = "["
for j in range(ncomp):
str_head += " {:2s}"
str_cal += " {:7.2f}"
str_s_auto += " {:s}"
str_head += " auto status " + (ncomp)*" " + " param status"
str_cal += " ] "
str_s_auto += " ] "
str_s_param = (6-ncomp)*" " + " [ {:s} ]"
print(str_head.format(*chs))
for f, cal , s_auto, s_param in zip(f_injected, calib_V2count, status_auto, status_param):
print(str_cal.format(f, *cal) + str_s_auto.format(*s_auto) + str_s_param.format(s_param))
str_head_rho = " Freq "
str_head_phi = " Freq "
str_rho = "{:9.3f} Hz => ["
str_phi = "{:9.3f} Hz => ["
for l in range(ncomp_cross):
str_head_rho += " {:4s}"
str_head_phi += " {:4s}"
str_rho += " {:5.3f}"
str_phi += " {:7.2f}"
str_rho += " ] "
str_phi += " ]"
print()
print("Normalized crosscorrelation coefficients:")
print(str_head_rho.format(*cross_names))
for f, rho in zip(f_injected, rho_cross):
print(str_rho.format(f, *rho))
print()
print("Relative phases (°):")
print(str_head_phi.format(*cross_names))
for f, phi in zip(f_injected, phi_cross):
print(str_phi.format(f, *phi))
def fig_diff_TF_LFR_allrel(calib1, calib2, echo=True, fname=None, logx=None, dB=None,
phi_range=None, rho_range=None, ampl_range=None, freq_range=None,
figsize=(14,16)):
F = int(calib1[0]['datatype'][-1])
dtype1 = calib1[0]['datatype'][:3]
dtype2 = calib2[0]['datatype'][:3]
if echo:
print("nb of frequencies: %d"%len(calib1))
print('calib1[0]:')
print(calib1[0])
print('calib2[0]:')
print(calib2[0])
chs = calib1[0]['comp']
icomp = [name2index_sm(ch) for ch in chs]
f_injected = np.array([cal['f_injected'] for cal in calib1])
calib_V2count1 = np.array([cal['calib_V2count'] for cal in calib1])
calib_V2count2 = np.array([cal['calib_V2count'] for cal in calib2])
cross_norm1 = np.array([cal['cross_norm'] for cal in calib1])
cross_norm2 = np.array([cal['cross_norm'] for cal in calib2])
ncomp = len(icomp)
fig1, axarr1 = plt.subplots(3, 1, figsize=figsize)
fig1.subplots_adjust(hspace=.08)
axarr1[0].set_title("LFR TF relative differences between %s and %s @F%d"%(dtype1, dtype2, F), fontsize=18)
for j in range(ncomp):
if dB:
axarr1[0].plot(f_injected, 20*np.log10(calib_V2count1[:,j])-20*np.log10(calib_V2count2[:,j]),
linewidth=2, marker=markers_sm[icomp[j]], label=chs_sm[icomp[j]], color=colors_sm[icomp[j]])
else:
axarr1[0].plot(f_injected, 100*(calib_V2count1[:,j]-calib_V2count2[:,j])/calib_V2count2[:,j], linewidth=2,
marker=markers_sm[icomp[j]], label=chs_sm[icomp[j]], color=colors_sm[icomp[j]])
#axarr1[0].semilogy()
#axarr1[0].loglog()
if logx:
for j in range(0,2): axarr1[j].semilogx()
xrange = (0,LFR_Fs[F]/2) if freq_range == None else freq_range
if ampl_range == None: ampl_range = [-10,+10] if not dB else [-6, 6]
if dB:
axarr1[0].set_ylim(np.rint(20*np.log10(ampl_range)+np.array([-0.5,0.5])))
axarr1[0].set_ylabel('delta amplitude (dB)', fontsize=14)
else:
axarr1[0].set_ylim(ampl_range)
axarr1[0].set_ylabel('delta amplitude (%)', fontsize=14)
cross_names = [chs_sm[i]+chs_sm[j] for i in icomp for j in icomp if j > i ]
ncomp_cross = len(cross_names)
cross_markers = ncomp_cross*['']
phi_cross1 = np.array([[np.angle(cross_n[l], deg=True) for l in range(ncomp_cross)] for cross_n in cross_norm1])
phi_cross2 = np.array([[np.angle(cross_n[l], deg=True) for l in range(ncomp_cross)] for cross_n in cross_norm2])
rho_cross1 = np.array([[abs(cross_n[l]) for l in range(ncomp_cross)] for cross_n in cross_norm1])
rho_cross2 = np.array([[abs(cross_n[l]) for l in range(ncomp_cross)] for cross_n in cross_norm2])
for l in range(ncomp_cross):
cross_markers[l] = '8' if 'B' not in cross_names[l] else '+'
if 'B' in cross_names[l] and ('E' in cross_names[l] or 'V' in cross_names[l]): cross_markers[l] = ' '
axarr1[1].plot(f_injected, phi_cross1[:,l]-phi_cross2[:,l], linewidth=2,
label=cross_names[l], marker=cross_markers[l])
axarr1[2].plot(f_injected, 100*(rho_cross1[:,l]-rho_cross2[:,l])/rho_cross2[:,l], linewidth=2,
label=cross_names[l], marker=cross_markers[l])
axarr1[1].set_ylabel('delta phi (°)', fontsize=14)
axarr1[2].set_ylabel('delta rho (%)', fontsize=14)
axarr1[2].set_xlabel('Frequency (Hz)', fontsize=12)
for j in range(0,3):
axarr1[j].set_xlim(xrange)
axarr1[j].legend(loc='best')
axarr1[1].set_ylim(-200,+200)
axarr1[2].set_ylim(-1,+1)
if phi_range != None: axarr1[1].set_ylim(phi_range)
if rho_range != None: axarr1[2].set_ylim(rho_range)
if fname != None:
fname = fname.replace('.svg','_F%d.svg'%F)
fig1.savefig(fname.replace('.svg','_dBlog.svg') if (dB and logx) else \
fname.replace('.svg','_dB.svg') if dB else fname.replace('.svg','_logx.svg') if logx else \
fname, bbox_inches='tight', pad_inches=0.2)
plt.show()
def compare_bp2_asm_old(file_bp2, file_asm, l_bp2=0, l_asm=0, dl_bp2=1, ifreq_bp2=None, echo=False):
bp2 = get_lfr_decom_l1_bp2(file_bp2)
asm = get_lfr_decom_l1_asm(file_asm)
if echo:
print('bp2 mode:', bp2['mode'], '@F%d'%(LFR_Fs2F(bp2['fe'])))
print('bp2 time:', bp2['relative_time'] + bp2['start_time'])
print('asm time:', asm['relative_time'] + asm['start_time'])
print()
print('l_bp2: %s and dl_bp2: %s, l_asm: %s'%(l_bp2, dl_bp2, l_asm))
nfreq_bp2, dim_bp2, _ = bp2['bp2_idl'][l_bp2, ...].shape
nfreq_asm, dim_asm, _ = asm['asm_idl'][l_asm, ...].shape
n_asm_ave = int(nfreq_asm/nfreq_bp2)
if echo:
print()
print('dim_bp2: %d, dim_asm: %d'%(dim_bp2, dim_asm))
print('nfreq_bp2: %d, nfreq_asm: %d => n_asm_ave = %d'%(nfreq_bp2, nfreq_asm, n_asm_ave))
print()
asm_idl_ave = np.zeros((nfreq_bp2, dim_asm, dim_asm), dtype=complex)
for i in range(nfreq_bp2):
asm_idl_ave[i, ...] = np.sum(asm['asm_idl'][l_asm, i*n_asm_ave:i*n_asm_ave+n_asm_ave, ...],
axis=0) / n_asm_ave
bp2_idl_ave = np.sum(bp2['bp2_idl'][l_bp2:l_bp2+dl_bp2, ...], axis=0) / dl_bp2
diff = (asm_idl_ave - bp2_idl_ave) / asm_idl_ave
q = abs(diff)
imax = np.nanargmax(q)
imin = np.nanargmin(q)
if echo:
print('max relative difference: %5.2f %% for:'%(100*q.flatten()[imax]))
print(asm_idl_ave.flatten()[imax], bp2_idl_ave.flatten()[imax])
print('min relative difference: %5.2e %% for:'%(100*q.flatten()[imin]))
print(asm_idl_ave.flatten()[imin], bp2_idl_ave.flatten()[imin])
if echo and ifreq_bp2 != None:
print()
print('bp2[\'freq\']'+'[ifreq_bp2=%d] : %d Hz'%(ifreq_bp2, bp2['freq'][ifreq_bp2]))
print('asm_idl_ave[ifreq_bp2=%d, ...]'%(ifreq_bp2))
print(asm_idl_ave[ifreq_bp2, ...])
print()
print('corresponding relative difference')
print(100*abs(diff[ifreq_bp2, ...]))
print('max: %5.2f %%'%(np.max(100*abs(diff[ifreq_bp2, ...]))))
return 100*q.flatten()[imax]
def diff(item1, item2, first=True, relative=True, digit=17, outputs=1, echo=False):
diff = (item1 - item2) / (item1 if first else item2) if relative else item1 - item2
q = abs(diff)*100 if relative else abs(diff)
imax = np.nanargmax(q)
imin = np.nanargmin(q)
if echo:
format_item1_item2 = '(item1 {}:.{}f{} item2 {}:.{}f{})'.format('{', str(digit), '}', '{', str(digit), '}')
format_max_diff = 'max relative difference: %.3f %%' if relative else 'max difference: %.3f'
format_min_diff = 'min relative difference: %.3e %%' if relative else 'min difference: %.3e'
print(format_max_diff%(q.flatten()[imax]))
print(format_item1_item2.format(item1.flatten()[imax], item2.flatten()[imax]))
print(format_min_diff%(q.flatten()[imin]))
print(format_item1_item2.format(item1.flatten()[imin], item2.flatten()[imin]))
return q.flatten()[imax] if outputs == 1 else (q.flatten()[imax], imax)
def compare_bp1_bp2(file_bp1, file_bp2, l_bp1=0, l_bp2=0, ifreq_bp1=None, echo=False):
bp1 = get_lfr_decom_l1_bp1(file_bp1)
bp2 = get_lfr_decom_l1_bp2(file_bp2)
if echo:
print('bp1 mode:', bp1['mode'], '@F%d'%(LFR_Fs2F(bp1['fe'])))
print('bp1 time:', bp1['relative_time'] + bp1['start_time'])
print('bp2 mode:', bp2['mode'], '@F%d'%(LFR_Fs2F(bp2['fe'])))
print('bp2 time:', bp2['relative_time'] + bp2['start_time'])
print()
print('l_bp1: %d, l_bp2: %d'%(l_bp1, l_bp2))
nspec_bp1, nfreq_bp1 = bp1['dop'].shape
nspec_bp2, nfreq_bp2, dim_bp2, _ = bp2['bp2_idl'].shape
if echo:
print()
print('nspec_bp1: %3d, nfreq_bp1: %3d'%(nspec_bp1, nfreq_bp1))
print('nspec_bp2: %3d, nfreq_bp2: %3d'%(nspec_bp2, nfreq_bp2))
print()
bp1_from_bp2 = sm_3b2e_bp1(bp2['bp2_idl'], echo=echo, k45_pe=1.+1.j)
if ifreq_bp1 == None:
i1, i2 = 0, nfreq_bp1
if echo: print('\n#### compare for all frequencies ####')
else:
i1, i2 = ifreq_bp1, ifreq_bp1+1
if echo:
print('\n#### compare for bp1[\'freq\']'+'[ifreq_bp1=%d] : %d Hz ###'% \
(ifreq_bp1, bp1['freq'][ifreq_bp1]))
if echo: print('\nDifference for trace_sm_b:')
d_psd_b = diff(bp1['psd_be'][l_bp1,i1:i2,0], bp1_from_bp2['psd_b_bp1'][l_bp2,i1:i2], digit=10, echo=echo)
if echo: print('\nDifference for trace_sm_e:')
d_psd_e = diff(bp1['psd_be'][l_bp1,i1:i2,1], bp1_from_bp2['psd_e_bp1'][l_bp2,i1:i2], digit=10, echo=echo)
if echo: print('\nDifference for degree_polar_3b:')
d_dop = diff(bp1['dop'][l_bp1,i1:i2], bp1_from_bp2['dop_bp1'][l_bp2,i1:i2], digit=10, echo=echo)
if echo: print('\nDifference for wave_ellipti_3b:')
d_ellip = diff(bp1['ellip'][l_bp1,i1:i2], bp1_from_bp2['ellip_bp1'][l_bp2,i1:i2], digit=10, echo=echo)
if echo: print('\nDifference for wave_nvector_3b:')
d_nvec, imax = diff(bp1['nvec'][l_bp1,i1:i2,:], bp1_from_bp2['nvec_bp1'][l_bp2,i1:i2,:],
relative=False, outputs=2, digit=10, echo=echo)
if echo: print('imax corresponding nvec component:', imax%3)
if echo: print('\nDifference for sx:')
d_sx = diff(bp1['sx'][l_bp1,i1:i2,0], bp1_from_bp2['sx_bp1'][l_bp2,i1:i2], digit=10, echo=echo)
if echo: print('\nDifference for sx arg:')
d_sx_arg, imax = diff(bp1['sx'][l_bp1,i1:i2,1], bp1_from_bp2['sx_arg_bp1'][l_bp2,i1:i2],
relative=False, digit=10, outputs=2, echo=echo)
if echo:
format_item1_item2 = '(item1 {}:.{}f{} item2 {}:.{}f{})'.format('{', str(10), '}', '{', str(10), '}')
format_max_diff = 'max difference: %.2f'
print('corresponding sx:' )
print(format_item1_item2.format(bp1['sx'][l_bp1,i1:i2,0].flatten()[imax],
bp1_from_bp2['sx'][l_bp2,i1:i2].flatten()[imax]))
if echo: print('\nDifference for vphi:')
d_vphi = diff(bp1['vphi'][l_bp1,i1:i2,0], bp1_from_bp2['vphi_bp1'][l_bp2,i1:i2], digit=10, echo=echo)
if echo: print('\nDifference for vphi arg:')
d_vphi_arg, imax = diff(bp1['vphi'][l_bp1,i1:i2,1], bp1_from_bp2['vphi_arg_bp1'][l_bp2,i1:i2],
relative=False, digit=10, outputs=2, echo=echo)
if echo:
print('correponding vphi:' )
print(format_item1_item2.format(bp1['vphi'][l_bp1,i1:i2,0].flatten()[imax],
bp1_from_bp2['vphi'][l_bp2,i1:i2].flatten()[imax]))
return d_psd_b, d_psd_e, d_dop, d_ellip, d_nvec, d_sx, d_sx_arg, d_vphi, d_vphi_arg
def compare_bp1_asm(file_bp1, file_asm, l_bp1=0, l_asm=0, ifreq_bp1=None, echo=False):
bp1 = get_lfr_decom_l1_bp1(file_bp1)
asm = get_lfr_decom_l1_asm(file_asm)
if echo:
print('bp1 mode:', bp1['mode'], '@F%d'%(LFR_Fs2F(bp1['fe'])))
print('bp1 time:', bp1['relative_time'] + bp1['start_time'])
print('asm mode:', asm['mode'], '@F%d'%(LFR_Fs2F(asm['fe'])))
print('asm time:', asm['relative_time'] + asm['start_time'])
print()
print('l_bp1: %d, l_asm: %d'%(l_bp1, l_asm))
nspec_bp1, nfreq_bp1 = bp1['dop'].shape
nspec_asm, nfreq_asm, dim_asm, _ = asm['asm_idl'].shape
n_asm_ave = int(nfreq_asm/nfreq_bp1)
if echo:
print()
print('nspec_bp1: %3d, nfreq_bp1: %3d'%(nspec_bp1, nfreq_bp1))
print('nspec_asm: %3d, nfreq_asm: %3d'%(nspec_asm, nfreq_asm))
print('\nn_asm_ave = nfreq_asm/nfreq_bp1 = %d'%(n_asm_ave))
print()
asm_idl_ave = np.zeros((nspec_asm, nfreq_bp1, dim_asm, dim_asm), dtype=complex)
for i in range(nfreq_bp1):
asm_idl_ave[:, i, ...] = np.sum(asm['asm_idl'][:, i*n_asm_ave:i*n_asm_ave+n_asm_ave, ...],
axis=1) / n_asm_ave
bp1_from_asm = sm_3b2e_bp1(asm_idl_ave, echo=echo, k45_pe=1.+1.j)
if ifreq_bp1 == None:
i1, i2 = 0, nfreq_bp1
if echo: print('\n#### compare for all frequencies ####')
else:
i1, i2 = ifreq_bp1, ifreq_bp1+1
if echo: print('\n#### compare for bp1[\'freq\']'+'[ifreq_bp1=%d] : %d Hz ###'% \
(ifreq_bp1, bp1['freq'][ifreq_bp1]))
if echo: print('\nDifference for trace_sm_b:')
d_psd_b = diff(bp1['psd_be'][l_bp1,i1:i2,0], bp1_from_asm['psd_b_bp1'][l_asm,i1:i2], digit=10, echo=echo)
if echo: print('\nDifference for trace_sm_e:')
d_psd_e = diff(bp1['psd_be'][l_bp1,i1:i2,1], bp1_from_asm['psd_e_bp1'][l_asm,i1:i2], digit=10, echo=echo)
if echo: print('\nDifference for degree_polar_3b:')
d_dop = diff(bp1['dop'][l_bp1,i1:i2], bp1_from_asm['dop_bp1'][l_asm,i1:i2], digit=10, echo=echo)
if echo: print('\nDifference for wave_ellipti_3b:')
d_ellip = diff(bp1['ellip'][l_bp1,i1:i2], bp1_from_asm['ellip_bp1'][l_asm,i1:i2], digit=10, echo=echo)
if echo: print('\nDifference for wave_nvector_3b:')
d_nvec, imax = diff(bp1['nvec'][l_bp1,i1:i2,:], bp1_from_asm['nvec_bp1'][l_asm,i1:i2,:],
relative=False, outputs=2, digit=10, echo=echo)
if echo: print('imax corresponding nvec component:', imax%3)
if echo: print('\nDifference for sx:')
d_sx = diff(bp1['sx'][l_bp1,i1:i2,0], bp1_from_asm['sx_bp1'][l_asm,i1:i2], digit=10, echo=echo)
if echo: print('\nDifference for sx arg:')
d_sx_arg, imax = diff(bp1['sx'][l_bp1,i1:i2,1], bp1_from_asm['sx_arg_bp1'][l_asm,i1:i2],
relative=False, digit=10, outputs=2, echo=echo)
if echo:
format_item1_item2 = '(item1 {}:.{}f{} item2 {}:.{}f{})'.format('{', str(10), '}', '{', str(10), '}')
format_max_diff = 'max difference: %.2f'
print('corresponding sx:' )
print(format_item1_item2.format(bp1['sx'][l_bp1,i1:i2,0].flatten()[imax],
bp1_from_asm['sx'][l_asm,i1:i2].flatten()[imax]))
if echo: print('\nDifference for vphi bp1:')
d_vphi = diff(bp1['vphi'][l_bp1,i1:i2,0], bp1_from_asm['vphi_bp1'][l_asm,i1:i2], digit=10, echo=echo)
if echo: print('\nDifference for vphi arg:')
d_vphi_arg, imax = diff(bp1['vphi'][l_bp1,i1:i2,1], bp1_from_asm['vphi_arg_bp1'][l_asm,i1:i2],
relative=False, digit=10, outputs=2, echo=echo)
if echo:
print('correponding vphi:' )
print(format_item1_item2.format(bp1['vphi'][l_bp1,i1:i2,0].flatten()[imax],
bp1_from_asm['vphi'][l_asm,i1:i2].flatten()[imax]))
return d_psd_b, d_psd_e, d_dop, d_ellip, d_nvec, d_sx, d_sx_arg, d_vphi, d_vphi_arg
def compare_bp2_asm(file_bp2, file_asm, l_bp2=0, l_asm=0, ifreq_bp2=None, echo=False):
bp2 = get_lfr_decom_l1_bp2(file_bp2)
asm = get_lfr_decom_l1_asm(file_asm)
if echo:
print('bp2 mode:', bp2['mode'], '@F%d'%(LFR_Fs2F(bp2['fe'])))
print('bp2 time:', bp2['relative_time'] + bp2['start_time'])
print('asm mode:', asm['mode'], '@F%d'%(LFR_Fs2F(asm['fe'])))
print('asm time:', asm['relative_time'] + asm['start_time'])
print()
print('l_bp2: %d, l_asm: %d'%(l_bp2, l_asm))
nspec_bp2, nfreq_bp2, dim_bp2, _ = bp2['bp2_idl'].shape
nspec_asm, nfreq_asm, dim_asm, _ = asm['asm_idl'].shape
n_asm_ave = int(nfreq_asm/nfreq_bp2)
if echo:
print()
print('nspec_bp2: %3d, nfreq_bp2: %3d'%(nspec_bp2, nfreq_bp2))
print('nspec_asm: %3d, nfreq_asm: %3d'%(nspec_asm, nfreq_asm))
print('\nn_asm_ave = nfreq_asm/nfreq_bp2 = %d'%(n_asm_ave))
print()
asm_idl_ave = np.zeros((nspec_asm, nfreq_bp2, dim_asm, dim_asm), dtype=complex)
for i in range(nfreq_bp2):
asm_idl_ave[:, i, ...] = np.sum(asm['asm_idl'][:, i*n_asm_ave:i*n_asm_ave+n_asm_ave, ...],
axis=1) / n_asm_ave
bp1_from_bp2 = sm_3b2e_bp1(bp2['bp2_idl'], echo=echo, k45_pe=1.+1.j)
bp1_from_asm = sm_3b2e_bp1(asm_idl_ave, echo=echo, k45_pe=1.+1.j)
if ifreq_bp2 == None:
i1, i2 = 0, nfreq_bp2
if echo: print('\n#### compare for all frequencies ####')
else:
i1, i2 = ifreq_bp2, ifreq_bp2+1
if echo: print('\n#### compare for bp2[\'freq\']'+'[ifreq_bp2=%d] : %d Hz ###'% \
(ifreq_bp2, bp2['freq'][ifreq_bp2]))
if echo: print('\nDifference for tensor elements bp2:')
d_sm = diff(bp2['bp2_idl'][l_bp2,i1:i2,...], asm_idl_ave[l_asm,i1:i2,...], digit=10, echo=echo)
if echo: print('\nDifference for trace_sm_b:')
d_psd_b = diff(bp1_from_bp2['psd_b_bp1'][l_bp2,i1:i2], bp1_from_asm['psd_b_bp1'][l_asm,i1:i2],
digit=10, echo=echo)
if echo: print('\nDifference for trace_sm_e:')
d_psd_e = diff(bp1_from_bp2['psd_e_bp1'][l_bp2,i1:i2], bp1_from_asm['psd_e_bp1'][l_asm,i1:i2],
digit=10, echo=echo)
if echo: print('\nDifference for degree_polar_3b:')
d_dop = diff(bp1_from_bp2['dop_bp1'][l_bp2,i1:i2], bp1_from_asm['dop_bp1'][l_asm,i1:i2],
digit=10, echo=echo)
if echo: print('\nDifference for wave_ellipti_3b:')
d_ellip = diff(bp1_from_bp2['ellip_bp1'][l_bp2,i1:i2], bp1_from_asm['ellip_bp1'][l_asm,i1:i2],
digit=10, echo=echo)
if echo: print('\nDifference for wave_nvector_3b:')
d_nvec, imax = diff(bp1_from_bp2['nvec_bp1'][l_bp2,i1:i2,:], bp1_from_asm['nvec_bp1'][l_asm,i1:i2,:],
relative=False, outputs=2, digit=10, echo=echo)
if echo: print('imax corresponding nvec component:', imax%3)
if echo: print('\nDifference for sx:')
d_sx = diff(bp1_from_bp2['sx'][l_bp2,i1:i2], bp1_from_asm['sx'][l_asm,i1:i2],
digit=10, echo=echo)
if echo: print('\nDifference for sx.real:')
d_sx = diff(bp1_from_bp2['sx_bp1'][l_bp2,i1:i2], bp1_from_asm['sx_bp1'][l_asm,i1:i2],
digit=10, echo=echo)
if echo: print('\nDifference for sx arg:')
d_sx_arg, imax = diff(bp1_from_bp2['sx_arg_bp1'][l_bp2,i1:i2], bp1_from_asm['sx_arg_bp1'][l_asm,i1:i2],
relative=False, digit=10, outputs=2, echo=echo)
if echo:
format_item1_item2 = '(item1 {}:.{}f{} item2 {}:.{}f{})'.format('{', str(10), '}', '{', str(10), '}')
format_max_diff = 'max difference: %.2f'
print('corresponding sx:' )
print(format_item1_item2.format(bp1_from_bp2['sx'][l_bp2,i1:i2].flatten()[imax],
bp1_from_asm['sx'][l_asm,i1:i2].flatten()[imax]))
if echo: print('\nDifference for vphi:')
d_vphi = diff(bp1_from_bp2['vphi'][l_bp2,i1:i2], bp1_from_asm['vphi'][l_asm,i1:i2],
digit=10, echo=echo)
if echo: print('\nDifference for vphi.real:')
d_vphi = diff(bp1_from_bp2['vphi_bp1'][l_bp2,i1:i2], bp1_from_asm['vphi_bp1'][l_asm,i1:i2],
digit=10, echo=echo)
if echo: print('\nDifference for vphi arg:')
d_vphi_arg, imax = diff(bp1_from_bp2['vphi_arg_bp1'][l_bp2,i1:i2], bp1_from_asm['vphi_arg_bp1'][l_asm,i1:i2],
relative=False, digit=10, outputs=2, echo=echo)
if echo:
print('correponding vphi:' )
print(format_item1_item2.format(bp1_from_bp2['vphi'][l_bp2,i1:i2].flatten()[imax],
bp1_from_asm['vphi'][l_asm,i1:i2].flatten()[imax]))
return d_sm, d_psd_b, d_psd_e, d_dop, d_ellip, d_nvec, d_sx, d_sx_arg, d_vphi, d_vphi_arg
case = 'ctc-5100'
dir_Packets = dir_data + "/2017_01_06_ctc-5100/decom"
files = glob.glob(dir_Packets + '/*.sf0')
files.sort()
print(len(files))
for file in files:
print(os.path.basename(file))
freqs_F0 = [f for f in range(1632, 9985, 96)] + [f for f in range(10080,12288,96)[0::3]]
calib_SWF_F0 = buildCalib_Bruno(files, freqs_F0, datatype='SWF_F0', echo=False, fig=False)
pname = case + '_' + os.path.basename(files[0]).replace('.sf0','_SWF.svg')
fig_TF_LFR_allRel(calib_SWF_F0, echo=False, ampl_range=[0,10000], freq_range=[1500,12200], unwrap=False,
fname=dir_plots+'/'+pname, dB=False, logx=False, phi_range=[-180,180])
signals_ASM = [('B1', 1.), ('B2', 1.), ('B3', 1.), ('E1', 1.), ('E2', 1.)]
freqs_F0_ASM = [f for f in range(1632, 9985, 96)]
calib_SWF_F0_5 = buildCalib_Bruno(files, freqs_F0_ASM, datatype='SWF_F0', echo=False, fig=False, signals=signals_ASM )
pname = case + '_' + os.path.basename(files[0]).replace('.sf0','_SWF_5.svg')
fig_TF_LFR_allRel(calib_SWF_F0_5, echo=False, ampl_range=[4000,10000], freq_range=[1500,10500], unwrap=False,
fname=dir_plots+'/'+pname, dB=False, logx=False, phi_range=[-180,180])
dir_Packets = dir_data + "/2017_01_06_ctc-5100/decom"
files = glob.glob(dir_Packets + '/*.af0')
files.sort()
print(len(files))
for file in files:
print(os.path.basename(file))
signals_ASM = [('B1', 1.), ('B2', 1.), ('B3', 1.), ('E1', 1.), ('E2', 1.)]
freqs_F0_ASM = [f for f in range(1632, 9985, 96)]
calib_ASM_F0 = buildCalib_Bruno(files[:88], freqs_F0_ASM, datatype='ASM_F0', echo=False, fig=False,
signals=signals_ASM, i1=4 )
pname = case + '_' + os.path.basename(files[0]).replace('.af0','_ASM.svg')
fig_TF_LFR_allRel(calib_ASM_F0, echo=False, ampl_range=[4000,10000], freq_range=[1500,10500], unwrap=False,
fname=dir_plots+'/'+pname, dB=False, logx=False, phi_range=[-180,180])
pname = case + '_' + 'diff_ASM-SWF_zoom.svg'
fig_diff_TF_LFR_allrel(calib_ASM_F0, calib_SWF_F0_5, echo=False, ampl_range=[-0.1, 0.05], freq_range=[1500,10500],
fname=dir_plots+'/'+pname, dB=False, logx=False, rho_range=[-0.0001,0.0001], phi_range=[-0.1,0.1])
pname = case + '_' + 'diff_ASM-SWF.svg'
fig_diff_TF_LFR_allrel(calib_ASM_F0, calib_SWF_F0_5, echo=False, ampl_range=[-1., 1], freq_range=[1500,10500],
fname=dir_plots+'/'+pname, dB=False, logx=False, rho_range=[-10.,1.], phi_range=[-360.,100.])
case = 'ctc-510'
dir_Packets = dir_data + "/2018_12_03_ctc-510_EM-FSW_3.2.0.24_sansV/decom"
files = glob.glob(dir_Packets + '/*.sf0')
files.sort()
print(len(files))
for file in files:
print(os.path.basename(file))
outsideFrq1 = [ 12., 24., 36., 48., 60., 72., 84., 96., 192., 288., 384., 480., 576., 672., 768., 864., 960.,
1056., 1152., 1248., 1344., 1440., 1536.]
outsideFrq2 = [10080., 10176., 10272., 10368., 10464., 10560., 10656., 10752., 10848., 10944., 11040., 11136.,
11232., 11328., 11424., 11520.,11616., 11712., 11808., 11904., 12000., 12096., 12192., 12288.,
13056., 13824., 14592., 15360., 16128., 16896., 17664., 18432., 19200., 19968., 20736., 21504.,
22272., 23040., 23808., 24576., 25344., 26112., 26880., 27648., 28416., 29184., 29952., 30720.]
insideFrqs = np.arange(1632, 9985, 96)
print(len(outsideFrq1) + len(outsideFrq2) + len(insideFrqs) )
freqs_F0 = outsideFrq1 + [f for f in range(1632, 9985, 96)] + outsideFrq2
calib_SWF_F0 = buildCalib_Bruno(files, freqs_F0, datatype='SWF_F0', echo=False, fig=False)
pname = case + '_' + os.path.basename(files[0]).replace('.sf0','_SWF.svg')
fig_TF_LFR_allRel(calib_SWF_F0, echo=False, ampl_range=[0,10000], freq_range=[0,12288 - 96], unwrap=False,
fname=dir_plots+'/'+pname, dB=False, logx=False, phi_range=[-180,180])
signals_ASM = [('B1', 1.), ('B2', 1.), ('B3', 1.), ('E1', 1.), ('E2', 1.)]
freqs_F0_ASM = [f for f in range(1632, 9985, 96)]
calib_SWF_F0_5 = buildCalib_Bruno(files[23:23+88], freqs_F0_ASM, datatype='SWF_F0', echo=False, fig=False, signals=signals_ASM )
pname = case + '_' + os.path.basename(files[0]).replace('.sf0','_SWF_5.svg')
fig_TF_LFR_allRel(calib_SWF_F0_5, echo=False, ampl_range=[4000,10000], freq_range=[1500,10500], unwrap=False,
fname=dir_plots+'/'+pname, dB=False, logx=False, phi_range=[-180,180])
files = glob.glob(dir_Packets + '/*.af0')
files.sort()
print(len(files))
for file in files:
print(os.path.basename(file))
signals_ASM = [('B1', 1.), ('B2', 1.), ('B3', 1.), ('E1', 1.), ('E2', 1.)]
freqs_F0_ASM = [f for f in range(1632, 9985, 96)]
calib_ASM_F0 = buildCalib_Bruno(files[23:23+88], freqs_F0_ASM, datatype='ASM_F0', echo=False, fig=False,
signals=signals_ASM, i1=3 )
pname = case + '_' + os.path.basename(files[0]).replace('.af0','_ASM.svg')
fig_TF_LFR_allRel(calib_ASM_F0, echo=False, ampl_range=[4000,10000], freq_range=[1500,10500], unwrap=False,
fname=dir_plots+'/'+pname, dB=False, logx=False, phi_range=[-180,180])
pname = case + '_' + 'diff_ASM-SWF_zoom.svg'
fig_diff_TF_LFR_allrel(calib_ASM_F0, calib_SWF_F0_5, echo=False, ampl_range=[-0.1, 0.05], freq_range=[1500,10500],
fname=dir_plots+'/'+pname, dB=False, logx=False, rho_range=[-0.0001,0.0001], phi_range=[-0.1,0.1])
pname = case + '_' + 'diff_ASM-SWF.svg'
fig_diff_TF_LFR_allrel(calib_ASM_F0, calib_SWF_F0_5, echo=False, ampl_range=[-1., 1], freq_range=[1500,10500],
fname=dir_plots+'/'+pname, dB=False, logx=False, rho_range=[-10.,1.], phi_range=[-5.,1.])
case = 'ctc-900'
dir_Packets = dir_data + "/2022_03_22_ctc-900_EM-FSW_3.3.0.7_unitaires_ALE/decom"
files = glob.glob(dir_Packets + '/*.sf0')
files.sort()
print(len(files))
for file in files:
print(os.path.basename(file))
88 2022_03_22_13_49_52_packet_record_NORMAL.sf0 2022_03_22_13_50_46_packet_record_NORMAL.sf0 2022_03_22_13_51_40_packet_record_NORMAL.sf0 2022_03_22_13_52_34_packet_record_NORMAL.sf0 2022_03_22_13_53_28_packet_record_NORMAL.sf0 2022_03_22_13_54_22_packet_record_NORMAL.sf0 2022_03_22_13_55_16_packet_record_NORMAL.sf0 2022_03_22_13_56_10_packet_record_NORMAL.sf0 2022_03_22_13_57_04_packet_record_NORMAL.sf0 2022_03_22_13_57_58_packet_record_NORMAL.sf0 2022_03_22_13_58_52_packet_record_NORMAL.sf0 2022_03_22_13_59_46_packet_record_NORMAL.sf0 2022_03_22_14_00_40_packet_record_NORMAL.sf0 2022_03_22_14_01_34_packet_record_NORMAL.sf0 2022_03_22_14_02_28_packet_record_NORMAL.sf0 2022_03_22_14_03_22_packet_record_NORMAL.sf0 2022_03_22_14_04_16_packet_record_NORMAL.sf0 2022_03_22_14_05_10_packet_record_NORMAL.sf0 2022_03_22_14_06_04_packet_record_NORMAL.sf0 2022_03_22_14_06_58_packet_record_NORMAL.sf0 2022_03_22_14_07_52_packet_record_NORMAL.sf0 2022_03_22_14_08_46_packet_record_NORMAL.sf0 2022_03_22_14_09_40_packet_record_NORMAL.sf0 2022_03_22_14_10_34_packet_record_NORMAL.sf0 2022_03_22_14_11_28_packet_record_NORMAL.sf0 2022_03_22_14_12_22_packet_record_NORMAL.sf0 2022_03_22_14_13_16_packet_record_NORMAL.sf0 2022_03_22_14_14_10_packet_record_NORMAL.sf0 2022_03_22_14_15_04_packet_record_NORMAL.sf0 2022_03_22_14_15_58_packet_record_NORMAL.sf0 2022_03_22_14_16_52_packet_record_NORMAL.sf0 2022_03_22_14_17_46_packet_record_NORMAL.sf0 2022_03_22_14_18_40_packet_record_NORMAL.sf0 2022_03_22_14_19_34_packet_record_NORMAL.sf0 2022_03_22_14_20_28_packet_record_NORMAL.sf0 2022_03_22_14_21_22_packet_record_NORMAL.sf0 2022_03_22_14_22_16_packet_record_NORMAL.sf0 2022_03_22_14_23_10_packet_record_NORMAL.sf0 2022_03_22_14_24_04_packet_record_NORMAL.sf0 2022_03_22_14_24_58_packet_record_NORMAL.sf0 2022_03_22_14_25_52_packet_record_NORMAL.sf0 2022_03_22_14_26_46_packet_record_NORMAL.sf0 2022_03_22_14_27_40_packet_record_NORMAL.sf0 2022_03_22_14_28_34_packet_record_NORMAL.sf0 2022_03_22_14_29_28_packet_record_NORMAL.sf0 2022_03_22_14_30_22_packet_record_NORMAL.sf0 2022_03_22_14_31_16_packet_record_NORMAL.sf0 2022_03_22_14_32_10_packet_record_NORMAL.sf0 2022_03_22_14_33_04_packet_record_NORMAL.sf0 2022_03_22_14_33_58_packet_record_NORMAL.sf0 2022_03_22_14_34_52_packet_record_NORMAL.sf0 2022_03_22_14_35_46_packet_record_NORMAL.sf0 2022_03_22_14_36_40_packet_record_NORMAL.sf0 2022_03_22_14_37_34_packet_record_NORMAL.sf0 2022_03_22_14_38_28_packet_record_NORMAL.sf0 2022_03_22_14_39_22_packet_record_NORMAL.sf0 2022_03_22_14_40_16_packet_record_NORMAL.sf0 2022_03_22_14_41_10_packet_record_NORMAL.sf0 2022_03_22_14_42_04_packet_record_NORMAL.sf0 2022_03_22_14_42_58_packet_record_NORMAL.sf0 2022_03_22_14_43_52_packet_record_NORMAL.sf0 2022_03_22_14_44_46_packet_record_NORMAL.sf0 2022_03_22_14_45_40_packet_record_NORMAL.sf0 2022_03_22_14_46_34_packet_record_NORMAL.sf0 2022_03_22_14_47_28_packet_record_NORMAL.sf0 2022_03_22_14_48_22_packet_record_NORMAL.sf0 2022_03_22_14_49_16_packet_record_NORMAL.sf0 2022_03_22_14_50_10_packet_record_NORMAL.sf0 2022_03_22_14_51_04_packet_record_NORMAL.sf0 2022_03_22_14_51_58_packet_record_NORMAL.sf0 2022_03_22_14_52_52_packet_record_NORMAL.sf0 2022_03_22_14_53_46_packet_record_NORMAL.sf0 2022_03_22_14_54_40_packet_record_NORMAL.sf0 2022_03_22_14_55_34_packet_record_NORMAL.sf0 2022_03_22_14_56_28_packet_record_NORMAL.sf0 2022_03_22_14_57_22_packet_record_NORMAL.sf0 2022_03_22_14_58_16_packet_record_NORMAL.sf0 2022_03_22_14_59_10_packet_record_NORMAL.sf0 2022_03_22_15_00_04_packet_record_NORMAL.sf0 2022_03_22_15_00_58_packet_record_NORMAL.sf0 2022_03_22_15_01_52_packet_record_NORMAL.sf0 2022_03_22_15_02_46_packet_record_NORMAL.sf0 2022_03_22_15_03_40_packet_record_NORMAL.sf0 2022_03_22_15_04_34_packet_record_NORMAL.sf0 2022_03_22_15_05_28_packet_record_NORMAL.sf0 2022_03_22_15_06_22_packet_record_NORMAL.sf0 2022_03_22_15_07_16_packet_record_NORMAL.sf0 2022_03_22_15_08_10_packet_record_NORMAL.sf0
freqs_F0 = np.arange(1632, 9985, 96)
print(len(freqs_F0))
print(freqs_F0)
88 [1632 1728 1824 1920 2016 2112 2208 2304 2400 2496 2592 2688 2784 2880 2976 3072 3168 3264 3360 3456 3552 3648 3744 3840 3936 4032 4128 4224 4320 4416 4512 4608 4704 4800 4896 4992 5088 5184 5280 5376 5472 5568 5664 5760 5856 5952 6048 6144 6240 6336 6432 6528 6624 6720 6816 6912 7008 7104 7200 7296 7392 7488 7584 7680 7776 7872 7968 8064 8160 8256 8352 8448 8544 8640 8736 8832 8928 9024 9120 9216 9312 9408 9504 9600 9696 9792 9888 9984]
#signals_ASM = [('B1', 1.), ('B2', 1.), ('B3', 1.), ('E1', 1.), ('E2', 1.)]
signals_ASM = [('B1', 1.5), ('B2', 2.), ('B3', 2.5), ('E1', .5), ('E2', 1.)]
freqs_F0 = [f for f in range(1632, 9985, 96)]
calib_SWF_F0_5 = buildCalib_Bruno(files, freqs_F0, datatype='SWF_F0', echo=False, fig=False, signals=signals_ASM)
pname = case + '_' + os.path.basename(files[0]).replace('.sf0','_SWF_5.svg')
fig_TF_LFR_allRel(calib_SWF_F0_5, echo=False, ampl_range=[4000,10000], freq_range=[1500,10500], unwrap=False,
fname=dir_plots+'/'+pname, dB=False, logx=False, phi_range=[-180,180], figsize=(14,16))
files = glob.glob(dir_Packets + '/*.af0')
files.sort()
print(len(files))
for file in files:
print(os.path.basename(file))
88 2022_03_22_13_49_52_packet_record_NORMAL.af0 2022_03_22_13_50_46_packet_record_NORMAL.af0 2022_03_22_13_51_40_packet_record_NORMAL.af0 2022_03_22_13_52_34_packet_record_NORMAL.af0 2022_03_22_13_53_28_packet_record_NORMAL.af0 2022_03_22_13_54_22_packet_record_NORMAL.af0 2022_03_22_13_55_16_packet_record_NORMAL.af0 2022_03_22_13_56_10_packet_record_NORMAL.af0 2022_03_22_13_57_04_packet_record_NORMAL.af0 2022_03_22_13_57_58_packet_record_NORMAL.af0 2022_03_22_13_58_52_packet_record_NORMAL.af0 2022_03_22_13_59_46_packet_record_NORMAL.af0 2022_03_22_14_00_40_packet_record_NORMAL.af0 2022_03_22_14_01_34_packet_record_NORMAL.af0 2022_03_22_14_02_28_packet_record_NORMAL.af0 2022_03_22_14_03_22_packet_record_NORMAL.af0 2022_03_22_14_04_16_packet_record_NORMAL.af0 2022_03_22_14_05_10_packet_record_NORMAL.af0 2022_03_22_14_06_04_packet_record_NORMAL.af0 2022_03_22_14_06_58_packet_record_NORMAL.af0 2022_03_22_14_07_52_packet_record_NORMAL.af0 2022_03_22_14_08_46_packet_record_NORMAL.af0 2022_03_22_14_09_40_packet_record_NORMAL.af0 2022_03_22_14_10_34_packet_record_NORMAL.af0 2022_03_22_14_11_28_packet_record_NORMAL.af0 2022_03_22_14_12_22_packet_record_NORMAL.af0 2022_03_22_14_13_16_packet_record_NORMAL.af0 2022_03_22_14_14_10_packet_record_NORMAL.af0 2022_03_22_14_15_04_packet_record_NORMAL.af0 2022_03_22_14_15_58_packet_record_NORMAL.af0 2022_03_22_14_16_52_packet_record_NORMAL.af0 2022_03_22_14_17_46_packet_record_NORMAL.af0 2022_03_22_14_18_40_packet_record_NORMAL.af0 2022_03_22_14_19_34_packet_record_NORMAL.af0 2022_03_22_14_20_28_packet_record_NORMAL.af0 2022_03_22_14_21_22_packet_record_NORMAL.af0 2022_03_22_14_22_16_packet_record_NORMAL.af0 2022_03_22_14_23_10_packet_record_NORMAL.af0 2022_03_22_14_24_04_packet_record_NORMAL.af0 2022_03_22_14_24_58_packet_record_NORMAL.af0 2022_03_22_14_25_52_packet_record_NORMAL.af0 2022_03_22_14_26_46_packet_record_NORMAL.af0 2022_03_22_14_27_40_packet_record_NORMAL.af0 2022_03_22_14_28_34_packet_record_NORMAL.af0 2022_03_22_14_29_28_packet_record_NORMAL.af0 2022_03_22_14_30_22_packet_record_NORMAL.af0 2022_03_22_14_31_16_packet_record_NORMAL.af0 2022_03_22_14_32_10_packet_record_NORMAL.af0 2022_03_22_14_33_04_packet_record_NORMAL.af0 2022_03_22_14_33_58_packet_record_NORMAL.af0 2022_03_22_14_34_52_packet_record_NORMAL.af0 2022_03_22_14_35_46_packet_record_NORMAL.af0 2022_03_22_14_36_40_packet_record_NORMAL.af0 2022_03_22_14_37_34_packet_record_NORMAL.af0 2022_03_22_14_38_28_packet_record_NORMAL.af0 2022_03_22_14_39_22_packet_record_NORMAL.af0 2022_03_22_14_40_16_packet_record_NORMAL.af0 2022_03_22_14_41_10_packet_record_NORMAL.af0 2022_03_22_14_42_04_packet_record_NORMAL.af0 2022_03_22_14_42_58_packet_record_NORMAL.af0 2022_03_22_14_43_52_packet_record_NORMAL.af0 2022_03_22_14_44_46_packet_record_NORMAL.af0 2022_03_22_14_45_40_packet_record_NORMAL.af0 2022_03_22_14_46_34_packet_record_NORMAL.af0 2022_03_22_14_47_28_packet_record_NORMAL.af0 2022_03_22_14_48_22_packet_record_NORMAL.af0 2022_03_22_14_49_16_packet_record_NORMAL.af0 2022_03_22_14_50_10_packet_record_NORMAL.af0 2022_03_22_14_51_04_packet_record_NORMAL.af0 2022_03_22_14_51_58_packet_record_NORMAL.af0 2022_03_22_14_52_52_packet_record_NORMAL.af0 2022_03_22_14_53_46_packet_record_NORMAL.af0 2022_03_22_14_54_40_packet_record_NORMAL.af0 2022_03_22_14_55_34_packet_record_NORMAL.af0 2022_03_22_14_56_28_packet_record_NORMAL.af0 2022_03_22_14_57_22_packet_record_NORMAL.af0 2022_03_22_14_58_16_packet_record_NORMAL.af0 2022_03_22_14_59_10_packet_record_NORMAL.af0 2022_03_22_15_00_04_packet_record_NORMAL.af0 2022_03_22_15_00_58_packet_record_NORMAL.af0 2022_03_22_15_01_52_packet_record_NORMAL.af0 2022_03_22_15_02_46_packet_record_NORMAL.af0 2022_03_22_15_03_40_packet_record_NORMAL.af0 2022_03_22_15_04_34_packet_record_NORMAL.af0 2022_03_22_15_05_28_packet_record_NORMAL.af0 2022_03_22_15_06_22_packet_record_NORMAL.af0 2022_03_22_15_07_16_packet_record_NORMAL.af0 2022_03_22_15_08_10_packet_record_NORMAL.af0
iasm = 3
#signals_ASM = [('B1', 1.), ('B2', 1.), ('B3', 1.), ('E1', 1.), ('E2', 1.)]
signals_ASM = [('B1', 1.5), ('B2', 2.), ('B3', 2.5), ('E1', .5), ('E2', 1.)]
freqs_F0_ASM = [f for f in range(1632, 9985, 96)]
calib_ASM_F0 = buildCalib_Bruno(files, freqs_F0_ASM, datatype='ASM_F0', echo=False, fig=False,
signals=signals_ASM, i1=iasm)
pname = case + '_' + os.path.basename(files[0]).replace('.af0','_ASM.svg')
fig_TF_LFR_allRel(calib_ASM_F0, echo=False, ampl_range=[4000,10000], freq_range=[1500,10500], unwrap=False,
fname=dir_plots+'/'+pname, dB=False, logx=False, phi_range=[-180,180], figsize=(14,16))
pname = case + '_' + 'diff_ASM-SWF.svg'
fig_diff_TF_LFR_allrel(calib_ASM_F0, calib_SWF_F0_5, echo=False, ampl_range=[-1., 1], freq_range=[1500,10500],
fname=dir_plots+'/'+pname, dB=False, logx=False, rho_range=[-10.,1.],
phi_range=[-5.,1.], figsize=(14,16))
pname = case + '_' + 'diff_ASM-SWF_zoom.svg'
fig_diff_TF_LFR_allrel(calib_ASM_F0, calib_SWF_F0_5, echo=False, ampl_range=[-0.1, 0.05], freq_range=[1500,10500],
fname=dir_plots+'/'+pname, dB=False, logx=False, rho_range=[-0.0001,0.0001],
phi_range=[-0.1,0.1], figsize=(14,16))
dir_Packets = dir_data + "/2018_12_03_ctc-510_EM-FSW_3.2.0.24_sansV/decom"
files = glob.glob(dir_Packets + '/*L.1f0')
files.sort()
print(len(files))
for file in files:
print(os.path.basename(file))
files_bp1 = files
files = glob.glob(dir_Packets + '/*L.2f0')
files.sort()
print(len(files))
for file in files:
print(os.path.basename(file))
files_bp2 = files
files = glob.glob(dir_Packets + '/*L.af0')
files.sort()
print(len(files))
for file in files:
print(os.path.basename(file))
files_asm = files
outsideFrq1 = [ 12., 24., 36., 48., 60., 72., 84., 96., 192., 288., 384., 480., 576., 672., 768., 864., 960.,
1056., 1152., 1248., 1344., 1440., 1536.]
outsideFrq2 = [10080., 10176., 10272., 10368., 10464., 10560., 10656., 10752., 10848., 10944., 11040., 11136.,
11232., 11328., 11424., 11520.,11616., 11712., 11808., 11904., 12000., 12096., 12192., 12288.,
13056., 13824., 14592., 15360., 16128., 16896., 17664., 18432., 19200., 19968., 20736., 21504.,
22272., 23040., 23808., 24576., 25344., 26112., 26880., 27648., 28416., 29184., 29952., 30720.]
insideFrqs = np.arange(1632, 9985, 96)
print("all files:", len(outsideFrq1) + len(outsideFrq2) + len(insideFrqs))
print("outside Frq1 files:", len(outsideFrq1))
print("outside Frq2 files:", len(outsideFrq2))
freqs_F0 = insideFrqs
print("inside F0 freqs files:", len(freqs_F0))
freqs_F0
#head_format = 10*'{:>11s},'
#data_format = 10*'{:11.5f},'
#units = [' '] + 10*['(%)']
heads = 'k', 'd_sm', 'd_psd_b', 'd_psd_e', 'd_dop', 'd_ellip', 'd_nvec', 'd_sx', 'd_sx_arg', 'd_vphi', 'd_vphi_arg'
units = [' ', '(%)', '(%)', '(%)', '(%)', '(%)', ' ', '(%)', ' ', '(%)', ' ']
head_format = '{:>3s},{:>8s},{:>8s},{:>8s},{:>8s},{:>8s},{:>8s},{:>8s},{:>11s},{:>8s},{:>11s}'
unit_format = '{:3s} {:>8s} {:>8s} {:>8s} {:>8s} {:>8s} {:>8s} {:>8s} {:>11s} {:>8s} {:>11s}'
data_format = '{:3d},{:8.2f},{:8.2f},{:8.2f},{:8.2f},{:8.2f},{:8.3f},{:8.2f},{:11d},{:8.2f},{:11d}'
k = 0
d = compare_bp2_asm(files_bp2[k], files_asm[k], l_bp2=1, l_asm=7+2, ifreq_bp2=None, echo=True)
print()
print(head_format.format(*heads))
print(unit_format.format(*units))
print(data_format.format(k, *d))
print()
d = compare_bp2_asm(files_bp2[k], files_asm[k], l_bp2=0, l_asm=2+2, ifreq_bp2=None, echo=True)
print()
print(head_format.format(*heads))
print(unit_format.format(*units))
print(data_format.format(k, *d))
k = 1
d = compare_bp2_asm(files_bp2[k], files_asm[k], l_bp2=1, l_asm=7, ifreq_bp2=None, echo=True)
print()
print(head_format.format(*heads))
print(unit_format.format(*units))
print(data_format.format(k, *d))
print()
d = compare_bp2_asm(files_bp2[k], files_asm[k], l_bp2=0, l_asm=2, ifreq_bp2=None, echo=True)
print()
print(head_format.format(*heads))
print(unit_format.format(*units))
print(data_format.format(k, *d))
print()
print(head_format.format(*heads))
print(unit_format.format(*units))
for k, (f_bp2, f_asm) in enumerate(zip(files_bp2, files_asm)):
d = compare_bp2_asm(f_bp2, f_asm, l_bp2=0, l_asm=2, ifreq_bp2=None, echo=False)
print(data_format.format(k, *d))
k = 114
d = compare_bp2_asm(files_bp2[k], files_asm[k], l_bp2=0, l_asm=2, ifreq_bp2=None, echo=True)
print()
print(head_format.format(*heads))
print(unit_format.format(*units))
print(data_format.format(k, *d))
print()
print(head_format.format(*heads))
print(unit_format.format(*units))
for k, (f_bp2, f_asm) in enumerate(zip(files_bp2, files_asm)):
d = compare_bp2_asm(f_bp2, f_asm, l_bp2=1, l_asm=7, ifreq_bp2=None, echo=False)
print(data_format.format(k, *d))
k = 37
d = compare_bp2_asm(files_bp2[k], files_asm[k], l_bp2=1, l_asm=7, ifreq_bp2=None, echo=True)
print()
print(head_format.format(*heads))
print(unit_format.format(*units))
print(data_format.format(k, *d))
print()
print()
print(head_format.format(*heads))
print(unit_format.format(*units))
for k in range(88):
d = compare_bp2_asm(files_bp2[23+k], files_asm[23+k], l_bp2=0, l_asm=2, ifreq_bp2=k//8, echo=False)
print(data_format.format(k, *d))
k = 44
d = compare_bp2_asm(files_bp2[23+k], files_asm[23+k], l_bp2=0, l_asm=2, ifreq_bp2=k//8, echo=True)
print()
print(head_format.format(*heads))
print(unit_format.format(*units))
print(data_format.format(k, *d))
k = 0
d = compare_bp2_asm(files_bp2[23+k], files_asm[23+k], l_bp2=0, l_asm=2, ifreq_bp2=None, echo=True)
print()
print(head_format.format(*heads))
print(unit_format.format(*units))
print(data_format.format(k, *d))
heads_bp1 = 'k', 'd_psd_b', 'd_psd_e', 'd_dop', 'd_ellip', 'd_nvec', 'd_sx', 'd_sx_arg', 'd_vphi', 'd_vphi_arg'
units_bp1 = [' ', '(%)', '(%)', '(%)', '(%)', ' ', '(%)', ' ', '(%)', ' ']
head_format_bp1 = '{:>3s},{:>8s},{:>8s},{:>8s},{:>8s},{:>8s},{:>8s},{:>11s},{:>8s},{:>11s}'
unit_format_bp1 = '{:3s} {:>8s} {:>8s} {:>8s} {:>8s} {:>8s} {:>8s} {:>11s} {:>8s} {:>11s}'
data_format_bp1 = '{:3d},{:8.2f},{:8.2f},{:8.2f},{:8.2f},{:8.3f},{:8.2f},{:11.1f},{:8.2f},{:11.1f}'
k = 0
d = compare_bp1_asm(files_bp1[0], files_asm[0], l_bp1=4, l_asm=4, ifreq_bp1=None, echo=True)
print()
print(head_format_bp1.format(*heads_bp1))
print(unit_format_bp1.format(*units_bp1))
print(data_format_bp1.format(k, *d))
print()
print()
print(head_format_bp1.format(*heads_bp1))
print(unit_format_bp1.format(*units_bp1))
for k, (f_bp1, f_asm) in enumerate(zip(files_bp1, files_asm)):
d = compare_bp1_asm(f_bp1, f_asm, l_bp1=4, l_asm=4, ifreq_bp1=None, echo=False)
print(data_format_bp1.format(k, *d))
k =11
d = compare_bp1_asm(files_bp1[k], files_asm[k], l_bp1=4, l_asm=4, ifreq_bp1=None, echo=True)
print()
print(head_format_bp1.format(*heads_bp1))
print(unit_format_bp1.format(*units_bp1))
print(data_format_bp1.format(k, *d))
print()
print()
print(head_format_bp1.format(*heads_bp1))
print(unit_format_bp1.format(*units_bp1))
for k in range(88):
d = compare_bp1_asm(files_bp1[23+k], files_asm[23+k], l_bp1=4, l_asm=4, ifreq_bp1=k//8, echo=False)
print(data_format_bp1.format(k, *d))
k = 79
d = compare_bp1_asm(files_bp1[k+23], files_asm[k+23], l_bp1=4, l_asm=4, ifreq_bp1=k//8, echo=True)
print()
print(head_format_bp1.format(*heads_bp1))
print(unit_format_bp1.format(*units_bp1))
print(data_format_bp1.format(k, *d))
print()
heads_bp1 = 'k', 'd_psd_b', 'd_psd_e', 'd_dop', 'd_ellip', 'd_nvec', 'd_sx', 'd_sx_arg', 'd_vphi', 'd_vphi_arg'
units_bp1 = [' ', '(%)', '(%)', '(%)', '(%)', ' ', '(%)', ' ', '(%)', ' ']
head_format_bp1 = '{:>3s},{:>8s},{:>8s},{:>8s},{:>8s},{:>8s},{:>8s},{:>11s},{:>8s},{:>11s}'
unit_format_bp1 = '{:3s} {:>8s} {:>8s} {:>8s} {:>8s} {:>8s} {:>8s} {:>11s} {:>8s} {:>11s}'
data_format_bp1 = '{:3d},{:8.2f},{:8.2f},{:8.2f},{:8.2f},{:8.3f},{:8.2f},{:11.1f},{:8.2f},{:11.1f}'
k = 0
d = compare_bp1_bp2(files_bp1[k], files_bp2[k], l_bp1=4, l_bp2=0, ifreq_bp1=None, echo=True)
print()
print(head_format_bp1.format(*heads_bp1))
print(unit_format_bp1.format(*units_bp1))
print(data_format_bp1.format(k, *d))
print()
k = 1
d = compare_bp1_bp2(files_bp1[k], files_bp2[k], l_bp1=4-2, l_bp2=0, ifreq_bp1=None, echo=True)
print()
print(head_format_bp1.format(*heads_bp1))
print(unit_format_bp1.format(*units_bp1))
print(data_format_bp1.format(k, *d))
print()
print()
print(head_format_bp1.format(*heads_bp1))
print(unit_format_bp1.format(*units_bp1))
for k, (f_bp1, f_bp2) in enumerate(zip(files_bp1, files_bp2)):
d = compare_bp1_bp2(f_bp1, f_bp2, l_bp1=4-2, l_bp2=0, ifreq_bp1=None, echo=False)
print(data_format_bp1.format(k, *d))
k = 90
d = compare_bp1_bp2(files_bp1[k], files_bp2[k], l_bp1=4-2, l_bp2=0, ifreq_bp1=None, echo=True)
print()
print(head_format_bp1.format(*heads_bp1))
print(unit_format_bp1.format(*units_bp1))
print(data_format_bp1.format(k, *d))
print()
print()
print(head_format_bp1.format(*heads_bp1))
print(unit_format_bp1.format(*units_bp1))
for k in range(88):
d = compare_bp1_bp2(files_bp1[23+k], files_bp2[23+k], l_bp1=4-2, l_bp2=0, ifreq_bp1=k//8, echo=False)
print(data_format_bp1.format(k, *d))
k = 47
d = compare_bp1_bp2(files_bp1[k+23], files_bp2[k+23], l_bp1=4-2, l_bp2=0, ifreq_bp1=k//8, echo=True)
print()
print(head_format_bp1.format(*heads_bp1))
print(unit_format_bp1.format(*units_bp1))
print(data_format_bp1.format(k, *d))
print()
case = 'ctc-5110'
dir_Packets = dir_data + "/2017_01_09_ctc-5110/decom"
files = glob.glob(dir_Packets + '/*.sf1')
files.sort()
print(len(files))
for file in files:
print(os.path.basename(file))
freqs_F1 = [f for f in range(96, 1745, 16) if f != 1424]
calib_SWF_F1 = buildCalib_Bruno(files, freqs_F1, datatype='SWF_F1', echo=False, fig=False)
pname = case + '_' + os.path.basename(files[0]).replace('.sf1','_SWF.svg')
fig_TF_LFR_allRel(calib_SWF_F1, echo=False, ampl_range=[0,10000], freq_range=[0,2000], unwrap=False,
fname=dir_plots+'/'+pname, dB=False, logx=False, phi_range=[-180,180])
signals_ASM = [('B1', 1.), ('B2', 1.), ('B3', 1.), ('E1', 1.), ('E2', 1.)]
freqs_F1 = [f for f in range(96, 1745, 16) if f != 1424]
calib_SWF_F1_5 = buildCalib_Bruno(files, freqs_F1, datatype='SWF_F1', echo=False, fig=False, signals=signals_ASM )
pname = case + '_' + os.path.basename(files[0]).replace('.sf1','_SWF_5.svg')
fig_TF_LFR_allRel(calib_SWF_F1_5, echo=False, ampl_range=[0,10000], freq_range=[0,2000], unwrap=False,
fname=dir_plots+'/'+pname, dB=False, logx=False, phi_range=[-180,180])
dir_Packets = dir_data + "/2017_01_09_ctc-5110/decom"
files = glob.glob(dir_Packets + '/*.af1')
files.sort()
print(len(files))
for file in files:
print(os.path.basename(file))
files_bis = files.copy()
files_bis.remove(files[83])
print(len(files_bis))
iasm = 3
signals_ASM = [('B1', 1.), ('B2', 1.), ('B3', 1.), ('E1', 1.), ('E2', 1.)]
freqs_F1_ASM = [f for f in range(96, 1745, 16)]
calib_ASM_F1 = buildCalib_Bruno(files, freqs_F1_ASM, datatype='ASM_F1', echo=False, fig=False, signals=signals_ASM, i1=iasm )
pname = case + '_' + os.path.basename(files[0]).replace('.af1','_ASM.svg')
fig_TF_LFR_allRel(calib_ASM_F1, echo=False, ampl_range=[0,10000], freq_range=[0,2000], unwrap=False,
fname=dir_plots+'/'+pname, dB=False, logx=False, phi_range=[-180,180])
signals_ASM = [('B1', 1.), ('B2', 1.), ('B3', 1.), ('E1', 1.), ('E2', 1.)]
freqs_F1_ASM_bis = [f for f in range(96, 1745, 16) if f != 1424]
calib_ASM_F1_bis = buildCalib_Bruno(files_bis, freqs_F1_ASM_bis, datatype='ASM_F1', echo=False, fig=False,
signals=signals_ASM, i1=iasm )
pname = case + '_' + os.path.basename(files[0]).replace('.af1','_ASM_bis.svg')
fig_TF_LFR_allRel(calib_ASM_F1_bis, echo=False, ampl_range=[0,10000], freq_range=[0,2000], unwrap=False,
fname=dir_plots+'/'+pname, dB=False, logx=False, phi_range=[-180,180])
pname = case + '_' + 'diff_ASM-SWF.svg'
fig_diff_TF_LFR_allrel(calib_ASM_F1_bis, calib_SWF_F1_5, echo=False, ampl_range=[-10., 500], freq_range=[0,2000],
fname=dir_plots+'/'+pname, dB=False, logx=False, rho_range=[-100.,100.], phi_range=[-360.,300.])
pname = case + '_' + 'diff_ASM-SWF_zoom.svg'
fig_diff_TF_LFR_allrel(calib_ASM_F1_bis, calib_SWF_F1_5, echo=False, ampl_range=[-0.1, 0.05], freq_range=[0,2000],
fname=dir_plots+'/'+pname, dB=False, logx=False, rho_range=[-0.01,0.0001], phi_range=[-.1,.1])
case = 'ctc-511'
dir_Packets = dir_data + "/2018_12_04_ctc-511_EM-FSW_3.2.0.24_sansV/decom"
files = glob.glob(dir_Packets + '/*.sf1')
files.sort()
print(len(files))
for file in files:
print(os.path.basename(file))
freqs_F1 = np.arange(96, 1745, 16)
print(len(freqs_F1))
print(freqs_F1)
freqs_F1 = [f for f in range(96, 1745, 16)]
calib_SWF_F1 = buildCalib_Bruno(files, freqs_F1, datatype='SWF_F1', echo=False, fig=False)
pname = case + '_' + os.path.basename(files[0]).replace('.sf1','_SWF.svg')
fig_TF_LFR_allRel(calib_SWF_F1, echo=False, ampl_range=[0,10000], freq_range=[0,2000], unwrap=False,
fname=dir_plots+'/'+pname, dB=False, logx=False, phi_range=[-180,180])
signals_ASM = [('B1', 1.), ('B2', 1.), ('B3', 1.), ('E1', 1.), ('E2', 1.)]
freqs_F1 = [f for f in range(96, 1745, 16)]
calib_SWF_F1_5 = buildCalib_Bruno(files, freqs_F1, datatype='SWF_F1', echo=False, fig=False, signals=signals_ASM )
pname = case + '_' + os.path.basename(files[0]).replace('.sf1','_SWF_5.svg')
fig_TF_LFR_allRel(calib_SWF_F1_5, echo=False, ampl_range=[0,10000], freq_range=[0,2000], unwrap=False,
fname=dir_plots+'/'+pname, dB=False, logx=False, phi_range=[-180,180])
files = glob.glob(dir_Packets + '/*.af1')
files.sort()
print(len(files))
for file in files:
print(os.path.basename(file))
iasm = 3
signals_ASM = [('B1', 1.), ('B2', 1.), ('B3', 1.), ('E1', 1.), ('E2', 1.)]
freqs_F1_ASM = [f for f in range(96, 1745, 16)]
calib_ASM_F1 = buildCalib_Bruno(files, freqs_F1_ASM, datatype='ASM_F1', echo=False, fig=False,
signals=signals_ASM, i1=iasm )
pname = case + '_' + os.path.basename(files[0]).replace('.af1','_ASM.svg')
fig_TF_LFR_allRel(calib_ASM_F1, echo=False, ampl_range=[0,10000], freq_range=[0,2000], unwrap=False,
fname=dir_plots+'/'+pname, dB=False, logx=False, phi_range=[-180,180])
pname = case + '_' + 'diff_ASM-SWF.svg'
fig_diff_TF_LFR_allrel(calib_ASM_F1, calib_SWF_F1_5, echo=False, ampl_range=[-1., 1], freq_range=[0,2000],
fname=dir_plots+'/'+pname, dB=False, logx=False, rho_range=[-1.,1.], phi_range=[-3.,3.])
pname = case + '_' + 'diff_ASM-SWF_zoom.svg'
fig_diff_TF_LFR_allrel(calib_ASM_F1, calib_SWF_F1_5, echo=False, ampl_range=[-0.1, 0.05], freq_range=[0,2000],
fname=dir_plots+'/'+pname, dB=False, logx=False, rho_range=[-0.01,0.0001], phi_range=[-.1,.1])
case = 'ctc-901'
#dir_Packets = dir_data + "/2022_03_21_ctc-901_EM-FSW_3.3.0.7_unitaires_ALE/decom"
dir_Packets = dir_data + "/2022_03_22_ctc-901_EM-FSW_3.3.0.7_unitaires_ALE/decom"
files = glob.glob(dir_Packets + '/*.sf1')
files.sort()
print(len(files))
for file in files:
print(os.path.basename(file))
freqs_F1 = np.arange(96, 1745, 16)
print(len(freqs_F1))
print(freqs_F1)
freqs_F1 = [f for f in range(96, 1745, 16)]
calib_SWF_F1 = buildCalib_Bruno(files, freqs_F1, datatype='SWF_F1', echo=False, fig=False)
pname = case + '_' + os.path.basename(files[0]).replace('.sf1','_SWF.svg')
fig_TF_LFR_allRel(calib_SWF_F1, echo=False, ampl_range=[0,10000], freq_range=[0,2000], unwrap=False,
fname=dir_plots+'/'+pname, dB=False, logx=False, phi_range=[-180,180])
#signals_ASM = [('B1', 1.), ('B2', 1.), ('B3', 1.), ('E1', 1.), ('E2', 1.)]
signals_ASM = [('B1', 1.5), ('B2', 2.), ('B3', 2.5), ('E1', .5), ('E2', 1.)]
freqs_F1 = [f for f in range(96, 1745, 16)]
calib_SWF_F1_5 = buildCalib_Bruno(files, freqs_F1, datatype='SWF_F1', echo=False, fig=False, signals=signals_ASM)
pname = case + '_' + os.path.basename(files[0]).replace('.sf1','_SWF_5.svg')
fig_TF_LFR_allRel(calib_SWF_F1_5, echo=False, ampl_range=[0,10000], freq_range=[0,2000], unwrap=False,
fname=dir_plots+'/'+pname, dB=False, logx=False, phi_range=[-180,180], figsize=(14,16))
files = glob.glob(dir_Packets + '/*.af1')
files.sort()
print(len(files))
for file in files:
print(os.path.basename(file))
iasm = 3
#signals_ASM = [('B1', 1.), ('B2', 1.), ('B3', 1.), ('E1', 1.), ('E2', 1.)]
signals_ASM = [('B1', 1.5), ('B2', 2.), ('B3', 2.5), ('E1', .5), ('E2', 1.)]
freqs_F1_ASM = [f for f in range(96, 1745, 16)]
calib_ASM_F1 = buildCalib_Bruno(files, freqs_F1_ASM, datatype='ASM_F1', echo=False, fig=False,
signals=signals_ASM, i1=iasm)
pname = case + '_' + os.path.basename(files[0]).replace('.af1','_ASM.svg')
fig_TF_LFR_allRel(calib_ASM_F1, echo=False, ampl_range=[0,10000], freq_range=[0,2000], unwrap=False,
fname=dir_plots+'/'+pname, dB=False, logx=False, phi_range=[-180,180], figsize=(14,16))
pname = case + '_' + 'diff_ASM-SWF.svg'
fig_diff_TF_LFR_allrel(calib_ASM_F1, calib_SWF_F1_5, echo=False, ampl_range=[-1., 1], freq_range=[0,2000],
fname=dir_plots+'/'+pname, dB=False, logx=False, rho_range=[-1.,1.], phi_range=[-3.,3.],
figsize=(14,16))
pname = case + '_' + 'diff_ASM-SWF_zoom.svg'
fig_diff_TF_LFR_allrel(calib_ASM_F1, calib_SWF_F1_5, echo=False, ampl_range=[-0.1, 0.05], freq_range=[0,2000],
fname=dir_plots+'/'+pname, dB=False, logx=False, rho_range=[-0.001,0.0001],
phi_range=[-.1,.1], figsize=(14,16))
dir_Packets = dir_data + "/2018_12_04_ctc-511_EM-FSW_3.2.0.24_sansV/decom"
files = glob.glob(dir_Packets + '/*L.1f1')
files.sort()
print(len(files))
for file in files:
print(os.path.basename(file))
files_bp1 = files
files = glob.glob(dir_Packets + '/*L.2f1')
files.sort()
print(len(files))
for file in files:
print(os.path.basename(file))
files_bp2 = files
files = glob.glob(dir_Packets + '/*L.af1')
files.sort()
print(len(files))
for file in files:
print(os.path.basename(file))
files_asm = files
freqs_F1 = np.arange(96, 1745, 16)
print(len(freqs_F1))
freqs_F1
#head_format = 10*'{:>11s},'
#data_format = 10*'{:11.5f},'
#units = [' '] + 10*['(%)']
heads = 'k', 'd_sm', 'd_psd_b', 'd_psd_e', 'd_dop', 'd_ellip', 'd_nvec', 'd_sx', 'd_sx_arg', 'd_vphi', 'd_vphi_arg'
units = [' ', '(%)', '(%)', '(%)', '(%)', '(%)', ' ', '(%)', ' ', '(%)', ' ']
head_format = '{:>3s},{:>8s},{:>8s},{:>8s},{:>8s},{:>8s},{:>8s},{:>8s},{:>11s},{:>8s},{:>11s}'
unit_format = '{:3s} {:>8s} {:>8s} {:>8s} {:>8s} {:>8s} {:>8s} {:>8s} {:>11s} {:>8s} {:>11s}'
data_format = '{:3d},{:8.2f},{:8.2f},{:8.2f},{:8.2f},{:8.2f},{:8.3f},{:8.2f},{:11d},{:8.2f},{:11d}'
k = 0
d = compare_bp2_asm(files_bp2[k], files_asm[k], l_bp2=1, l_asm=7+2, ifreq_bp2=None, echo=True)
print()
print(head_format.format(*heads))
print(unit_format.format(*units))
print(data_format.format(k, *d))
print()
d = compare_bp2_asm(files_bp2[k], files_asm[k], l_bp2=0, l_asm=2+2, ifreq_bp2=None, echo=True)
print()
print(head_format.format(*heads))
print(unit_format.format(*units))
print(data_format.format(k, *d))
k = 1
d = compare_bp2_asm(files_bp2[k], files_asm[k], l_bp2=1, l_asm=7, ifreq_bp2=None, echo=True)
print()
print(head_format.format(*heads))
print(unit_format.format(*units))
print(data_format.format(k, *d))
print()
d = compare_bp2_asm(files_bp2[k], files_asm[k], l_bp2=0, l_asm=2, ifreq_bp2=None, echo=True)
print()
print(head_format.format(*heads))
print(unit_format.format(*units))
print(data_format.format(k, *d))
print()
print(head_format.format(*heads))
print(unit_format.format(*units))
for k, (f_bp2, f_asm) in enumerate(zip(files_bp2, files_asm)):
d = compare_bp2_asm(f_bp2, f_asm, l_bp2=0, l_asm=2, ifreq_bp2=None, echo=False)
print(data_format.format(k, *d))
k = 14
d = compare_bp2_asm(files_bp2[k], files_asm[k], l_bp2=0, l_asm=2, ifreq_bp2=None, echo=True)
print()
print(head_format.format(*heads))
print(unit_format.format(*units))
print(data_format.format(k, *d))
print()
print(head_format.format(*heads))
print(unit_format.format(*units))
for k, (f_bp2, f_asm) in enumerate(zip(files_bp2, files_asm)):
d = compare_bp2_asm(f_bp2, f_asm, l_bp2=1, l_asm=7, ifreq_bp2=None, echo=False)
print(data_format.format(k, *d))
k = 44
d = compare_bp2_asm(files_bp2[k], files_asm[k], l_bp2=1, l_asm=7, ifreq_bp2=None, echo=True)
print()
print(head_format.format(*heads))
print(unit_format.format(*units))
print(data_format.format(k, *d))
print()
print()
print(head_format.format(*heads))
print(unit_format.format(*units))
for k, (f_bp2, f_asm) in enumerate(zip(files_bp2, files_asm)):
d = compare_bp2_asm(f_bp2, f_asm, l_bp2=0, l_asm=2, ifreq_bp2=k//8, echo=False)
print(data_format.format(k, *d))
k = 33
d = compare_bp2_asm(files_bp2[k], files_asm[k], l_bp2=0, l_asm=2, ifreq_bp2=k//8, echo=True)
print()
print(head_format.format(*heads))
print(unit_format.format(*units))
print(data_format.format(k, *d))
heads_bp1 = 'k', 'd_psd_b', 'd_psd_e', 'd_dop', 'd_ellip', 'd_nvec', 'd_sx', 'd_sx_arg', 'd_vphi', 'd_vphi_arg'
units_bp1 = [' ', '(%)', '(%)', '(%)', '(%)', ' ', '(%)', ' ', '(%)', ' ']
head_format_bp1 = '{:>3s},{:>8s},{:>8s},{:>8s},{:>8s},{:>8s},{:>8s},{:>11s},{:>8s},{:>11s}'
unit_format_bp1 = '{:3s} {:>8s} {:>8s} {:>8s} {:>8s} {:>8s} {:>8s} {:>11s} {:>8s} {:>11s}'
data_format_bp1 = '{:3d},{:8.2f},{:8.2f},{:8.2f},{:8.2f},{:8.3f},{:8.2f},{:11.1f},{:8.2f},{:11.1f}'
k = 0
d = compare_bp1_asm(files_bp1[0], files_asm[0], l_bp1=4, l_asm=4, ifreq_bp1=None, echo=True)
print()
print(head_format_bp1.format(*heads_bp1))
print(unit_format_bp1.format(*units_bp1))
print(data_format_bp1.format(k, *d))
print()
print()
print(head_format_bp1.format(*heads_bp1))
print(unit_format_bp1.format(*units_bp1))
for k, (f_bp1, f_asm) in enumerate(zip(files_bp1, files_asm)):
d = compare_bp1_asm(f_bp1, f_asm, l_bp1=4, l_asm=4, ifreq_bp1=None, echo=False)
print(data_format_bp1.format(k, *d))
k = 17
d = compare_bp1_asm(files_bp1[k], files_asm[k], l_bp1=4, l_asm=4, ifreq_bp1=None, echo=True)
print()
print(head_format_bp1.format(*heads_bp1))
print(unit_format_bp1.format(*units_bp1))
print(data_format_bp1.format(k, *d))
print()
k = 40
d = compare_bp1_asm(files_bp1[k], files_asm[k], l_bp1=4, l_asm=4, ifreq_bp1=k//8, echo=True)
print()
print(head_format_bp1.format(*heads_bp1))
print(unit_format_bp1.format(*units_bp1))
print(data_format_bp1.format(k, *d))
print()
print()
print(head_format_bp1.format(*heads_bp1))
print(unit_format_bp1.format(*units_bp1))
for k, (f_bp1, f_asm) in enumerate(zip(files_bp1, files_asm)):
d = compare_bp1_asm(f_bp1, f_asm, l_bp1=4, l_asm=4, ifreq_bp1=k//8, echo=False)
print(data_format_bp1.format(k, *d))
k = 91
d = compare_bp1_asm(files_bp1[k], files_asm[k], l_bp1=4, l_asm=4, ifreq_bp1=k//8, echo=True)
print()
print(head_format_bp1.format(*heads_bp1))
print(unit_format_bp1.format(*units_bp1))
print(data_format_bp1.format(k, *d))
print()
heads_bp1 = 'k', 'd_psd_b', 'd_psd_e', 'd_dop', 'd_ellip', 'd_nvec', 'd_sx', 'd_sx_arg', 'd_vphi', 'd_vphi_arg'
units_bp1 = [' ', '(%)', '(%)', '(%)', '(%)', ' ', '(%)', ' ', '(%)', ' ']
head_format_bp1 = '{:>3s},{:>8s},{:>8s},{:>8s},{:>8s},{:>8s},{:>8s},{:>11s},{:>8s},{:>11s}'
unit_format_bp1 = '{:3s} {:>8s} {:>8s} {:>8s} {:>8s} {:>8s} {:>8s} {:>11s} {:>8s} {:>11s}'
data_format_bp1 = '{:3d},{:8.2f},{:8.2f},{:8.2f},{:8.2f},{:8.3f},{:8.2f},{:11.1f},{:8.2f},{:11.1f}'
k = 0
d = compare_bp1_bp2(files_bp1[k], files_bp2[k], l_bp1=4, l_bp2=0, ifreq_bp1=None, echo=True)
print()
print(head_format_bp1.format(*heads_bp1))
print(unit_format_bp1.format(*units_bp1))
print(data_format_bp1.format(k, *d))
print()
k = 1
d = compare_bp1_bp2(files_bp1[k], files_bp2[k], l_bp1=4-2, l_bp2=0, ifreq_bp1=None, echo=True)
print()
print(head_format_bp1.format(*heads_bp1))
print(unit_format_bp1.format(*units_bp1))
print(data_format_bp1.format(k, *d))
print()
print()
print(head_format_bp1.format(*heads_bp1))
print(unit_format_bp1.format(*units_bp1))
for k, (f_bp1, f_bp2) in enumerate(zip(files_bp1, files_bp2)):
d = compare_bp1_bp2(f_bp1, f_bp2, l_bp1=4-2, l_bp2=0, ifreq_bp1=None, echo=False)
print(data_format_bp1.format(k, *d))
k = 90
d = compare_bp1_bp2(files_bp1[k], files_bp2[k], l_bp1=4-2, l_bp2=0, ifreq_bp1=None, echo=True)
print()
print(head_format_bp1.format(*heads_bp1))
print(unit_format_bp1.format(*units_bp1))
print(data_format_bp1.format(k, *d))
print()
k = 90
d = compare_bp1_bp2(files_bp1[k], files_bp2[k], l_bp1=4-2, l_bp2=0, ifreq_bp1=k//8, echo=True)
print()
print(head_format_bp1.format(*heads_bp1))
print(unit_format_bp1.format(*units_bp1))
print(data_format_bp1.format(k, *d))
print()
print()
print(head_format_bp1.format(*heads_bp1))
print(unit_format_bp1.format(*units_bp1))
for k, (f_bp1, f_bp2) in enumerate(zip(files_bp1, files_bp2)):
d = compare_bp1_bp2(f_bp1, f_bp2, l_bp1=4-2, l_bp2=0, ifreq_bp1=k//8, echo=False)
print(data_format_bp1.format(k, *d))
k = 28
d = compare_bp1_bp2(files_bp1[k], files_bp2[k], l_bp1=4-2, l_bp2=0, ifreq_bp1=k//8, echo=True)
print()
print(head_format_bp1.format(*heads_bp1))
print(unit_format_bp1.format(*units_bp1))
print(data_format_bp1.format(k, *d))
print()
case = 'ctc-5120'
dir_Packets = dir_data + "/2017_01_06_ctc-5120/decom"
files = glob.glob(dir_Packets + '/*.sf2')
files.sort()
print(len(files))
for file in files:
print(os.path.basename(file))
freqs_F2 = [f for f in range(7, 103, 1)]
calib_SWF_F2 = buildCalib_Bruno(files, freqs_F2, datatype='SWF_F2', echo=False, fig=False)
pname = case + '_' + os.path.basename(files[0]).replace('.sf2','_SWF.svg')
fig_TF_LFR_allRel(calib_SWF_F2, echo=False, ampl_range=[0,10000], freq_range=[0,110], unwrap=False,
fname=dir_plots+'/'+pname, dB=False, logx=False, phi_range=[-180,180])
signals_ASM = [('B1', 1.), ('B2', 1.), ('B3', 1.), ('E1', 1.), ('E2', 1.)]
freqs_F2 = [f for f in range(7, 103, 1)]
calib_SWF_F2_5 = buildCalib_Bruno(files, freqs_F2, datatype='SWF_F2', echo=False, fig=False, signals=signals_ASM )
pname = case + '_' + os.path.basename(files[0]).replace('.sf2','_SWF_5.svg')
fig_TF_LFR_allRel(calib_SWF_F2_5, echo=False, ampl_range=[0,10000], freq_range=[0,110], unwrap=False,
fname=dir_plots+'/'+pname, dB=False, logx=False, phi_range=[-180,180])
dir_Packets = dir_data + "/2017_01_06_ctc-5120/decom"
files = glob.glob(dir_Packets + '/*.af2')
files.sort()
print(len(files))
for file in files:
print(os.path.basename(file))
iasm = 4
signals_ASM = [('B1', 1.), ('B2', 1.), ('B3', 1.), ('E1', 1.), ('E2', 1.)]
freqs_F2_ASM = [f for f in range(7, 103, 1)]
calib_ASM_F2 = buildCalib_Bruno(files, freqs_F2_ASM, datatype='ASM_F2', echo=False, fig=False,
signals=signals_ASM, i1=iasm )
pname = case + '_' + os.path.basename(files[0]).replace('.af2','_ASM.svg')
fig_TF_LFR_allRel(calib_ASM_F2, echo=False, ampl_range=[0,10000], freq_range=[0,110], unwrap=False,
fname=dir_plots+'/'+pname, dB=False, logx=False, phi_range=[-180,180])
pname = case + '_' + 'diff_ASM-SWF.svg'
fig_diff_TF_LFR_allrel(calib_ASM_F2, calib_SWF_F2_5, echo=False, ampl_range=[-1., 1], freq_range=[0,110],
fname=dir_plots+'/'+pname, dB=False, logx=False, rho_range=[-.001,.003], phi_range=[-.5,1.])
pname = case + '_' + 'diff_ASM-SWF_zoom.svg'
fig_diff_TF_LFR_allrel(calib_ASM_F2, calib_SWF_F2_5, echo=False, ampl_range=[-0.1, 0.05], freq_range=[0,110],
fname=dir_plots+'/'+pname, dB=False, logx=False, rho_range=[-0.0001,0.0001], phi_range=[-.1,.1])
case = 'ctc-512'
dir_Packets = dir_data + "/2018_12_04_ctc-512_EM-FSW_3.2.0.24/decom"
files = glob.glob(dir_Packets + '/*.sf2')
files.sort()
print(len(files))
for file in files:
print(os.path.basename(file))
len(np.arange(7, 103, 1))
freqs_F2 = [f for f in range(7, 103, 1)]
calib_SWF_F2 = buildCalib_Bruno(files, freqs_F2, datatype='SWF_F2', echo=False, fig=False)
pname = case + '_' + os.path.basename(files[0]).replace('.sf2','_SWF.svg')
fig_TF_LFR_allRel(calib_SWF_F2, echo=False, ampl_range=[0,10000], freq_range=[0,110], unwrap=False,
fname=dir_plots+'/'+pname, dB=False, logx=False, phi_range=[-180,180])
signals_ASM = [('B1', 1.), ('B2', 1.), ('B3', 1.), ('E1', 1.), ('E2', 1.)]
freqs_F2 = [f for f in range(7, 103, 1)]
calib_SWF_F2_5 = buildCalib_Bruno(files, freqs_F2, datatype='SWF_F2', echo=False, fig=False, signals=signals_ASM )
pname = case + '_' + os.path.basename(files[0]).replace('.sf2','_SWF_5.svg')
fig_TF_LFR_allRel(calib_SWF_F2_5, echo=False, ampl_range=[0,10000], freq_range=[0,110], unwrap=False,
fname=dir_plots+'/'+pname, dB=False, logx=False, phi_range=[-180,180])
files = glob.glob(dir_Packets + '/*.af2')
files.sort()
print(len(files))
for file in files:
print(os.path.basename(file))
iasm = 1
signals_ASM = [('B1', 1.), ('B2', 1.), ('B3', 1.), ('E1', 1.), ('E2', 1.)]
freqs_F2_ASM = [f for f in range(7, 103, 1)]
calib_ASM_F2 = buildCalib_Bruno(files, freqs_F2_ASM, datatype='ASM_F2', echo=False, fig=False,
signals=signals_ASM, i1=iasm )
pname = case + '_' + os.path.basename(files[0]).replace('.af2','_ASM.svg')
fig_TF_LFR_allRel(calib_ASM_F2, echo=False, ampl_range=[0,10000], freq_range=[0,110], unwrap=False,
fname=dir_plots+'/'+pname, dB=False, logx=False, phi_range=[-180,180])
pname = case + '_' + 'diff_ASM-SWF.svg'
fig_diff_TF_LFR_allrel(calib_ASM_F2, calib_SWF_F2_5, echo=False, ampl_range=[-1., 1], freq_range=[0,110],
fname=dir_plots+'/'+pname, dB=False, logx=False, rho_range=[-.001,.003], phi_range=[-1.5,.1])
pname = case + '_' + 'diff_ASM-SWF_zoom.svg'
fig_diff_TF_LFR_allrel(calib_ASM_F2, calib_SWF_F2_5, echo=False, ampl_range=[-0.1, 0.05], freq_range=[0,110],
fname=dir_plots+'/'+pname, dB=False, logx=False, rho_range=[-0.0001,0.0001], phi_range=[-.1,.1])
case = 'F2-64Hz-2Vpp_on_E1E2B1B2B3-UnitKCOEFFMatrices'
dir_Packets = dir_data + "/F2-64Hz-2Vpp_on_E1E2B1B2B3-UnitKCOEFFMatrices/decom"
files = glob.glob(dir_Packets + '/*.sf2')
files.sort()
print(len(files))
for file in files:
print(os.path.basename(file))
signals_ASM = [('B1', 2.), ('B2', 2.), ('B3', 2.), ('E1', 2.), ('E2', 2.)]
freqs_F2 = [f for f in range(64, 64+1, 1)]
calib_SWF_F2_5 = buildCalib_Bruno(files, freqs_F2, datatype='SWF_F2', echo=True, fig=False, signals=signals_ASM)
calib_SWF_F2_5
files = glob.glob(dir_Packets + '/*.af2')
files.sort()
print(len(files))
for file in files:
print(os.path.basename(file))
iasm = 7
signals_ASM = [('B1', 2.), ('B2', 2.), ('B3', 2.), ('E1', 2.), ('E2', 2.)]
freqs_F2_ASM = [f for f in range(64, 64+1, 1)]
calib_ASM_F2 = buildCalib_Bruno(files, freqs_F2_ASM, datatype='ASM_F2', echo=True, fig=False, signals=signals_ASM,
i1=iasm )
calib_ASM_F2
dir_Packets = dir_data + "/2018_12_04_ctc-512_EM-FSW_3.2.0.24/decom"
files = glob.glob(dir_Packets + '/*L.1f2')
files.sort()
print(len(files))
for file in files:
print(os.path.basename(file))
files_bp1 = files
files = glob.glob(dir_Packets + '/*L.2f2')
files.sort()
print(len(files))
for file in files:
print(os.path.basename(file))
files_bp2 = files
files = glob.glob(dir_Packets + '/*L.af2')
files.sort()
print(len(files))
for file in files:
print(os.path.basename(file))
files_asm = files
freqs_F2 = np.arange(7, 103, 1)
print(len(freqs_F2))
freqs_F2
#head_format = 10*'{:>11s},'
#data_format = 10*'{:11.5f},'
#units = [' '] + 10*['(%)']
heads = 'k', 'd_sm', 'd_psd_b', 'd_psd_e', 'd_dop', 'd_ellip', 'd_nvec', 'd_sx', 'd_sx_arg', 'd_vphi', 'd_vphi_arg'
units = [' ', '(%)', '(%)', '(%)', '(%)', '(%)', ' ', '(%)', ' ', '(%)', ' ']
head_format = '{:>3s},{:>8s},{:>8s},{:>8s},{:>8s},{:>8s},{:>8s},{:>8s},{:>11s},{:>8s},{:>11s}'
unit_format = '{:3s} {:>8s} {:>8s} {:>8s} {:>8s} {:>8s} {:>8s} {:>8s} {:>11s} {:>8s} {:>11s}'
data_format = '{:3d},{:8.2f},{:8.2f},{:8.2f},{:8.2f},{:8.2f},{:8.3f},{:8.2f},{:11d},{:8.2f},{:11d}'
k = 0
d = compare_bp2_asm(files_bp2[k], files_asm[k], l_bp2=1, l_asm=9, ifreq_bp2=None, echo=True)
print()
print(head_format.format(*heads))
print(unit_format.format(*units))
print(data_format.format(k, *d))
print()
d = compare_bp2_asm(files_bp2[k], files_asm[k], l_bp2=0, l_asm=4, ifreq_bp2=None, echo=True)
print()
print(head_format.format(*heads))
print(unit_format.format(*units))
print(data_format.format(k, *d))
k = 1
d = compare_bp2_asm(files_bp2[k], files_asm[k], l_bp2=1, l_asm=9-3, ifreq_bp2=None, echo=True)
print()
print(head_format.format(*heads))
print(unit_format.format(*units))
print(data_format.format(k, *d))
print()
d = compare_bp2_asm(files_bp2[k], files_asm[k], l_bp2=0, l_asm=4-3, ifreq_bp2=None, echo=True)
print()
print(head_format.format(*heads))
print(unit_format.format(*units))
print(data_format.format(k, *d))
print()
print(head_format.format(*heads))
print(unit_format.format(*units))
for k, (f_bp2, f_asm) in enumerate(zip(files_bp2, files_asm)):
d = compare_bp2_asm(f_bp2, f_asm, l_bp2=0, l_asm=4-3, ifreq_bp2=None, echo=False)
print(data_format.format(k, *d))
k = 67
d = compare_bp2_asm(files_bp2[k], files_asm[k], l_bp2=0, l_asm=4-3, ifreq_bp2=None, echo=True)
print()
print(head_format.format(*heads))
print(unit_format.format(*units))
print(data_format.format(k, *d))
print()
print(head_format.format(*heads))
print(unit_format.format(*units))
for k, (f_bp2, f_asm) in enumerate(zip(files_bp2, files_asm)):
d = compare_bp2_asm(f_bp2, f_asm, l_bp2=1, l_asm=9-3, ifreq_bp2=None, echo=False)
print(data_format.format(k, *d))
k = 42
d = compare_bp2_asm(files_bp2[k], files_asm[k], l_bp2=1, l_asm=9-3, ifreq_bp2=None, echo=True)
print()
print(head_format.format(*heads))
print(unit_format.format(*units))
print(data_format.format(k, *d))
print()
print()
print(head_format.format(*heads))
print(unit_format.format(*units))
for k, (f_bp2, f_asm) in enumerate(zip(files_bp2, files_asm)):
d = compare_bp2_asm(f_bp2, f_asm, l_bp2=0, l_asm=4-3, ifreq_bp2=k//8, echo=False)
print(data_format.format(k, *d))
k =63
d = compare_bp2_asm(files_bp2[k], files_asm[k], l_bp2=0, l_asm=4-3, ifreq_bp2=k//8, echo=True)
print()
print(head_format.format(*heads))
print(unit_format.format(*units))
print(data_format.format(k, *d))
heads_bp1 = 'k', 'd_psd_b', 'd_psd_e', 'd_dop', 'd_ellip', 'd_nvec', 'd_sx', 'd_sx_arg', 'd_vphi', 'd_vphi_arg'
units_bp1 = [' ', '(%)', '(%)', '(%)', '(%)', ' ', '(%)', ' ', '(%)', ' ']
head_format_bp1 = '{:>3s},{:>8s},{:>8s},{:>8s},{:>8s},{:>8s},{:>8s},{:>11s},{:>8s},{:>11s}'
unit_format_bp1 = '{:3s} {:>8s} {:>8s} {:>8s} {:>8s} {:>8s} {:>8s} {:>11s} {:>8s} {:>11s}'
data_format_bp1 = '{:3d},{:8.2f},{:8.2f},{:8.2f},{:8.2f},{:8.3f},{:8.2f},{:11.1f},{:8.2f},{:11.1f}'
k = 0
d = compare_bp1_asm(files_bp1[0], files_asm[0], l_bp1=4, l_asm=4, ifreq_bp1=None, echo=True)
print()
print(head_format_bp1.format(*heads_bp1))
print(unit_format_bp1.format(*units_bp1))
print(data_format_bp1.format(k, *d))
print()
print()
print(head_format_bp1.format(*heads_bp1))
print(unit_format_bp1.format(*units_bp1))
for k, (f_bp1, f_asm) in enumerate(zip(files_bp1, files_asm)):
d = compare_bp1_asm(f_bp1, f_asm, l_bp1=4, l_asm=4, ifreq_bp1=None, echo=False)
print(data_format_bp1.format(k, *d))
k = 17
d = compare_bp1_asm(files_bp1[k], files_asm[k], l_bp1=4, l_asm=4, ifreq_bp1=None, echo=True)
print()
print(head_format_bp1.format(*heads_bp1))
print(unit_format_bp1.format(*units_bp1))
print(data_format_bp1.format(k, *d))
print()
k = 17
d = compare_bp1_asm(files_bp1[k], files_asm[k], l_bp1=4, l_asm=4, ifreq_bp1=k//8, echo=True)
print()
print(head_format_bp1.format(*heads_bp1))
print(unit_format_bp1.format(*units_bp1))
print(data_format_bp1.format(k, *d))
print()
print()
print(head_format_bp1.format(*heads_bp1))
print(unit_format_bp1.format(*units_bp1))
for k, (f_bp1, f_asm) in enumerate(zip(files_bp1, files_asm)):
d = compare_bp1_asm(f_bp1, f_asm, l_bp1=4, l_asm=4, ifreq_bp1=k//8, echo=False)
print(data_format_bp1.format(k, *d))
k = 63
d = compare_bp1_asm(files_bp1[k], files_asm[k], l_bp1=4, l_asm=4, ifreq_bp1=k//8, echo=True)
print()
print(head_format_bp1.format(*heads_bp1))
print(unit_format_bp1.format(*units_bp1))
print(data_format_bp1.format(k, *d))
print()
k = 63
d = compare_bp1_asm(files_bp1[k], files_asm[k], l_bp1=1, l_asm=1, ifreq_bp1=k//8, echo=True)
print()
print(head_format_bp1.format(*heads_bp1))
print(unit_format_bp1.format(*units_bp1))
print(data_format_bp1.format(k, *d))
print()
heads_bp1 = 'k', 'd_psd_b', 'd_psd_e', 'd_dop', 'd_ellip', 'd_nvec', 'd_sx', 'd_sx_arg', 'd_vphi', 'd_vphi_arg'
units_bp1 = [' ', '(%)', '(%)', '(%)', '(%)', ' ', '(%)', ' ', '(%)', ' ']
head_format_bp1 = '{:>3s},{:>8s},{:>8s},{:>8s},{:>8s},{:>8s},{:>8s},{:>11s},{:>8s},{:>11s}'
unit_format_bp1 = '{:3s} {:>8s} {:>8s} {:>8s} {:>8s} {:>8s} {:>8s} {:>11s} {:>8s} {:>11s}'
data_format_bp1 = '{:3d},{:8.2f},{:8.2f},{:8.2f},{:8.2f},{:8.3f},{:8.2f},{:11.1f},{:8.2f},{:11.1f}'
k = 0
d = compare_bp1_bp2(files_bp1[k], files_bp2[k], l_bp1=4, l_bp2=0, ifreq_bp1=None, echo=True)
print()
print(head_format_bp1.format(*heads_bp1))
print(unit_format_bp1.format(*units_bp1))
print(data_format_bp1.format(k, *d))
print()
k = 1
d = compare_bp1_bp2(files_bp1[k], files_bp2[k], l_bp1=4-3, l_bp2=0, ifreq_bp1=None, echo=True)
print()
print(head_format_bp1.format(*heads_bp1))
print(unit_format_bp1.format(*units_bp1))
print(data_format_bp1.format(k, *d))
print()
print()
print(head_format_bp1.format(*heads_bp1))
print(unit_format_bp1.format(*units_bp1))
for k, (f_bp1, f_bp2) in enumerate(zip(files_bp1, files_bp2)):
d = compare_bp1_bp2(f_bp1, f_bp2, l_bp1=4-3, l_bp2=0, ifreq_bp1=None, echo=False)
print(data_format_bp1.format(k, *d))
k = 56
d = compare_bp1_bp2(files_bp1[k], files_bp2[k], l_bp1=4-3, l_bp2=0, ifreq_bp1=None, echo=True)
print()
print(head_format_bp1.format(*heads_bp1))
print(unit_format_bp1.format(*units_bp1))
print(data_format_bp1.format(k, *d))
print()
k = 56
d = compare_bp1_bp2(files_bp1[k], files_bp2[k], l_bp1=4-3, l_bp2=0, ifreq_bp1=k//8, echo=True)
print()
print(head_format_bp1.format(*heads_bp1))
print(unit_format_bp1.format(*units_bp1))
print(data_format_bp1.format(k, *d))
print()
print()
print(head_format_bp1.format(*heads_bp1))
print(unit_format_bp1.format(*units_bp1))
for k, (f_bp1, f_bp2) in enumerate(zip(files_bp1, files_bp2)):
d = compare_bp1_bp2(f_bp1, f_bp2, l_bp1=4-3, l_bp2=0, ifreq_bp1=k//8, echo=False)
print(data_format_bp1.format(k, *d))
k = 63
d = compare_bp1_bp2(files_bp1[k], files_bp2[k], l_bp1=4-3, l_bp2=0, ifreq_bp1=k//8, echo=True)
print()
print(head_format_bp1.format(*heads_bp1))
print(unit_format_bp1.format(*units_bp1))
print(data_format_bp1.format(k, *d))
print()
case = 'ctc-5130'
dir_Packets = dir_data + "/2017_01_09_ctc-5130/decom"
files = glob.glob(dir_Packets + '/*.cf3')
files.sort()
print(len(files))
for file in files:
print(os.path.basename(file))
freqs_F3 = [f for f in range(1, 17, 1)]
calib_CWF_F3 = buildCalib_Bruno(files, freqs_F3, datatype='CWF_F3', echo=False, fig=False, icwf_offset=16*4,
signals=[('E1', 1.), ('E2', 1.), ('V', 1.)], i1=4*16, i2=4*16+100*16)
pname = case + '_' + os.path.basename(files[0]).replace('.cf3','_CWF.svg')
fig_TF_LFR_allRel(calib_CWF_F3, echo=False, ampl_range=[0.8,12000], freq_range=[0,17],
fname=dir_plots+'/'+pname, dB=True, logx=False, phi_range=[-360,50], rho_range=[-0.5, 2.5])
pname = case + '_' + os.path.basename(files[0]).replace('.cf3','_CWF.svg')
fig_TF_LFR_allRel(calib_CWF_F3, echo=False, ampl_range=[-100,9500], freq_range=[0,17],
fname=dir_plots+'/'+pname, dB=False, logx=False, phi_range=[-360,50], rho_range=[-0.5, 2.5])