From de3b0fc5b60022b6b21dea5eb01d99f0c1211625 Mon Sep 17 00:00:00 2001 From: Chris Hiszpanski Date: Wed, 15 Mar 2023 11:46:54 -0700 Subject: [PATCH] Fix DivideByZero exception Use log(a/b) == log(a) - log(b) to avoid divide by zero. --- python/demod.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/demod.py b/python/demod.py index 7f0a0eb..b6f87c5 100644 --- a/python/demod.py +++ b/python/demod.py @@ -98,7 +98,7 @@ def work(self, input_items, output_items): # bit being a 0 or 1. Confidence of 0 is equally likely 0 or 1. # Positive confidence levels are more likely 1 and negative values # are more likely 0. - self.bit_confidence = 10.0*np.log10(bit1_amps/bit0_amps) + self.bit_confidence = 10.0*(np.log10(bit1_amps)-np.log10(bit0_amps)) # Send PDU message to decoder meta = pmt.to_pmt({