From 09527e238316921e99c4058dc57130d3f72de06d Mon Sep 17 00:00:00 2001 From: cmayer Date: Thu, 15 Nov 2018 18:42:31 +0100 Subject: [PATCH] move np.bool(...) to msg_proxy --- python/msg_proxy.py | 6 +++--- python/physical_layer/MIL_STD_188_110A.py | 6 ++---- python/physical_layer/MIL_STD_188_110C.py | 6 +++--- python/physical_layer/STANAG_4285.py | 4 ++-- 4 files changed, 10 insertions(+), 12 deletions(-) diff --git a/python/msg_proxy.py b/python/msg_proxy.py index f3fc253..660e26d 100644 --- a/python/msg_proxy.py +++ b/python/msg_proxy.py @@ -49,7 +49,7 @@ class msg_proxy(gr.basic_block): iq_samples = pmt.to_python(pmt.cdr(msg_in)) success,doppler = self._obj.get_doppler(iq_samples) msg_out = pmt.make_dict() - msg_out = pmt.dict_add(msg_out, pmt.intern('success'), pmt.to_pmt(success)) + msg_out = pmt.dict_add(msg_out, pmt.intern('success'), pmt.to_pmt(np.bool(success))) msg_out = pmt.dict_add(msg_out, pmt.intern('doppler'), pmt.to_pmt(doppler)) ## print(msg_out) self.message_port_pub(self._port_doppler, msg_out) @@ -64,7 +64,7 @@ class msg_proxy(gr.basic_block): msg_out = pmt.dict_add(msg_out, pmt.intern('symb'), pmt.to_pmt(symb['symb'])) msg_out = pmt.dict_add(msg_out, pmt.intern('scramble'), pmt.to_pmt(symb['scramble'])) msg_out = pmt.dict_add(msg_out, pmt.intern('constellation_idx'), pmt.to_pmt(constellation_idx)) - msg_out = pmt.dict_add(msg_out, pmt.intern('do_continue'), pmt.to_pmt(do_continue)) - msg_out = pmt.dict_add(msg_out, pmt.intern('save_soft_dec'), pmt.to_pmt(save_soft_dec)) + msg_out = pmt.dict_add(msg_out, pmt.intern('do_continue'), pmt.to_pmt(np.bool(do_continue))) + msg_out = pmt.dict_add(msg_out, pmt.intern('save_soft_dec'), pmt.to_pmt(np.bool(save_soft_dec))) ## print(msg_out) self.message_port_pub(self._port_frame_info, msg_out) diff --git a/python/physical_layer/MIL_STD_188_110A.py b/python/physical_layer/MIL_STD_188_110A.py index a16028a..699667c 100644 --- a/python/physical_layer/MIL_STD_188_110A.py +++ b/python/physical_layer/MIL_STD_188_110A.py @@ -139,7 +139,7 @@ class PhysicalLayer(object): self._frame_counter += 1 print('test:', symbols[self._mode['unknown']:], np.mean(np.real(symbols[self._mode['unknown']:]))) if self._frame_counter < self._num_frames_per_block-2: - success = np.bool(np.mean(np.real(symbols[self._mode['unknown']:])) > 0.7) + success = np.mean(np.real(symbols[self._mode['unknown']:])) > 0.7 return [self.get_next_data_frame(success),self._mode['ci'],success,success] def get_next_data_frame(self, success): @@ -177,9 +177,7 @@ class PhysicalLayer(object): tpks = np.abs(cc[imax+3*16*sps:imax+5*16*sps]) print('imax=', imax, 'apks=',apks, np.mean(apks), np.mean(tpks)) - success = np.bool(np.mean(apks) > 5*np.mean(tpks) and - apks[0]/apks[1] > 0.5 and - apks[0]/apks[1] < 2.0) + success = np.mean(apks) > 5*np.mean(tpks) and apks[0]/apks[1] > 0.5 and apks[0]/apks[1] < 2.0 if success: idx = np.arange(32*sps) pks = [np.correlate(iq_samples[imax+i*32*sps+idx], diff --git a/python/physical_layer/MIL_STD_188_110C.py b/python/physical_layer/MIL_STD_188_110C.py index e67900e..e6e2c02 100644 --- a/python/physical_layer/MIL_STD_188_110C.py +++ b/python/physical_layer/MIL_STD_188_110C.py @@ -183,7 +183,7 @@ class PhysicalLayer(object): pks = [np.correlate(iq_samples[imax+i*23*sps+idx], zp[i*23*sps+idx])[0] for i in range(8)] - success = np.bool(np.mean(np.abs(pks)) > 2*np.mean(np.abs(cc[imax+11*sps+range(-sps,sps)]))) + success = np.mean(np.abs(pks)) > 2*np.mean(np.abs(cc[imax+11*sps+range(-sps,sps)])) print('test:',imax, np.mean(np.abs(pks)), np.mean(np.abs(cc[imax+11*sps+range(-sps,sps)]))) if success: print('doppler apks', np.abs(pks)) @@ -198,10 +198,10 @@ class PhysicalLayer(object): pass def get_preamble_quality(self, symbols): - return np.bool(np.abs(np.mean(symbols[-40:])) > 0.5) + return np.abs(np.mean(symbols[-40:])) > 0.5 def get_data_frame_quality(self, symbols): - return np.bool(np.abs(np.mean(symbols[-31:])) > 0.5) + return np.abs(np.mean(symbols[-31:])) > 0.5 def decode_reinserted_preamble(self, symbols): ## decode D0,D1,D2 diff --git a/python/physical_layer/STANAG_4285.py b/python/physical_layer/STANAG_4285.py index 134bb5c..e2b80cb 100644 --- a/python/physical_layer/STANAG_4285.py +++ b/python/physical_layer/STANAG_4285.py @@ -46,7 +46,7 @@ class PhysicalLayer(object): idx = range(30,80) z = symbols[idx]*np.conj(self._preamble['symb'][idx]) ## print('quality_preamble',np.sum(np.real(z)<0), symbols[idx]) - success = np.bool(np.sum(np.real(z)<0) < 30) + success = np.sum(np.real(z)<0) < 30 frame_description = [self._data,self._mode,success,True] self._frame_counter += 1 @@ -69,7 +69,7 @@ class PhysicalLayer(object): pks = cc[(imax,imax+31*sps),] tpks = cc[imax+15*sps:imax+16*sps] ## print('doppler: ', np.abs(pks), np.abs(tpks)) - success = np.bool(np.mean(np.abs(pks)) > 5*np.mean(np.abs(tpks))) + success = np.mean(np.abs(pks)) > 5*np.mean(np.abs(tpks)) doppler = np.diff(np.unwrap(np.angle(pks)))[0]/31/self._sps if success else 0 return success,doppler