1
0
mirror of https://github.com/gnss-sdr/gnss-sdr synced 2025-07-04 02:53:06 +00:00

Accelerate CN0 estimation

This commit is contained in:
Carles Fernandez 2019-04-25 14:58:30 +02:00
parent 50d4db9c05
commit 42c0544c4c
2 changed files with 12 additions and 12 deletions

View File

@ -65,23 +65,23 @@
* where \f$T_{int}\f$ is the coherent integration time, in seconds. * where \f$T_{int}\f$ is the coherent integration time, in seconds.
* *
*/ */
float cn0_svn_estimator(const gr_complex* Prompt_buffer, int length, double coh_integration_time_s) float cn0_svn_estimator(const gr_complex* Prompt_buffer, int length, float coh_integration_time_s)
{ {
double SNR = 0.0; float SNR = 0.0;
double SNR_dB_Hz = 0.0; float SNR_dB_Hz = 0.0;
double Psig = 0.0; float Psig = 0.0;
double Ptot = 0.0; float Ptot = 0.0;
for (int i = 0; i < length; i++) for (int i = 0; i < length; i++)
{ {
Psig += std::abs(static_cast<double>(Prompt_buffer[i].real())); Psig += std::abs(Prompt_buffer[i].real());
Ptot += static_cast<double>(Prompt_buffer[i].imag()) * static_cast<double>(Prompt_buffer[i].imag()) + static_cast<double>(Prompt_buffer[i].real()) * static_cast<double>(Prompt_buffer[i].real()); Ptot += Prompt_buffer[i].imag() * Prompt_buffer[i].imag() + Prompt_buffer[i].real() * Prompt_buffer[i].real();
} }
Psig /= static_cast<double>(length); Psig /= static_cast<float>(length);
Psig = Psig * Psig; Psig = Psig * Psig;
Ptot /= static_cast<double>(length); Ptot /= static_cast<float>(length);
SNR = Psig / (Ptot - Psig); SNR = Psig / (Ptot - Psig);
SNR_dB_Hz = 10.0 * log10(SNR) - 10.0 * log10(coh_integration_time_s); SNR_dB_Hz = 10.0 * std::log10(SNR) - 10.0 * std::log10(coh_integration_time_s);
return static_cast<float>(SNR_dB_Hz); return SNR_dB_Hz;
} }

View File

@ -72,7 +72,7 @@
* IEEE 10th International Symposium on Spread Spectrum Techniques and * IEEE 10th International Symposium on Spread Spectrum Techniques and
* Applications, pp.28-30, August 2008. * Applications, pp.28-30, August 2008.
*/ */
float cn0_svn_estimator(const gr_complex* Prompt_buffer, int length, double coh_integration_time_s); float cn0_svn_estimator(const gr_complex* Prompt_buffer, int length, float coh_integration_time_s);
/*! \brief A carrier lock detector /*! \brief A carrier lock detector