# How to use t_symbol method in avocado

Best Python code snippet using avocado_python

test_orthogonality.py

Source:test_orthogonality.py

1import numpy as np2import matplotlib.pyplot as plt3from scipy import linalg4# éåæ¨¡æ¬çç®çæ¯çºäºå¤æ·ä¿¡èçæ­£äº¤æ§5# ç¶ä¿¡èä¸­åºç¾ä¸é£çºææ¯å©ä¿¡èçé »çå·®ä¸ç­æ¼ k / T_symbol ( kçºæ´æ¸ãT_symbolçºä¸åsymbolçæåå¨æ )6# åå§ç©ä¸çº0ï¼ä¸æ­£äº¤7# æåä¹å¯ä»¥ç¼ç¾ä¿¡èçdelayï¼ä¸å½±é¿æ­£äº¤æ§8# èä¸éæå¾éè¦çä¸é»ï¼çµ¦å®T_symbol(symbol å¨æ)æï¼æåæå¾å°å­è¼æ³¢çé »ççº k / T_symbol , k = 1,2,3....9# è¥åæ¨£ééçºTsï¼ä¸Ts * Nfft = T_symbol (ä¹å°±æ¯ä¸åsymbol å¨æå§åæ¨£Nfftåé»)10# ååªæåå¥½åNfftåé¢æ£æååºåå¶FFTçé¢æ£é »è­æææ­£äº¤æ§ï¼åå¤§æ¼Nfftæå°æ¼Nfftåé»å°±æ²ææ­£äº¤æ§äº11Nfft = 16 # åNfftçé»æ¸12T_symbol = 1.6 # ä¸åsymbolçå¨æï¼éä¹ä»£è¡¨å¶ä»å­è¼æ³¢çé »ççº( k / T_symbol )Hz , k = 1,2,3...13t = [0]*100014T = 0.002 # é£çºä¿¡èçéé15for i in range(len(t)):16 t[i] = T*i17x = [0]*len(t)18re_x = [0]*len(t)19Ts = T_symbol / Nfft # åæ¨£å¨æä¸å¯çºå¶ä»æ¸ï¼å¦åæåºç¾éæ­£äº¤20t_sample = [0]*(int(2/Ts)+1) # ç¸½å±æåæ¨£(int(2/Ts)+1)åé»21for i in range(len(t_sample)):22 t_sample[i] = Ts*i23x_sample = [0]*len(t_sample)24re_x_sample = [0]*len(t_sample)25# å±åæ¨£(int(2/Ts)+1)åé»ï¼é¸åNfftåé»26f_index = [0]*Nfft27for i in range(len(f_index)):28 f_index[i] = i29x_matrix = [[0j]*6 for i in range(Nfft)]30x_matrix = np.matrix(x_matrix)31# åç«åºé£çºä¿¡è32for k in range(6):33 for i in range(len(t)):34 if k == 0:35 x[i] = np.exp(1j * 2*np.pi * t[i] / T_symbol) # é »ççº ( 1/T_symbol ) Hzãexponential ä¿¡èdelay 0ç§36 f = 137 delay = 038 elif k == 1:39 x[i] = np.exp(1j * 2*np.pi * 2 * t[i] / T_symbol) # é »ççº ( 2/T_symbol ) Hzãexponential ä¿¡èdelay 0ç§40 f = 241 delay = 042 elif k == 2:43 x[i] = np.exp(1j * 2*np.pi * 3 * (t[i] - 0.1) / T_symbol) # é »ççº ( 3/T_symbol ) Hzãexponential ä¿¡èdelay 0.1ç§44 f = 345 delay = 0.146 elif k == 3:47 x[i] = np.exp(1j * 2*np.pi * 4 * (t[i] - 0.7) / T_symbol) # é »ççº ( 4/T_symbol ) Hzãexponential ä¿¡èdelay 0.7ç§48 f = 449 delay = 0.750 elif k == 4:51 x[i] = np.exp(1j * 2*np.pi * 3.5 * t[i] / T_symbol) # é »ççº ( 3.5/T_symbol ) Hzãexponential ä¿¡èdelay 0ç§52 f = 3.553 delay = 054 elif k == 5:55 f1 = 456 delay1 = 0.357 f2 = 358 delay2 = 0.759 if t[i] <= 1.3:60 x[i] = np.exp(1j * 2*np.pi * 4 * (t[i] - 0.3) / T_symbol) # é »ççº ( 4/T_symbol ) Hzãexponentialä¿¡èdelay 0.3ç§(ä¸é£çºä¿¡è)61 else:62 x[i] = np.exp(1j * 2*np.pi * 3 * (t[i] - 0.7) / T_symbol)63 for j in range(len(t)):64 re_x[j] = x[j].real65 plt.subplot(6, 2, 2*k + 1)66 if k == 5:67 plt.title(r'$when\/\/t<1.3\/\/cos( \frac{{ j2\pi\cdot{0}\cdot (t-{1}) }} {{ {2} }} ),\/\/else\/\/cos( \frac{{ j2\pi\cdot{3}\cdot (t-{4}) }} {{ {2} }} )$'.format(f1, delay1, T_symbol, f2, delay2))68 else:69 plt.title(r'$cos( \frac{{ j2\pi\cdot {0} \cdot (t - {1} ) }} {{ {2} }} )$'.format(f,delay,T_symbol))70 plt.plot(t, re_x ,linestyle = '--')71 plt.xlim(0,2)72# æ¥èç«åºåæ¨£å¾çä¿¡è73for k in range(6):74 for i in range(len(t_sample)):75 # é6åexponential ä¿¡èä¸­ï¼åªæå4åæäºç¸æ­£äº¤76 if k == 0:77 x_sample[i] = np.exp(1j * 2*np.pi * t_sample[i] / T_symbol) # é »ççº ( 1/T_symbol ) Hzãexponential ä¿¡èdelay 0ç§78 elif k == 1:79 x_sample[i] = np.exp(1j * 2*np.pi * 2 * t_sample[i] / T_symbol) # é »ççº ( 2/T_symbol ) Hzãexponential ä¿¡èdelay 0ç§80 elif k == 2:81 x_sample[i] = np.exp(1j * 2*np.pi * 3 * (t_sample[i] - 0.1) / T_symbol) # é »ççº ( 3/T_symbol ) Hzãexponential ä¿¡èdelay 0.1ç§82 elif k == 3:83 x_sample[i] = np.exp(1j * 2*np.pi * 4 * (t_sample[i] - 0.7) / T_symbol) # é »ççº ( 4/T_symbol ) Hzãexponential ä¿¡èdelay 0.7ç§84 elif k == 4:85 x_sample[i] = np.exp(1j * 2*np.pi * 3.5 * t_sample[i] / T_symbol) # é »ççº ( 3.5/T_symbol ) Hzãexponential ä¿¡èdelay 0ç§86 elif k == 5:87 if t_sample[i] <= 1.3:88 x_sample[i] = np.exp(1j * 2*np.pi * 4 * (t_sample[i] - 0.3) / T_symbol) # é »ççº ( 4/T_symbol ) Hzãexponential ä¿¡èdelay 0ç§(ä¸é£çºä¿¡è)89 else:90 x_sample[i] = np.exp(1j * 2*np.pi * 3 * (t_sample[i] - 0.7) / T_symbol)91 if i < 16:92 x_matrix[i,k] = x_sample[i]93 for j in range(len(x_sample)):94 re_x_sample[j] = x_sample[j].real95 X = np.fft.fft(x_sample[0:Nfft]) #å¾(int(2/Ts)+1)ååæ¨£é»ä¸­ï¼é¸åNfftåé»ä¾åFFT96 for j in range(len(X)):97 X[j] = abs(X[j])98 plt.subplot(6, 2, 2*k+1)99 plt.stem(t_sample,re_x_sample)100 plt.ylabel('Re{x[n]}').set_rotation(0)101 ax = plt.gca()102 ax.yaxis.set_label_coords(-0.08, 0.9) # ç¨ä¾è¨­å®åº§æ¨è»¸åç¨±çä½ç½®103 plt.xlabel('t')104 ax.xaxis.set_label_coords(1.05, -0.025) # ç¨ä¾è¨­å®åº§æ¨è»¸åç¨±çä½ç½®105 plt.subplot(6, 2, 2*k+2)106 plt.stem(f_index,X)107 plt.ylabel('Re{X[k]}').set_rotation(0)108 ax = plt.gca()109 ax.yaxis.set_label_coords(-0.08,0.9) #ç¨ä¾è¨­å®åº§æ¨è»¸åç¨±çä½ç½®110 plt.xlim(0,Nfft)111 plt.xticks(np.arange(0,Nfft,2))112ans = x_matrix.getH() * x_matrix / (T_symbol/Ts) #å¯è§å¯ans matrixä¾å¤æ·ä¿¡èéæ¯å¦ææ­£äº¤æ§113print(ans)114# çµæè¡¨æåªæå4åä¿¡èäºç¸æ­£äº¤...

