Example #1
0
def do_gen(content, decision):
    SER_S = np.empty((tau_range.shape[0], phi_range.shape[0]))
    SER_U = np.empty((tau_range.shape[0], phi_range.shape[0]))

    for tau_idx, tau in enumerate(tau_range):
        print("tau = %.2f" % (tau))

        # symbols of (synch"ed, unsynch"ed) sender
        if content in ("same",):
            tmp_syms = np.random.randint(16, size=nsyms + 2)
            send_syms = [tmp_syms, tmp_syms]
        else:
            send_syms = np.random.randint(16, size=2 * (nsyms + 2)).reshape(2, nsyms + 2)

        send_syms_s, send_syms_u = send_syms[0][1:-1], send_syms[1][1:-1]
        send_chips = pt.map_chips(*send_syms)

        RECV_CHIPS_I = pt.detect_i(send_chips[:2], send_chips[2:], phi_range, tau, As, Au)
        RECV_CHIPS_Q = pt.detect_q(send_chips[:2], send_chips[2:], phi_range, tau, As, Au)

        for phi_idx in range(len(phi_range)):
            recv_chips = np.empty(2 * RECV_CHIPS_I.shape[0])
            recv_chips[::2] = RECV_CHIPS_I[:, phi_idx]
            recv_chips[1::2] = RECV_CHIPS_Q[:, phi_idx]

            # slice bits to simulate hard decision decoder
            if decision in ("hard",):
                recv_chips = np.sign(recv_chips)

            recv_syms = pt.detect_syms_corr(recv_chips)[1:-1]

            SER_S[tau_idx, phi_idx] = sum(recv_syms != send_syms_s) / (1.0 * len(recv_syms))
            SER_U[tau_idx, phi_idx] = sum(recv_syms != send_syms_u) / (1.0 * len(recv_syms))

    np.savez_compressed("data/ser_Au%.2f_%s_%s_v2.npz" % (Au, content, decision), SER_S=SER_S, SER_U=SER_U, **settings)
Example #2
0
def do_gen(content, decision):
    SER_S, SER_U = None, None

    for tau in tau_range:
        print 'tau = %.2f' % (tau)
        ser_s, ser_u = np.array([]), np.array([])

        # symbols of (synch'ed, unsynch'ed) sender
        if content in ('same', ):
            tmp_syms = np.random.randint(16, size=nsyms + 2)
            send_syms = [tmp_syms, tmp_syms]
        else:
            send_syms = np.random.randint(16, size=2 * (nsyms + 2)).reshape(
                2, nsyms + 2)

        send_syms_s, send_syms_u = send_syms[0][1:-1], send_syms[1][1:-1]
        send_chips = pt.map_chips(*send_syms)

        RECV_CHIPS_I = pt.detect_i(send_chips[:2], send_chips[2:], phi_range,
                                   tau, As, Au)
        RECV_CHIPS_Q = pt.detect_q(send_chips[:2], send_chips[2:], phi_range,
                                   tau, As, Au)

        for i in xrange(len(phi_range)):
            recv_chips = np.ravel(zip(RECV_CHIPS_I[:, i], RECV_CHIPS_Q[:, i]))

            # slice bits to simulate hard decision decoder
            if decision in ('hard', ):
                recv_chips = np.sign(recv_chips)

            recv_syms = pt.detect_syms_corr(recv_chips)[1:-1]

            ser_s = np.append(
                ser_s,
                sum(recv_syms != send_syms_s) / (1.0 * len(recv_syms)))
            ser_u = np.append(
                ser_u,
                sum(recv_syms != send_syms_u) / (1.0 * len(recv_syms)))

        if SER_S is None:
            SER_S = ser_s
            SER_U = ser_u
        else:
            SER_S = np.vstack((SER_S, ser_s))
            SER_U = np.vstack((SER_U, ser_u))

    np.savez_compressed('data/ser_Au%.2f_%s_%s_v2.npz' %
                        (Au, content, decision),
                        tau_range=tau_range,
                        phi_range=phi_range,
                        As=As,
                        Au=Au,
                        SER_S=SER_S,
                        SER_U=SER_U,
                        nsyms=nsyms,
                        nsteps=nsteps)
