def __init__(self): random.seed() self.modelHelperFunctions = Model self.timeDelta = 1.0 #sec self.numberParticles = 1000 self.world = np.array([-3000,3000, #x dims -3000,3000, #y dims 0,200]) #z dims self.transmitters = np.array([tra.Transmitter()]) self.transmitters[-1].state.x = 0 #set the x location of the transmitter self.transmitters[-1].state.y = 0 #set the x location of the transmitter self.transmitters[-1].state.z = 2.35 #the z location of the transmitter [meters off the ground] self.transmitters[-1].state.id = len(self.transmitters)-1 self.transmitters = np.hstack((self.transmitters,np.array([tra.Transmitter()]))) self.transmitters[-1].state.x = 500 #set the x location of the transmitter self.transmitters[-1].state.y = -100 #set the x location of the transmitter self.transmitters[-1].state.z = 4. #the z location of the transmitter [meters off the ground] self.transmitters[-1].state.id = len(self.transmitters)-1 self.transmitters = np.hstack((self.transmitters,np.array([tra.Transmitter()]))) self.transmitters[-1].state.x = 1000 #set the x location of the transmitter self.transmitters[-1].state.y = 1500 #set the x location of the transmitter self.transmitters[-1].state.z = 3. #the z location of the transmitter [meters off the ground] self.transmitters[-1].state.id = len(self.transmitters)-1 self.aircrafts = np.array([air.Aircraft(len(self.transmitters))]) for aircraft in self.aircrafts: aircraft.state.x = -100#random.uniform(300, 900) #randomise the x location of the aircraft aircraft.state.y = 1400#random.uniform(300, 900) #randomise the y location of the aircraft aircraft.state.z = random.uniform(50, 120) #randomise the z location of the aircraft self.particles = [] for i in range(self.numberParticles): self.particles.append(par.Particle(len(self.transmitters))) self.particles[-1].state.x = random.uniform(self.world[0], self.world[1]) #randomise the x location of the particle self.particles[-1].state.y = random.uniform(self.world[2], self.world[3]) #randomise the y location of the particle self.particles[-1].state.z = random.uniform(self.world[4], self.world[5]) #randomise the z location of the particle self.particles[-1].state.groundSpeed = self.aircrafts[0].state.groundSpeed #randomise ground speed of the particle, heading is assumed to be known self.particles[-1].state.yaw = self.aircrafts[0].state.yaw #randomise ground speed of the particle, heading is assumed to be known
def __init__(self): self.UDP_HOST = "127.0.0.1" self.UDP_PORT = 3000 self.BUFFER_SIZE = 1024 self.imh = Incoming_Message_Handler.Incoming_Message_Handler() self.transmitter = Transmitter.Transmitter()
def __init__(self): self.transmitter = Transmitter.Transmitter("192.168.1.25", 8000, "192.168.1.21", 3000) self.data_collector = Data_Collector.Data_Collector() #initialize sensors #TODO write function that does this from .par file self.data_collector.add_LD_Sensor("uartlite_1")
def __init__(self): self.modelHelperFunctions = Model self.timeDelta = 1.0 #sec self.numberParticles = 1000 self.world = [ 0, 1500, #x dims 0, 0, #y dims 0, 200 ] #z dims aircraft = air.Aircraft() aircraft.state.x = random.uniform( 1000, 1500) #randomise the x location of the aircraft aircraft.state.z = random.uniform( 50, 120) #randomise the z location of the aircraft self.aircrafts = [aircraft] transmitter = tra.Transmitter() transmitter.state.x = 1 #set the x location of the transmitter transmitter.state.z = 2.35 #the z location of the transmitter [meters off the ground] self.transmitters = [transmitter] self.particles = [] for i in range(self.numberParticles): self.particles.append(par.Particle()) self.particles[-1].state.x = random.uniform( self.world[0], self.world[1]) #randomise the x location of the particle self.particles[-1].state.y = random.uniform( self.world[2], self.world[3]) #randomise the y location of the particle self.particles[-1].state.z = random.uniform( self.world[4], self.world[5]) #randomise the z location of the particle #self.particles[-1].state.groundSpeed = random.uniform(-10, -100) #randomise ground speed of the particle, heading is assumed to be known self.particles[-1].state.groundSpeed = self.aircrafts[ 0].state.groundSpeed #randomise ground speed of the particle, heading is assumed to be known
def Flux_dencity_ground(rx, ry, rz, tuple): # Inputs the position vector at where the reading is being focused receiver_position = [1, 0, 0] # focus point Flux = [0, 0, 0] Axis = Transmitter.Flux_dencity(rx, ry, rz, tuple) Axis_hat = Axis / np.linalg.norm(Axis) ground_position = [rx, ry, rz] g = start_radius_vector(Axis, r) # Start vector dl = 2 * r * np.tan(np.pi / n) Emf = np.linalg.norm(Axis) * (np.pi * r**2 ) # 90 degrees offset!!!!! (in time) I = Emf / 0.1 # current in Amps (A) for i in range(n): v = np.dot(rotation_matrix(Axis, i * (2 * np.pi / n)), g) dl_point = np.add(ground_position, v) v_hat = v / np.linalg.norm(v) dl_hat = np.cross(v_hat, Axis_hat) dl_v = np.dot(dl, dl_hat) b = small_flux_dencity(dl_point, dl_v, receiver_position, I) Flux = np.add(Flux, b) return Flux
NMux = [2, 4] NSyms = int(3000) ovsmpl = [2] C_type = np.complex128 Modulation = np.array([1 + 1j, 1 - 1j, -1 + 1j, -1 - 1j]) # QPSK NS = len(ovsmpl) NM = len(NMux) NLB = len(L_b) times = np.zeros(NS * (NM + 1) * NLB * 3).reshape(NS, NM + 1, NLB, 3) for S in range(NS): for MUX in range(NM): signal = Transmitter.TransmitSignal(NMux[MUX], NSyms, ovsmpl[S], C_type, Modulation) for LB in range(NLB): print("Now Executing With:") print("NSyms " + str(NSyms)) print("OvSample " + str(ovsmpl[S])) print("NMUX " + str(NMux[MUX])) print("L_b " + str(L_b[LB])) times[S, MUX + 1, LB, :] = MIMO_CPU.FDE_MIMO_Speedtest( signal, L_b[LB], mu, ovsmpl[S]) / L_b[0] * 1000 times_GPU = All_IN_MIMO.ALL_IN_MIMO_SpeedTest(signal, L_b[LB], mu, ovsmpl[S]) / L_b[0] * 1000 times[S, 0, LB, 0] = times_GPU[0] + times_GPU[1] + 0.5 * times_GPU[3] times[S, 0, LB,
from sound import * from Receiver import * from checksum import Packet as Pack from Transmitter import * from HuffmanCode import * from bitarray import bitarray import sounddevice as sd a = HuffmanCode() encode = a.compress("test.txt") b = Transmitter(encode) chunks = b.chunks packet = b.encode(1) final_packet = [] for p in packet: check = Pack(p) final_packet.append(check.get_final_packet()) bits = "" for p in final_packet: bits += p sig = genSignal(bitarray(bits), baud=400, signal_cf=1700, clock_cf=2000, fdev=500, fs=48000, packet_size=128 + 16 + 32) print("done creating signal") from Receiver import *
if SAVED: filename = 'eye_tx_%s_ch_%s_ns_%.4f.png' % (transmitter.name, channel.name, var) myplt.save_current(filename) if __name__ == "__main__": T_pulse = 1 # sec Fs = 32 # samples/sec in pulse representation alpha = 0.5 K = 4 noise_mean = 0 noise_vars = [0, 0.0001, 0.010] hs_tx = tx.HalfSineTransmitter(T_pulse, Fs) srrc_tx = tx.SRRCTransmitter(alpha, T_pulse, Fs, K) transmitters = [hs_tx, srrc_tx] # channel impulse responses - modeled as an LTI system with finite impulse response h_test = np.array([1, 1 / 2, 3 / 4, -2 / 7]) #ch_test = chnl.Channel(h_test, np.ones(1), Fs, T_pulse, 'Test') ch_indoor = chnl.IndoorChannel(Fs, T_pulse) ch_outdoor = chnl.OutdoorChannel(Fs, T_pulse) channels = [ch_indoor, ch_outdoor] #channels = [ch_test] random_bits = np.random.randint(2, size=10) # to test transmission for channel in channels:
if SAVED: myplt.save_current('eye_{}.png'.format(transmitter.name)) if __name__ == "__main__": ''' Q1) Plot impulse and freq response for both transmitters Try changing alpha and K ''' T_pulse = 1 # sec Fs = 32 # samples/sec per pulse alpha = [0.25, 0.5] K = [6, 4] hs_tx = tx.HalfSineTransmitter(T_pulse, Fs) test_pulse_shape_hs(hs_tx, SAVED=True) srrc_txs = [ tx.SRRCTransmitter(al, T_pulse, Fs, k) for k in K for al in alpha ] test_pulse_shape_srrc(srrc_txs, K, alpha, SAVED=True) ''' Q 2,3,4) Modulated signal and it's spectrum for 10 random bits & eye diagram ''' K = [k for k in K for al in alpha] alpha = [al for k in K for al in alpha] random_bits = np.random.randint(2, size=10) srrc_tx = srrc_txs[-1] transmitters = [hs_tx, srrc_txs[-1], srrc_txs[0]]
import Map import Transmitter import BookKeeper import Timer if __name__ == "__main__": t = time.time() timer = Timer.Timer() keeper = BookKeeper.BookKeeper("log.txt", timer) karte = Map.Map("test1_street", "test1_inter", keeper) print "map initialized" tran = Transmitter.Transmitter(karte.intersections, karte.streets) karte.show() for i in range(100): karte.spawnRandomCar(timer.get()) karte.update() tran.streetTransmit(karte.intersections, karte.streets) tran.intersectionTransmit(karte.intersections) timer.increment() print "\n"
import MIMO import All_IN_MIMO l_b = 64 NSyms = l_b*100 NMux = 1 Modulation = np.array([1+1j,1-1j,-1+1j,-1-1j]) # QPSK ovsmpl = 2 f_s = 56e9 mu = 1e-4 #################################### Transmitter ############################## ShowModulation = True C_type = np.complex128 signal = Transmitter.TransmitSignal(NMux,NSyms,ovsmpl,C_type,Modulation) f = Transmitter.CreateFrequencySpectrum(NSyms*ovsmpl,f_s) ## Distortions ## signal_Disturbed = Disturbance.DynamicDelay(signal,f,f_s) signal_e1 = MIMO.FDE_MIMO_GPU(signal_Disturbed,l_b,mu,ovsmpl) signal_e2 = All_IN_MIMO.ALL_IN_MIMO(signal_Disturbed,l_b,mu,ovsmpl) plt.figure() plt.subplot(2,1,1) diff = np.abs(signal_e1[0,:])-np.abs(signal_e2[0,:]) plt.plot(diff) plt.subplot(2,1,2) r = range(int(NSyms/2),NSyms - l_b*2) plt.scatter(signal_Disturbed[0,r].real,signal_Disturbed[0,r].imag)
import Transmitter import sys import time if __name__ == "__main__": args = sys.argv transmit = Transmitter.TransmitterS() transmit.transmit_code(args[1]) print(args[1])
random_bits = np.random.randint(2, size=10) # to test transmission # channel impulse responses - modeled as an LTI system with finite impulse response #h_test = np.array([1, 1/2, 3/4, -2/7]) #ch_test = chnl.Channel(h_test, np.ones(1), Fs, T_pulse, 'Test') #ch_test = chnl.IndoorChannel(Fs, T_pulse) ch_test = chnl.OutdoorChannel(Fs, T_pulse) eq_zf = eqz.ZFEqualizer(ch_test, Fs, T_pulse) eq_mmse = eqz.MMSEEqualizer(ch_test, Fs, T_pulse, noise_var=noise_var) equalizers = [eq_zf, eq_mmse] # transmitter and receiver - #tx_test = tx.HalfSineTransmitter(T_pulse, Fs) tx_test = tx.SRRCTransmitter(alpha, T_pulse, Fs, K) rx_test = rx.MatchedReceiver(tx_test) for equalizer in equalizers: print('Working on- Equalizer: ', equalizer.name, ', Channel: ', ch_test.name, ' ...') #test_equalizer_response(equalizer, noise = noise_var, SAVED = True) #test_equalization_only_channel(equalizer, ch_test, , random_bits, Fs) #test_equalization_no_noise(equalizer, ch_test, tx_test, rx_test, random_bits) test_eye_diagram(equalizer, ch_test, tx_test, rx_test, noise_var=noise_var, SAVED=True)
result = Flux_dencity_ground(i / 10.0, j / 10.0, k / 20.0, tuple) layerx += result[0] layery += result[1] layerz += result[2] f.write( str(k / 20.0) + "," + str(layerx) + "," + str(layery) + "," + str(layerz) + "\n") f.close() f = open('2Dfield/0m/' + str(tuple) + '.csv', 'w') f.write("x,y,vertical,horizontal\n") m = 10 for i in range(-1 * m, 3 * m + 1): for k in range(-2 * m, 0): result = Transmitter.Flux_dencity(i / float(m), 0.0, k / float(m), tuple) f.write( str(i / float(m)) + "," + str(k / float(m)) + "," + str(result[0]) + "," + str(result[2]) + "\n") f.close() f = open('2Dfield/0.2m/' + str(tuple) + '.csv', 'w') f.write("x,y,vertical,horizontal\n") m = 10 for i in range(-1 * m, 3 * m + 1): for k in range(-2 * m, 0): result = Transmitter.Flux_dencity(i / float(m), 0.2, k / float(m), tuple) f.write( str(i / float(m)) + "," + str(k / float(m)) + "," + str(result[0]) + "," + str(result[2]) + "\n")