From 2832c5d37984fd5fbaeb62207c64ea01333f960e Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Tue, 17 Sep 2019 00:58:34 +0200 Subject: [PATCH] Fix estimation of CN0 for low values --- src/algorithms/tracking/libs/lock_detectors.cc | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/algorithms/tracking/libs/lock_detectors.cc b/src/algorithms/tracking/libs/lock_detectors.cc index a56d73bc8..ccf74e502 100644 --- a/src/algorithms/tracking/libs/lock_detectors.cc +++ b/src/algorithms/tracking/libs/lock_detectors.cc @@ -122,12 +122,16 @@ float cn0_mm_estimator(const gr_complex* Prompt_buffer, int length, float coh_in m_2 /= n; m_4 /= n; aux = std::sqrt(2.0 * m_2 * m_2 - m_4); - SNR_aux = aux / (m_2 - aux); - SNR_dB_Hz = 10.0 * std::log10(SNR_aux) - 10.0 * std::log10(coh_integration_time_s); - if (std::isnan(SNR_dB_Hz)) + if (std::isnan(aux)) { - SNR_dB_Hz = Psig / (m_2 - Psig); + SNR_aux = Psig / (m_2 - Psig); } + else + { + SNR_aux = aux / (m_2 - aux); + } + SNR_dB_Hz = 10.0 * std::log10(SNR_aux) - 10.0 * std::log10(coh_integration_time_s); + return SNR_dB_Hz; }