mirror of
https://github.com/gnss-sdr/gnss-sdr
synced 2025-04-14 23:03:14 +00:00
Improve CN0 estimator
This commit is contained in:
parent
8089c41735
commit
87e106ceac
@ -849,7 +849,7 @@ bool dll_pll_veml_tracking::cn0_and_tracking_lock_status(double coh_integration_
|
||||
d_Prompt_buffer[d_cn0_estimation_counter % trk_parameters.cn0_samples] = d_P_accu;
|
||||
d_cn0_estimation_counter++;
|
||||
// Code lock indicator
|
||||
float d_CN0_SNV_dB_Hz_raw = cn0_svn_estimator(d_Prompt_buffer.data(), trk_parameters.cn0_samples, static_cast<float>(coh_integration_time_s));
|
||||
float d_CN0_SNV_dB_Hz_raw = cn0_mm_estimator(d_Prompt_buffer.data(), trk_parameters.cn0_samples, static_cast<float>(coh_integration_time_s));
|
||||
d_CN0_SNV_dB_Hz = d_cn0_smoother.smooth(d_CN0_SNV_dB_Hz_raw);
|
||||
// Carrier lock indicator
|
||||
d_carrier_lock_test = d_carrier_lock_test_smoother.smooth(carrier_lock_detector(d_Prompt_buffer.data(), 1));
|
||||
|
@ -607,7 +607,7 @@ bool dll_pll_veml_tracking_fpga::cn0_and_tracking_lock_status(double coh_integra
|
||||
d_Prompt_buffer[d_cn0_estimation_counter % trk_parameters.cn0_samples] = d_P_accu;
|
||||
d_cn0_estimation_counter++;
|
||||
// Code lock indicator
|
||||
float d_CN0_SNV_dB_Hz_raw = cn0_svn_estimator(d_Prompt_buffer.data(), trk_parameters.cn0_samples, static_cast<float>(coh_integration_time_s));
|
||||
float d_CN0_SNV_dB_Hz_raw = cn0_mm_estimator(d_Prompt_buffer.data(), trk_parameters.cn0_samples, static_cast<float>(coh_integration_time_s));
|
||||
d_CN0_SNV_dB_Hz = d_cn0_smoother.smooth(d_CN0_SNV_dB_Hz_raw);
|
||||
// Carrier lock indicator
|
||||
d_carrier_lock_test = d_carrier_lock_test_smoother.smooth(carrier_lock_detector(d_Prompt_buffer.data(), 1));
|
||||
|
@ -414,7 +414,7 @@ int Galileo_E1_Tcp_Connector_Tracking_cc::general_work(int noutput_items __attri
|
||||
d_cn0_estimation_counter = 0;
|
||||
|
||||
// Code lock indicator
|
||||
d_CN0_SNV_dB_Hz = cn0_svn_estimator(d_Prompt_buffer.data(), FLAGS_cn0_samples, GALILEO_E1_CODE_PERIOD_S);
|
||||
d_CN0_SNV_dB_Hz = cn0_mm_estimator(d_Prompt_buffer.data(), FLAGS_cn0_samples, GALILEO_E1_CODE_PERIOD_S);
|
||||
|
||||
// Carrier lock indicator
|
||||
d_carrier_lock_test = carrier_lock_detector(d_Prompt_buffer.data(), FLAGS_cn0_samples);
|
||||
|
@ -762,7 +762,7 @@ int glonass_l1_ca_dll_pll_c_aid_tracking_cc::general_work(int noutput_items __at
|
||||
{
|
||||
d_cn0_estimation_counter = 0;
|
||||
// Code lock indicator
|
||||
d_CN0_SNV_dB_Hz = cn0_svn_estimator(d_Prompt_buffer.data(), CN0_ESTIMATION_SAMPLES, GLONASS_L1_CA_CODE_PERIOD_S);
|
||||
d_CN0_SNV_dB_Hz = cn0_mm_estimator(d_Prompt_buffer.data(), CN0_ESTIMATION_SAMPLES, GLONASS_L1_CA_CODE_PERIOD_S);
|
||||
// Carrier lock indicator
|
||||
d_carrier_lock_test = carrier_lock_detector(d_Prompt_buffer.data(), CN0_ESTIMATION_SAMPLES);
|
||||
// Loss of lock detection
|
||||
|
@ -753,7 +753,7 @@ int glonass_l1_ca_dll_pll_c_aid_tracking_sc::general_work(int noutput_items __at
|
||||
{
|
||||
d_cn0_estimation_counter = 0;
|
||||
// Code lock indicator
|
||||
d_CN0_SNV_dB_Hz = cn0_svn_estimator(d_Prompt_buffer.data(), CN0_ESTIMATION_SAMPLES, GLONASS_L1_CA_CODE_PERIOD_S);
|
||||
d_CN0_SNV_dB_Hz = cn0_mm_estimator(d_Prompt_buffer.data(), CN0_ESTIMATION_SAMPLES, GLONASS_L1_CA_CODE_PERIOD_S);
|
||||
// Carrier lock indicator
|
||||
d_carrier_lock_test = carrier_lock_detector(d_Prompt_buffer.data(), CN0_ESTIMATION_SAMPLES);
|
||||
// Loss of lock detection
|
||||
|
@ -621,7 +621,7 @@ int Glonass_L1_Ca_Dll_Pll_Tracking_cc::general_work(int noutput_items __attribut
|
||||
{
|
||||
d_cn0_estimation_counter = 0;
|
||||
// Code lock indicator
|
||||
d_CN0_SNV_dB_Hz = cn0_svn_estimator(d_Prompt_buffer.data(), CN0_ESTIMATION_SAMPLES, GLONASS_L1_CA_CODE_PERIOD_S);
|
||||
d_CN0_SNV_dB_Hz = cn0_mm_estimator(d_Prompt_buffer.data(), CN0_ESTIMATION_SAMPLES, GLONASS_L1_CA_CODE_PERIOD_S);
|
||||
// Carrier lock indicator
|
||||
d_carrier_lock_test = carrier_lock_detector(d_Prompt_buffer.data(), CN0_ESTIMATION_SAMPLES);
|
||||
// Loss of lock detection
|
||||
|
@ -760,7 +760,7 @@ int glonass_l2_ca_dll_pll_c_aid_tracking_cc::general_work(int noutput_items __at
|
||||
{
|
||||
d_cn0_estimation_counter = 0;
|
||||
// Code lock indicator
|
||||
d_CN0_SNV_dB_Hz = cn0_svn_estimator(d_Prompt_buffer.data(), CN0_ESTIMATION_SAMPLES, GLONASS_L2_CA_CODE_PERIOD_S);
|
||||
d_CN0_SNV_dB_Hz = cn0_mm_estimator(d_Prompt_buffer.data(), CN0_ESTIMATION_SAMPLES, GLONASS_L2_CA_CODE_PERIOD_S);
|
||||
// Carrier lock indicator
|
||||
d_carrier_lock_test = carrier_lock_detector(d_Prompt_buffer.data(), CN0_ESTIMATION_SAMPLES);
|
||||
// Loss of lock detection
|
||||
|
@ -751,7 +751,7 @@ int glonass_l2_ca_dll_pll_c_aid_tracking_sc::general_work(int noutput_items __at
|
||||
{
|
||||
d_cn0_estimation_counter = 0;
|
||||
// Code lock indicator
|
||||
d_CN0_SNV_dB_Hz = cn0_svn_estimator(d_Prompt_buffer.data(), CN0_ESTIMATION_SAMPLES, GLONASS_L2_CA_CODE_PERIOD_S);
|
||||
d_CN0_SNV_dB_Hz = cn0_mm_estimator(d_Prompt_buffer.data(), CN0_ESTIMATION_SAMPLES, GLONASS_L2_CA_CODE_PERIOD_S);
|
||||
// Carrier lock indicator
|
||||
d_carrier_lock_test = carrier_lock_detector(d_Prompt_buffer.data(), CN0_ESTIMATION_SAMPLES);
|
||||
// Loss of lock detection
|
||||
|
@ -621,7 +621,7 @@ int Glonass_L2_Ca_Dll_Pll_Tracking_cc::general_work(int noutput_items __attribut
|
||||
{
|
||||
d_cn0_estimation_counter = 0;
|
||||
// Code lock indicator
|
||||
d_CN0_SNV_dB_Hz = cn0_svn_estimator(d_Prompt_buffer.data(), CN0_ESTIMATION_SAMPLES, GLONASS_L2_CA_CODE_PERIOD_S);
|
||||
d_CN0_SNV_dB_Hz = cn0_mm_estimator(d_Prompt_buffer.data(), CN0_ESTIMATION_SAMPLES, GLONASS_L2_CA_CODE_PERIOD_S);
|
||||
// Carrier lock indicator
|
||||
d_carrier_lock_test = carrier_lock_detector(d_Prompt_buffer.data(), CN0_ESTIMATION_SAMPLES);
|
||||
// Loss of lock detection
|
||||
|
@ -436,7 +436,7 @@ int Gps_L1_Ca_Dll_Pll_Tracking_GPU_cc::general_work(int noutput_items __attribut
|
||||
{
|
||||
d_cn0_estimation_counter = 0;
|
||||
// Code lock indicator
|
||||
d_CN0_SNV_dB_Hz = cn0_svn_estimator(d_Prompt_buffer.data(), FLAGS_cn0_samples, GPS_L1_CA_CODE_PERIOD_S);
|
||||
d_CN0_SNV_dB_Hz = cn0_mm_estimator(d_Prompt_buffer.data(), FLAGS_cn0_samples, GPS_L1_CA_CODE_PERIOD_S);
|
||||
// Carrier lock indicator
|
||||
d_carrier_lock_test = carrier_lock_detector(d_Prompt_buffer.data(), FLAGS_cn0_samples);
|
||||
// Loss of lock detection
|
||||
|
@ -794,7 +794,7 @@ int Gps_L1_Ca_Kf_Tracking_cc::general_work(int noutput_items __attribute__((unus
|
||||
{
|
||||
d_cn0_estimation_counter = 0;
|
||||
// Code lock indicator
|
||||
d_CN0_SNV_dB_Hz = cn0_svn_estimator(d_Prompt_buffer.data(), FLAGS_cn0_samples, GPS_L1_CA_CODE_PERIOD_S);
|
||||
d_CN0_SNV_dB_Hz = cn0_mm_estimator(d_Prompt_buffer.data(), FLAGS_cn0_samples, GPS_L1_CA_CODE_PERIOD_S);
|
||||
// Carrier lock indicator
|
||||
d_carrier_lock_test = carrier_lock_detector(d_Prompt_buffer.data(), FLAGS_cn0_samples);
|
||||
// Loss of lock detection
|
||||
|
@ -450,7 +450,7 @@ int Gps_L1_Ca_Tcp_Connector_Tracking_cc::general_work(int noutput_items __attrib
|
||||
else
|
||||
{
|
||||
d_cn0_estimation_counter = 0;
|
||||
d_CN0_SNV_dB_Hz = cn0_svn_estimator(d_Prompt_buffer.data(), FLAGS_cn0_samples, GPS_L1_CA_CODE_PERIOD_S);
|
||||
d_CN0_SNV_dB_Hz = cn0_mm_estimator(d_Prompt_buffer.data(), FLAGS_cn0_samples, GPS_L1_CA_CODE_PERIOD_S);
|
||||
d_carrier_lock_test = carrier_lock_detector(d_Prompt_buffer.data(), FLAGS_cn0_samples);
|
||||
|
||||
// ###### TRACKING UNLOCK NOTIFICATION #####
|
||||
|
@ -85,6 +85,53 @@ float cn0_svn_estimator(const gr_complex* Prompt_buffer, int length, float coh_i
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Signal-to-Noise (SNR) (\f$\rho\f$) estimator using the Moments Method:
|
||||
* \f{equation}
|
||||
* \hat{\rho}=\frac{\hat{P}_s}{\hat{P}_n}=\frac{\sqrt{2*\hat{M}_2^2 - \hat{M}_4 }}{\hat{M}_2-\sqrt{2*\hat{M}_2^2 - \hat{M}_4 }},
|
||||
* \f}
|
||||
* where \f$\hat{P}_s=\left(\frac{1}{N}\sum^{N-1}_{i=0}|Re(Pc(i))|\right)^2\f$ is the estimation of the signal power,
|
||||
* \f$ \hat{M}_2=\frac{1}{N}\sum^{N-1}_{i=0}|Pc(i)|^2 \f$, \f$\hat{M}_4 = \frac{1}{N}\sum^{N-1}_{i=0}|Pc(i)|^4 \f$, \f$|\cdot|\f$ is the absolute value,
|
||||
* \f$Re(\cdot)\f$ stands for the real part of the value, and \f$Pc(i)\f$ is the prompt correlator output for the sample index i.
|
||||
*
|
||||
* The SNR value is converted to CN0 [dB-Hz], taking to account the coherent integration time, using the following formula:
|
||||
* \f{equation}
|
||||
* CN0_{dB}=10*log(\hat{\rho})-10*log(T_{int}),
|
||||
* \f}
|
||||
* where \f$T_{int}\f$ is the coherent integration time, in seconds.
|
||||
*
|
||||
*/
|
||||
float cn0_mm_estimator(const gr_complex* Prompt_buffer, int length, float coh_integration_time_s)
|
||||
{
|
||||
float SNR_aux = 0.0;
|
||||
float SNR_dB_Hz = 0.0;
|
||||
float Psig = 0.0;
|
||||
float m_2 = 0.0;
|
||||
float m_4 = 0.0;
|
||||
float aux;
|
||||
auto n = static_cast<float>(length);
|
||||
for (int i = 0; i < length; i++)
|
||||
{
|
||||
Psig += std::abs(Prompt_buffer[i].real());
|
||||
aux = Prompt_buffer[i].imag() * Prompt_buffer[i].imag() + Prompt_buffer[i].real() * Prompt_buffer[i].real();
|
||||
m_2 += aux;
|
||||
m_4 += (aux * aux);
|
||||
}
|
||||
Psig /= n;
|
||||
Psig = Psig * Psig;
|
||||
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))
|
||||
{
|
||||
SNR_dB_Hz = Psig / (m_2 - Psig);
|
||||
}
|
||||
return SNR_dB_Hz;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* The estimate of the cosine of twice the carrier phase error is given by
|
||||
* \f{equation}
|
||||
|
@ -51,7 +51,7 @@
|
||||
#include <gnuradio/gr_complex.h>
|
||||
|
||||
|
||||
/*! \brief CN0_SNV is a Carrier-to-Noise (CN0) estimator
|
||||
/*! \brief cn0_svn_estimator is a Carrier-to-Noise (CN0) estimator
|
||||
* based on the Signal-to-Noise Variance (SNV) estimator
|
||||
*
|
||||
* Signal-to-Noise (SNR) (\f$\rho\f$) estimator using the Signal-to-Noise Variance (SNV) estimator:
|
||||
@ -75,6 +75,29 @@
|
||||
float cn0_svn_estimator(const gr_complex* Prompt_buffer, int length, float coh_integration_time_s);
|
||||
|
||||
|
||||
/*! \brief cn0_mm_estimator is a Carrier-to-Noise (CN0) estimator
|
||||
* based on the Moments Method (MM)
|
||||
*
|
||||
* Signal-to-Noise (SNR) (\f$\rho\f$) estimator using the Moments Method:
|
||||
* \f{equation}
|
||||
* \hat{\rho}=\frac{\hat{P}_s}{\hat{P}_n}=\frac{\sqrt{2*\hat{M}_2^2 - \hat{M}_4 }}{\hat{M}_2-\sqrt{2*\hat{M}_2^2 - \hat{M}_4 }},
|
||||
* \f}
|
||||
* where \f$\hat{P}_s=\left(\frac{1}{N}\sum^{N-1}_{i=0}|Re(Pc(i))|\right)^2\f$ is the estimation of the signal power,
|
||||
* \f$ \hat{M}_2=\frac{1}{N}sum^{N-1}_{i=0}|Pc(i)|^2 \f$, \f$\hat{M}_4 = \frac{1}{N}sum^{N-1}_{i=0}|Pc(i)|^4 \f$, \f$|\cdot|\f$ is the absolute value,
|
||||
* \f$Re(\cdot)\f$ stands for the real part of the value, and \f$Pc(i)\f$ is the prompt correlator output for the sample index i.
|
||||
*
|
||||
* The SNR value is converted to CN0 [dB-Hz], taking to account the coherent integration time, using the following formula:
|
||||
* \f{equation}
|
||||
* CN0_{dB}=10*log(\hat{\rho})-10*log(T_{int}),
|
||||
* \f}
|
||||
* where \f$T_{int}\f$ is the coherent integration time, in seconds.
|
||||
* Ref: D. R. Pauluzzi, N. C. Beaulieu, "A comparison of SNR estimation
|
||||
* techniques for the AWGN channel," IEEE Trans. on Comm., vol. 48,
|
||||
* no. 10, pp. 1681–1691, Oct. 2000.
|
||||
*/
|
||||
float cn0_mm_estimator(const gr_complex* Prompt_buffer, int length, float coh_integration_time_s);
|
||||
|
||||
|
||||
/*! \brief A carrier lock detector
|
||||
*
|
||||
* The Carrier Phase Lock Detector block uses the estimate of the cosine of twice the carrier phase error is given by
|
||||
|
Loading…
x
Reference in New Issue
Block a user