Example #3
0
def gen_n_interf(content, decision, mode="n"):
	"""@param mode: [n] refers to the n interferer mode, we use n low-power interferers with half the power of the sync signal
	                [1] refers to one strong interferer that has the sum of n interferers as its power level.
	"""
	SER_S = np.empty((num_interferer+1, nsteps))

	for ninterf_ in np.arange(0, num_interferer+1):
		print("Starting to generate for %i interferers, mode is %s" % (ninterf_, mode))
		ninterf = ninterf_  # remember the real number of virtual interferers (power setting)
		Au = Au_

		if mode in ("1",):
			# we use a single interferer with the same power as n interferers
			Au = Au_ * np.sqrt(ninterf)

			if ninterf > 1:
				ninterf = 1

		if ninterf == 0:
			phi_range = np.zeros((1,nsteps))
		else:
			phi_range = np.random.uniform(-np.pi, np.pi, size=nsteps*ninterf).reshape(ninterf, nsteps)

		if content in ("unif",):
			send_syms = np.random.randint(16, size=(ninterf+1)*(nsyms+2)).reshape(ninterf+1, nsyms+2)
		else:
			# everyone gets the same symbols to send
			sync_syms = np.random.randint(16, size=nsyms+2)
			send_syms = np.vstack([sync_syms]*(ninterf+1))

		send_syms_s = send_syms[0][1:-1]
		send_chips = ptn.map_chips_n(*send_syms)

		RECV_CHIPS_I = ptn.detect_i_n(ninterf, send_chips[:2], send_chips[2:], phi_range, tau, As, Au)
		RECV_CHIPS_Q = ptn.detect_q_n(ninterf, send_chips[:2], send_chips[2:], phi_range, tau, As, Au)

		for phi_idx in range(nsteps):
			recv_chips = np.zeros(2*RECV_CHIPS_I.shape[0])
			recv_chips[ ::2] = RECV_CHIPS_I[:,phi_idx]
			recv_chips[1::2] = RECV_CHIPS_Q[:,phi_idx]

			# slice bits to simulate hard decision decoder
			if decision in ("hard",):
				recv_chips = np.sign(recv_chips)

			recv_syms = pt.detect_syms_corr(recv_chips)[1:-1]

			SER_S[ninterf_, phi_idx] = np.sum(recv_syms != send_syms_s) / (1.0*len(recv_syms))

		print("PRR = ", np.mean((1.0-SER_S[ninterf_,:])**pktlen))

	np.savez_compressed("data/ser_s_%s_%s_%s.npz"%(content, decision, mode), SER_S=SER_S, **settings)
Example #4
0
def do_gen(content, decision):
    SER_S = np.empty((tau_range.shape[0], phi_range.shape[0]))
    SER_U = np.empty((tau_range.shape[0], phi_range.shape[0]))

    for tau_idx, tau in enumerate(tau_range):
        print("tau = %.2f" % (tau))

        # symbols of (synch"ed, unsynch"ed) sender
        if content in ("same", ):
            tmp_syms = np.random.randint(16, size=nsyms + 2)
            send_syms = [tmp_syms, tmp_syms]
        else:
            send_syms = np.random.randint(16, size=2 * (nsyms + 2)).reshape(
                2, nsyms + 2)

        send_syms_s, send_syms_u = send_syms[0][1:-1], send_syms[1][1:-1]
        send_chips = pt.map_chips(*send_syms)

        RECV_CHIPS_I = pt.detect_i(send_chips[:2], send_chips[2:], phi_range,
                                   tau, As, Au)
        RECV_CHIPS_Q = pt.detect_q(send_chips[:2], send_chips[2:], phi_range,
                                   tau, As, Au)

        for phi_idx in range(len(phi_range)):
            recv_chips = np.empty(2 * RECV_CHIPS_I.shape[0])
            recv_chips[::2] = RECV_CHIPS_I[:, phi_idx]
            recv_chips[1::2] = RECV_CHIPS_Q[:, phi_idx]

            # slice bits to simulate hard decision decoder
            if decision in ("hard", ):
                recv_chips = np.sign(recv_chips)

            recv_syms = pt.detect_syms_corr(recv_chips)[1:-1]

            SER_S[tau_idx,
                  phi_idx] = sum(recv_syms != send_syms_s) / (1.0 *
                                                              len(recv_syms))
            SER_U[tau_idx,
                  phi_idx] = sum(recv_syms != send_syms_u) / (1.0 *
                                                              len(recv_syms))

    np.savez_compressed("data/ser_Au%.2f_%s_%s_v2.npz" %
                        (Au, content, decision),
                        SER_S=SER_S,
                        SER_U=SER_U,
                        **settings)
