How to use t_symbol method in avocado

Best Python code snippet using avocado_python

test_orthogonality.py

Source:test_orthogonality.py Github

copy

Full Screen

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個信號互相正交...

Full Screen

Full Screen

clock_sync.py

Source:clock_sync.py Github

copy

Full Screen

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

Full Screen

Full Screen

fmRRC.py

Source:fmRRC.py Github

copy

Full Screen

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 ...

Full Screen

Full Screen

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.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run avocado automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful