import snakerf as srf import matplotlib.pyplot as plt import numpy as np from math import inf, pi, log2 t = np.linspace(0, 1, 1000000) f = 100 # # v1 = np.sin(srf.f2w(f) * t) # v2 = np.sin(srf.f2w(f) * t) # v3 = np.sin(srf.f2w(4*f) * t) # y1 = v1 + v2 + v3 # y2 = srf.power_combine([v1, v2, v3], t) v4 = srf.Vt_noise(t, 273.15) # y3 = srf.power_combine([v4, v1], t) # plt.hist(v4, 24) # plt.plot(t,v4.real) # plt.show() plt.subplot(2, 1, 1) plt.plot(t, v4) # srf.plot_power_spectrum(plt.gca(), t, v4, time = True) plt.subplot(2, 1, 2) Pf_noise = srf.Vt2Pf(v4, len(t)) * 10 Vt_from_Pf_noise = srf.Pf2Vt(Pf_noise, len(t)) plt.plot(t, Vt_from_Pf_noise)
import snakerf as srf import matplotlib.pyplot as plt import numpy as np from math import inf, pi, log2 t = np.linspace(0, 0.01, 1000000) f = 1000 fs = srf.fft_fs(t) ws = srf.f2w(fs) v1 = srf.dBm2Vp(-100) * np.sin(srf.f2w(f) * t) v2 = srf.Vt_noise(t) v3 = srf.power_combine([v1, v2], t, out_Pf=True) # print(srf.C(1e-9, ws)) R1 = 1e3 C1 = 10e-9 v4 = v3 * srf.Vdiv(srf.R(R1, ws), srf.C(C1, ws)) # print(srf.w2f(1/(R1*C1))) # plt.subplot(4,1,1) # srf.plot_power_spectrum(plt.gca(), t, v1, time = True) # plt.subplot(4,1,2) # srf.plot_power_spectrum(plt.gca(), t, v2, time = True) plt.subplot(2, 1, 1) srf.plot_power_spectrum(plt.gca(), fs, v3, time=False) srf.plot_power_spectrum(plt.gca(), fs, v4, time=False) plt.subplot(2, 1, 2) plt.plot(t, srf.Pf2Vt(v3, len(t))) plt.plot(t, srf.Pf2Vt(v4, len(t)))
data = '{0:0{1:d}b}'.format(srf.gold_codes(m)[0], 2**m - 1) print(data) n = 1 f = 250000 f_bit = 9001 T_bit = 1 / f_bit t = np.linspace(0, len(data) * T_bit / n - T_bit / 100, 100000) fs = srf.fft_fs(t) ws = srf.f2w(fs) v1 = srf.V_psk(t, f, f_bit, data, -90, n=n) v2 = srf.V_msk(t, f, f_bit, data, -90) vn = srf.Vt_noise(t) v1n = srf.power_combine([v1, vn], t, out_Pf=True) v2n = srf.power_combine([v2, vn], t, out_Pf=True) R1 = 1e3 C1 = 25e-11 v1f = v1n * srf.Pdiv(srf.R(R1, ws), srf.C(C1, ws)) v2f = v2n * srf.Pdiv(srf.R(R1, ws), srf.C(C1, ws)) # print(srf.w2f(1/(R1*C1))) plt.subplot(2, 1, 1) # plt.plot(fs, srf.dB(srf.mag(srf.Pdiv(srf.R(R1, ws), srf.C(C1, ws))))) # plt.axvline(srf.w2f(1/(R1*C1)), ls = '-', c = 'black') # srf.plot_power_spectrum(plt.gca(), t, v1, time = True) # srf.plot_power_spectrum(plt.gca(), t, v2, time = True)