Example #5
0
def do_gen(part, content, decision, wide, numthreads):
    tau_range = (tau_range_wide if wide else tau_range_norm)
    Au_range = (Au_range_wide if wide else Au_range_norm)
    Au_range_dB = (Au_range_wide_dB if wide else Au_range_norm_dB)

    start_time = time.time()

    tau_range = np.split(tau_range, numthreads)[part]

    PRR_S = np.zeros((tau_range.shape[0], Au_range.shape[0]))
    PRR_U = np.zeros((tau_range.shape[0], Au_range.shape[0]))

    SER_S_PHI = np.zeros((tau_range.shape[0], phi_range.shape[0]))
    SER_U_PHI = np.zeros((tau_range.shape[0], phi_range.shape[0]))

    for tau_idx, tau in enumerate(tau_range):
        # symbols of (synch'ed, unsynch'ed) sender
        if content in ('same', ):
            tmp_syms = np.random.randint(16, size=nsyms + 2)
            send_syms = np.vstack((tmp_syms, tmp_syms))
        else:
            send_syms = np.random.randint(16, size=2 * (nsyms + 2)).reshape(
                2, nsyms + 2)

        send_syms_s, send_syms_u = send_syms[0][1:-1], send_syms[1][1:-1]
        send_chips = pt.map_chips(*send_syms)

        #RECV_CHIPS_I_A = pt.detect_i(send_chips[:2], send_chips[2:], phi_range, tau, As, Au_range)
        #RECV_CHIPS_Q_A = pt.detect_q(send_chips[:2], send_chips[2:], phi_range, tau, As, Au_range)

        for Au_idx, Au in enumerate(Au_range):
            print('%s: tau=%7.3f, tau_step=(%3i/%3i), Au=%7.3f, Au_step=(%3i/%3i), runtime: %5.2f secs' %\
             (sys.argv[0], tau, tau_idx+1, tau_range.shape[0], Au, Au_idx+1, Au_range.shape[0], time.time() - start_time))
            start_time = time.time()

            RECV_CHIPS_I = pt.detect_i(send_chips[:2], send_chips[2:],
                                       phi_range, tau, As, Au)
            RECV_CHIPS_Q = pt.detect_q(send_chips[:2], send_chips[2:],
                                       phi_range, tau, As, Au)

            for phi_idx, phi in enumerate(phi_range):
                # Interleave the I and Q phase (this is faster than np.ravel)
                recv_chips = np.zeros(2 * RECV_CHIPS_I.shape[0])
                recv_chips[::2] = RECV_CHIPS_I[:, phi_idx]
                recv_chips[1::2] = RECV_CHIPS_Q[:, phi_idx]

                if decision in ('hard', ):
                    recv_chips = np.sign(recv_chips)

                recv_syms = pt.detect_syms_corr(recv_chips)[1:-1]

                SER_S_PHI[tau_idx, phi_idx] = np.sum(
                    recv_syms != send_syms_s) / (1.0 * len(recv_syms))
                SER_U_PHI[tau_idx, phi_idx] = np.sum(
                    recv_syms != send_syms_u) / (1.0 * len(recv_syms))

            PRR_S[tau_idx, Au_idx] = np.mean(
                (1.0 - SER_S_PHI[tau_idx, :])**pktlen)
            PRR_U[tau_idx, Au_idx] = np.mean(
                (1.0 - SER_U_PHI[tau_idx, :])**pktlen)

    np.savez_compressed('data/prr_AsAu_%s_%s%s_part%i.npz' %
                        (content, decision, wide, part),
                        PRR_S=PRR_S,
                        PRR_U=PRR_U,
                        SER_S_PHI=SER_S_PHI,
                        SER_U_PHI=SER_U_PHI,
                        tau_range=tau_range,
                        nsteps=nsteps,
                        nsyms=nsyms,
                        As=As,
                        Au_range=Au_range,
                        phi_range=phi_range,
                        Au_range_dB=Au_range_dB)
Example #6
0
def gen_n_interf(content, decision, mode="n"):
    """@param mode: [n] refers to the n interferer mode, we use n low-power interferers with half the power of the sync signal
	                [1] refers to one strong interferer that has the sum of n interferers as its power level.
	"""
    SER_S = np.empty((num_interferer + 1, nsteps))

    for ninterf_ in np.arange(0, num_interferer + 1):
        print("Starting to generate for %i interferers, mode is %s" %
              (ninterf_, mode))
        ninterf = ninterf_  # remember the real number of virtual interferers (power setting)
        Au = Au_

        if mode in ("1", ):
            # we use a single interferer with the same power as n interferers
            Au = Au_ * np.sqrt(ninterf)

            if ninterf > 1:
                ninterf = 1

        if ninterf == 0:
            phi_range = np.zeros((1, nsteps))
        else:
            phi_range = np.random.uniform(-np.pi, np.pi,
                                          size=nsteps * ninterf).reshape(
                                              ninterf, nsteps)

        if content in ("unif", ):
            send_syms = np.random.randint(16, size=(ninterf + 1) *
                                          (nsyms + 2)).reshape(
                                              ninterf + 1, nsyms + 2)
        else:
            # everyone gets the same symbols to send
            sync_syms = np.random.randint(16, size=nsyms + 2)
            send_syms = np.vstack([sync_syms] * (ninterf + 1))

        send_syms_s = send_syms[0][1:-1]
        send_chips = ptn.map_chips_n(*send_syms)

        RECV_CHIPS_I = ptn.detect_i_n(ninterf, send_chips[:2], send_chips[2:],
                                      phi_range, tau, As, Au)
        RECV_CHIPS_Q = ptn.detect_q_n(ninterf, send_chips[:2], send_chips[2:],
                                      phi_range, tau, As, Au)

        for phi_idx in range(nsteps):
            recv_chips = np.zeros(2 * RECV_CHIPS_I.shape[0])
            recv_chips[::2] = RECV_CHIPS_I[:, phi_idx]
            recv_chips[1::2] = RECV_CHIPS_Q[:, phi_idx]

            # slice bits to simulate hard decision decoder
            if decision in ("hard", ):
                recv_chips = np.sign(recv_chips)

            recv_syms = pt.detect_syms_corr(recv_chips)[1:-1]

            SER_S[ninterf_, phi_idx] = np.sum(
                recv_syms != send_syms_s) / (1.0 * len(recv_syms))

        print("PRR = ", np.mean((1.0 - SER_S[ninterf_, :])**pktlen))

    np.savez_compressed("data/ser_s_%s_%s_%s.npz" % (content, decision, mode),
                        SER_S=SER_S,
                        **settings)