clock_sync.py

Source:clock_sync.py

1import numpy as np2import cupy as cp3# import matplotlib.pyplot as plt4# By GuJi in WT&T, BUPT5def clock_sync(envelope, estimated_symbol_rate):6# x = 1:1000000;7# pwr = sin(x*2*pi*352.745/1000000+95.1534);8# plot(pwr);9 envelope_normal = cp.asnumpy(envelope/cp.max(envelope))10 # fft_pwr = fft(envelope_normal);11 free_symbol_rate = estimated_symbol_rate12 loop_gain_k0 = free_symbol_rate*0.113 loop_gain_k1 = free_symbol_rate*0.0114 dll_dt_span = 0.115 t_symbol = 016 siglen = len(envelope_normal)17 clk_sample_pattern = np.zeros(siglen, dtype=np.bool)18 last_early_factor = 019 dll_symbol_rate = free_symbol_rate20 integral_dll_symbol_rate = 021 while True:22 t_symbol = t_symbol + 1/dll_symbol_rate23 if t_symbol+0.5/dll_symbol_rate>siglen-1:24 break25 t_early = t_symbol - dll_dt_span/dll_symbol_rate26 t_late = t_symbol + dll_dt_span/dll_symbol_rate27 late_factor = -envelope_normal[round(t_late)]+envelope_normal[round(t_early)]28# d_error_factor = abs(late_factor)-abs(last_early_factor);29# last_early_factor = late_factor;30 dll_symbol_rate = free_symbol_rate+loop_gain_k0*late_factor+integral_dll_symbol_rate31 # integral_dll_symbol_rate = integral_dll_symbol_rate + loop_gain_k1*late_factor;32 integral_dll_symbol_rate = integral_dll_symbol_rate + loop_gain_k1*(late_factor-integral_dll_symbol_rate)33 # dll_symbol_rate = dll_symbol_rate - loop_gain_k1*early_factor;34 # clk_sample_pattern(round(t_symbol)) = late_factor*10;35 36 loop_gain_k0 = free_symbol_rate*0.0137 loop_gain_k1 = free_symbol_rate*0.00138 39 while(True):40 t_symbol = t_symbol - 1/dll_symbol_rate41 if(t_symbol-0.5/dll_symbol_rate<0):42 break43 t_early = t_symbol + dll_dt_span/dll_symbol_rate44 t_late = t_symbol - dll_dt_span/dll_symbol_rate45 late_factor = -envelope_normal[round(t_late)]+envelope_normal[round(t_early)]46# d_error_factor = abs(late_factor)-abs(last_early_factor);47# last_early_factor = late_factor;48 dll_symbol_rate = free_symbol_rate+loop_gain_k0*late_factor+integral_dll_symbol_rate49 # integral_dll_symbol_rate = integral_dll_symbol_rate + loop_gain_k1*late_factor;50 integral_dll_symbol_rate = integral_dll_symbol_rate + loop_gain_k1*(late_factor-integral_dll_symbol_rate)51 # dll_symbol_rate = dll_symbol_rate - loop_gain_k1*early_factor;52 # clk_sample_pattern(round(t_symbol)) = late_factor*10;53 54 while(True):55 t_symbol = t_symbol + 1/dll_symbol_rate56 if(t_symbol+0.5/dll_symbol_rate>siglen-1):57 break58 t_early = t_symbol - dll_dt_span/dll_symbol_rate59 t_late = t_symbol + dll_dt_span/dll_symbol_rate60 late_factor = -envelope_normal[round(t_late)]+envelope_normal[round(t_early)]61# d_error_factor = abs(late_factor)-abs(last_early_factor);62# last_early_factor = late_factor;63 dll_symbol_rate = free_symbol_rate+loop_gain_k0*late_factor+integral_dll_symbol_rate64 # integral_dll_symbol_rate = integral_dll_symbol_rate + loop_gain_k1*late_factor;65 integral_dll_symbol_rate = integral_dll_symbol_rate + loop_gain_k1*(late_factor-integral_dll_symbol_rate)66 # dll_symbol_rate = dll_symbol_rate - loop_gain_k1*early_factor;67 clk_sample_pattern[round(t_symbol)] = 168 69 70 # plt.plot(envelope_normal)71 # plt.plot(clk_sample_pattern)72 # plt.show()...

fmRRC.py

Source:fmRRC.py

1#2# Comp Eng 3DY4 (Computer Systems Integration Project)3#4# Copyright by Nicola Nicolici5# Department of Electrical and Computer Engineering6# McMaster University7# Ontario, Canada8#910import numpy as np11import math1213def impulseResponseRootRaisedCosine(Fs, N_taps):1415 """16 Root raised cosine (RRC) filter1718 Fs sampling rate at the output of the resampler in the RDS path19 sampling rate must be an integer multipler of 237520 this integer multiple is the number of samples per symbol2122 N_taps number of filter taps2324 """2526 # duration for each symbol - should NOT be changed for RDS!27 T_symbol = 1/2375.02829 # roll-off factor (must be greater than 0 and smaller than 1)30 # for RDS a value in the range of 0.9 is a good trade-off between31 # the excess bandwidth and the size/duration of ripples in the time-domain32 beta = 0.903334 # the RRC inpulse response that will be computed in this function35 impulseResponseRRC = np.empty(N_taps)3637 for k in range(N_taps):38 t = float((k-N_taps/2))/Fs39 # we ignore the 1/T_symbol scale factor40 if t == 0.0: impulseResponseRRC[k] = 1.0 + beta*((4/math.pi)-1)41 elif t == -T_symbol/(4*beta) or t == T_symbol/(4*beta):42 impulseResponseRRC[k] = (beta/np.sqrt(2))*(((1+2/math.pi)* \43 (math.sin(math.pi/(4*beta)))) + ((1-2/math.pi)*(math.cos(math.pi/(4*beta)))))44 else: impulseResponseRRC[k] = (math.sin(math.pi*t*(1-beta)/T_symbol) + \45 4*beta*(t/T_symbol)*math.cos(math.pi*t*(1+beta)/T_symbol))/ \46 (math.pi*t*(1-(4*beta*t/T_symbol)*(4*beta*t/T_symbol))/T_symbol)4748 # returns the RRC impulse response to be used by convolution49 return impulseResponseRRC5051if __name__ == "__main__":52 ...

## Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.