def do_gen(part, content, decision, wide, numthreads):
	if wide == "_uwide":
		tau_range = tau_range_uwide
		Au_range  = Au_range_uwide
	elif wide == "_wide":
		tau_range = tau_range_wide
		Au_range  = Au_range_wide
	else:
		tau_range = tau_range_norm
		Au_range  = Au_range_norm


	start_time = time.time()

	tau_range = np.split(tau_range, numthreads)[part]

	PRR_S = np.zeros((tau_range.shape[0], Au_range.shape[0]))
	PRR_U = np.zeros((tau_range.shape[0], Au_range.shape[0]))

	SER_S_PHI = np.zeros((tau_range.shape[0], phi_range.shape[0]))
	SER_U_PHI = np.zeros((tau_range.shape[0], phi_range.shape[0]))

	for tau_idx, tau in enumerate(tau_range):
		# symbols of (synch"ed, unsynch"ed) sender
		if content in ("same",):
			tmp_syms= np.random.randint(16, size=nsyms+2)
			send_syms = np.vstack((tmp_syms, tmp_syms))
		else:
			send_syms = np.random.randint(16, size=2*(nsyms+2)).reshape(2, nsyms+2)

		send_syms_s, send_syms_u = send_syms[0][1:-1], send_syms[1][1:-1]
		send_chips = pt.map_chips(*send_syms)

		#RECV_CHIPS_I_A = pt.detect_i(send_chips[:2], send_chips[2:], phi_range, tau, As, Au_range)
		#RECV_CHIPS_Q_A = pt.detect_q(send_chips[:2], send_chips[2:], phi_range, tau, As, Au_range)

		for Au_idx, Au in enumerate(Au_range):
			print("%s: tau=%7.3f, tau_step=(%3i/%3i), Au=%7.3f, Au_step=(%3i/%3i), runtime: %5.2f secs" %\
				(sys.argv[0], tau, tau_idx+1, tau_range.shape[0], Au, Au_idx+1, Au_range.shape[0], time.time() - start_time))
			start_time = time.time()

			RECV_CHIPS_I = pt.detect_i(send_chips[:2], send_chips[2:], phi_range, tau, As, Au)
			RECV_CHIPS_Q = pt.detect_q(send_chips[:2], send_chips[2:], phi_range, tau, As, Au)

			for phi_idx, phi in enumerate(phi_range):
				# Interleave the I and Q phase (this is faster than np.ravel)
				recv_chips       = np.zeros(2*RECV_CHIPS_I.shape[0])
				recv_chips[ ::2] = RECV_CHIPS_I[:,phi_idx]
				recv_chips[1::2] = RECV_CHIPS_Q[:,phi_idx]

				if decision in ("hard",):
					recv_chips = np.sign(recv_chips)

				recv_syms = pt.detect_syms_corr(recv_chips)[1:-1]

				SER_S_PHI[tau_idx, phi_idx] = np.sum(recv_syms != send_syms_s) / (1.0*len(recv_syms))
				SER_U_PHI[tau_idx, phi_idx] = np.sum(recv_syms != send_syms_u) / (1.0*len(recv_syms))

			PRR_S[tau_idx, Au_idx] = np.mean((1.0-SER_S_PHI[tau_idx,:])**pktlen)
			PRR_U[tau_idx, Au_idx] = np.mean((1.0-SER_U_PHI[tau_idx,:])**pktlen)

	np.savez_compressed("data/prr_AsAu_%s_%s%s_part%i.npz"%(content, decision, wide, part),
						PRR_S=PRR_S, PRR_U=PRR_U, **settings)