1
0
mirror of https://github.com/gnss-sdr/gnss-sdr synced 2024-12-14 04:00:34 +00:00

Mark private members

This commit is contained in:
Carles Fernandez 2020-10-29 11:49:09 +01:00
parent 58269aac2a
commit 8b508618d6
No known key found for this signature in database
GPG Key ID: 4C583C52B0C3877D
6 changed files with 149 additions and 151 deletions

View File

@ -28,15 +28,15 @@
notch_sptr make_notch_filter(float pfa, float p_c_factor,
int32_t length_, int32_t n_segments_est, int32_t n_segments_reset)
int32_t length, int32_t n_segments_est, int32_t n_segments_reset)
{
return notch_sptr(new Notch(pfa, p_c_factor, length_, n_segments_est, n_segments_reset));
return notch_sptr(new Notch(pfa, p_c_factor, length, n_segments_est, n_segments_reset));
}
Notch::Notch(float pfa,
float p_c_factor,
int32_t length_,
int32_t length,
int32_t n_segments_est,
int32_t n_segments_reset) : gr::block("Notch",
gr::io_signature::make(1, 1, sizeof(gr_complex)),
@ -44,24 +44,23 @@ Notch::Notch(float pfa,
{
const int32_t alignment_multiple = volk_get_alignment() / sizeof(gr_complex);
set_alignment(std::max(1, alignment_multiple));
set_history(2);
this->pfa = pfa;
noise_pow_est = 0.0;
this->p_c_factor = gr_complex(p_c_factor, 0.0);
this->length_ = length_; // Set the number of samples per segment
filter_state_ = false; // Initial state of the filter
n_deg_fred = 2 * length_; // Number of dregrees of freedom
n_segments = 0;
this->n_segments_est = n_segments_est; // Set the number of segments for noise power estimation
this->n_segments_reset = n_segments_reset; // Set the period (in segments) when the noise power is estimated
z_0 = gr_complex(0.0, 0.0);
boost::math::chi_squared_distribution<float> my_dist_(n_deg_fred);
thres_ = boost::math::quantile(boost::math::complement(my_dist_, pfa));
c_samples = volk_gnsssdr::vector<gr_complex>(length_);
pfa_ = pfa;
noise_pow_est_ = 0.0;
p_c_factor_ = gr_complex(p_c_factor, 0.0);
length_ = length; // Set the number of samples per segment
filter_state_ = false; // Initial state of the filter
n_deg_fred_ = 2 * length_; // Number of dregrees of freedom
n_segments_ = 0;
n_segments_est_ = n_segments_est; // Set the number of segments for noise power estimation
n_segments_reset_ = n_segments_reset; // Set the period (in segments) when the noise power is estimated
z_0_ = gr_complex(0.0, 0.0);
boost::math::chi_squared_distribution<float> my_dist_(n_deg_fred_);
thres_ = boost::math::quantile(boost::math::complement(my_dist_, pfa_));
c_samples_ = volk_gnsssdr::vector<gr_complex>(length_);
angle_ = volk_gnsssdr::vector<float>(length_);
power_spect = volk_gnsssdr::vector<float>(length_);
last_out = gr_complex(0.0, 0.0);
d_fft = std::make_unique<gr::fft::fft_complex>(length_, true);
power_spect_ = volk_gnsssdr::vector<float>(length_);
last_out_ = gr_complex(0.0, 0.0);
d_fft_ = std::make_unique<gr::fft::fft_complex>(length_, true);
}
@ -77,47 +76,47 @@ int Notch::general_work(int noutput_items, gr_vector_int &ninput_items __attribu
in++;
while ((index_out + length_) < noutput_items)
{
if ((n_segments < n_segments_est) && (filter_state_ == false))
if ((n_segments_ < n_segments_est_) && (filter_state_ == false))
{
memcpy(d_fft->get_inbuf(), in, sizeof(gr_complex) * length_);
d_fft->execute();
volk_32fc_s32f_power_spectrum_32f(power_spect.data(), d_fft->get_outbuf(), 1.0, length_);
volk_32f_s32f_calc_spectral_noise_floor_32f(&sig2dB, power_spect.data(), 15.0, length_);
sig2lin = std::pow(10.0F, (sig2dB / 10.0F)) / (static_cast<float>(n_deg_fred));
noise_pow_est = (static_cast<float>(n_segments) * noise_pow_est + sig2lin) / (static_cast<float>(n_segments + 1));
memcpy(d_fft_->get_inbuf(), in, sizeof(gr_complex) * length_);
d_fft_->execute();
volk_32fc_s32f_power_spectrum_32f(power_spect_.data(), d_fft_->get_outbuf(), 1.0, length_);
volk_32f_s32f_calc_spectral_noise_floor_32f(&sig2dB, power_spect_.data(), 15.0, length_);
sig2lin = std::pow(10.0F, (sig2dB / 10.0F)) / (static_cast<float>(n_deg_fred_));
noise_pow_est_ = (static_cast<float>(n_segments_) * noise_pow_est_ + sig2lin) / (static_cast<float>(n_segments_ + 1));
memcpy(out, in, sizeof(gr_complex) * length_);
}
else
{
volk_32fc_x2_conjugate_dot_prod_32fc(&dot_prod_, in, in, length_);
if ((lv_creal(dot_prod_) / noise_pow_est) > thres_)
if ((lv_creal(dot_prod_) / noise_pow_est_) > thres_)
{
if (filter_state_ == false)
{
filter_state_ = true;
last_out = gr_complex(0.0, 0.0);
last_out_ = gr_complex(0.0, 0.0);
}
volk_32fc_x2_multiply_conjugate_32fc(c_samples.data(), in, (in - 1), length_);
volk_32fc_s32f_atan2_32f(angle_.data(), c_samples.data(), static_cast<float>(1.0), length_);
volk_32fc_x2_multiply_conjugate_32fc(c_samples_.data(), in, (in - 1), length_);
volk_32fc_s32f_atan2_32f(angle_.data(), c_samples_.data(), static_cast<float>(1.0), length_);
for (int32_t aux = 0; aux < length_; aux++)
{
z_0 = std::exp(gr_complex(0.0, 1.0) * (*(angle_.data() + aux)));
*(out + aux) = *(in + aux) - z_0 * (*(in + aux - 1)) + p_c_factor * z_0 * last_out;
last_out = *(out + aux);
z_0_ = std::exp(gr_complex(0.0, 1.0) * (*(angle_.data() + aux)));
*(out + aux) = *(in + aux) - z_0_ * (*(in + aux - 1)) + p_c_factor_ * z_0_ * last_out_;
last_out_ = *(out + aux);
}
}
else
{
if (n_segments > n_segments_reset)
if (n_segments_ > n_segments_reset_)
{
n_segments = 0;
n_segments_ = 0;
}
filter_state_ = false;
memcpy(out, in, sizeof(gr_complex) * length_);
}
}
index_out += length_;
n_segments++;
n_segments_++;
in += length_;
out += length_;
}

View File

@ -41,7 +41,7 @@ using notch_sptr = boost::shared_ptr<Notch>;
notch_sptr make_notch_filter(
float pfa,
float p_c_factor,
int32_t length_,
int32_t length,
int32_t n_segments_est,
int32_t n_segments_reset);
@ -58,23 +58,23 @@ public:
gr_vector_void_star &output_items);
private:
friend notch_sptr make_notch_filter(float pfa, float p_c_factor, int32_t length_, int32_t n_segments_est, int32_t n_segments_reset);
Notch(float pfa, float p_c_factor, int32_t length_, int32_t n_segments_est, int32_t n_segments_reset);
std::unique_ptr<gr::fft::fft_complex> d_fft;
volk_gnsssdr::vector<gr_complex> c_samples;
friend notch_sptr make_notch_filter(float pfa, float p_c_factor, int32_t length, int32_t n_segments_est, int32_t n_segments_reset);
Notch(float pfa, float p_c_factor, int32_t length, int32_t n_segments_est, int32_t n_segments_reset);
std::unique_ptr<gr::fft::fft_complex> d_fft_;
volk_gnsssdr::vector<gr_complex> c_samples_;
volk_gnsssdr::vector<float> angle_;
volk_gnsssdr::vector<float> power_spect;
gr_complex last_out;
gr_complex z_0;
gr_complex p_c_factor;
float pfa;
float noise_pow_est;
volk_gnsssdr::vector<float> power_spect_;
gr_complex last_out_;
gr_complex z_0_;
gr_complex p_c_factor_;
float pfa_;
float noise_pow_est_;
float thres_;
int32_t length_;
int32_t n_deg_fred;
uint32_t n_segments;
uint32_t n_segments_est;
uint32_t n_segments_reset;
int32_t n_deg_fred_;
uint32_t n_segments_;
uint32_t n_segments_est_;
uint32_t n_segments_reset_;
bool filter_state_;
};

View File

@ -27,15 +27,15 @@
#include <cstring>
notch_lite_sptr make_notch_filter_lite(float p_c_factor, float pfa, int32_t length_, int32_t n_segments_est, int32_t n_segments_reset, int32_t n_segments_coeff)
notch_lite_sptr make_notch_filter_lite(float p_c_factor, float pfa, int32_t length, int32_t n_segments_est, int32_t n_segments_reset, int32_t n_segments_coeff)
{
return notch_lite_sptr(new NotchLite(p_c_factor, pfa, length_, n_segments_est, n_segments_reset, n_segments_coeff));
return notch_lite_sptr(new NotchLite(p_c_factor, pfa, length, n_segments_est, n_segments_reset, n_segments_coeff));
}
NotchLite::NotchLite(float p_c_factor,
float pfa,
int32_t length_,
int32_t length,
int32_t n_segments_est,
int32_t n_segments_reset,
int32_t n_segments_coeff) : gr::block("NotchLite",
@ -45,28 +45,27 @@ NotchLite::NotchLite(float p_c_factor,
const int32_t alignment_multiple = volk_get_alignment() / sizeof(gr_complex);
set_alignment(std::max(1, alignment_multiple));
set_history(2);
this->p_c_factor = gr_complex(p_c_factor, 0.0);
this->n_segments_est = n_segments_est;
this->n_segments_reset = n_segments_reset;
this->n_segments_coeff_reset = n_segments_coeff;
this->n_segments_coeff = 0;
this->length_ = length_;
set_output_multiple(length_);
this->pfa = pfa;
n_segments = 0;
n_deg_fred = 2 * length_;
noise_pow_est = 0.0;
p_c_factor_ = gr_complex(p_c_factor, 0.0);
n_segments_est_ = n_segments_est;
n_segments_reset_ = n_segments_reset;
n_segments_coeff_reset_ = n_segments_coeff;
n_segments_coeff_ = 0;
length_ = length;
pfa_ = pfa;
n_segments_ = 0;
n_deg_fred_ = 2 * length_;
noise_pow_est_ = 0.0;
filter_state_ = false;
z_0 = gr_complex(0.0, 0.0);
last_out = gr_complex(0.0, 0.0);
boost::math::chi_squared_distribution<float> my_dist_(n_deg_fred);
thres_ = boost::math::quantile(boost::math::complement(my_dist_, pfa));
c_samples1 = gr_complex(0.0, 0.0);
c_samples2 = gr_complex(0.0, 0.0);
angle1 = 0.0;
angle2 = 0.0;
power_spect = volk_gnsssdr::vector<float>(length_);
d_fft = std::make_unique<gr::fft::fft_complex>(length_, true);
z_0_ = gr_complex(0.0, 0.0);
last_out_ = gr_complex(0.0, 0.0);
boost::math::chi_squared_distribution<float> my_dist_(n_deg_fred_);
thres_ = boost::math::quantile(boost::math::complement(my_dist_, pfa_));
c_samples1_ = gr_complex(0.0, 0.0);
c_samples2_ = gr_complex(0.0, 0.0);
angle1_ = 0.0;
angle2_ = 0.0;
power_spect_ = volk_gnsssdr::vector<float>(length_);
d_fft_ = std::make_unique<gr::fft::fft_complex>(length_, true);
}
@ -82,56 +81,56 @@ int NotchLite::general_work(int noutput_items, gr_vector_int &ninput_items __att
in++;
while ((index_out + length_) < noutput_items)
{
if ((n_segments < n_segments_est) && (filter_state_ == false))
if ((n_segments_ < n_segments_est_) && (filter_state_ == false))
{
memcpy(d_fft->get_inbuf(), in, sizeof(gr_complex) * length_);
d_fft->execute();
volk_32fc_s32f_power_spectrum_32f(power_spect.data(), d_fft->get_outbuf(), 1.0, length_);
volk_32f_s32f_calc_spectral_noise_floor_32f(&sig2dB, power_spect.data(), 15.0, length_);
sig2lin = std::pow(10.0F, (sig2dB / 10.0F)) / static_cast<float>(n_deg_fred);
noise_pow_est = (static_cast<float>(n_segments) * noise_pow_est + sig2lin) / static_cast<float>(n_segments + 1);
memcpy(d_fft_->get_inbuf(), in, sizeof(gr_complex) * length_);
d_fft_->execute();
volk_32fc_s32f_power_spectrum_32f(power_spect_.data(), d_fft_->get_outbuf(), 1.0, length_);
volk_32f_s32f_calc_spectral_noise_floor_32f(&sig2dB, power_spect_.data(), 15.0, length_);
sig2lin = std::pow(10.0F, (sig2dB / 10.0F)) / static_cast<float>(n_deg_fred_);
noise_pow_est_ = (static_cast<float>(n_segments_) * noise_pow_est_ + sig2lin) / static_cast<float>(n_segments_ + 1);
memcpy(out, in, sizeof(gr_complex) * length_);
}
else
{
volk_32fc_x2_conjugate_dot_prod_32fc(&dot_prod_, in, in, length_);
if ((lv_creal(dot_prod_) / noise_pow_est) > thres_)
if ((lv_creal(dot_prod_) / noise_pow_est_) > thres_)
{
if (filter_state_ == false)
{
filter_state_ = true;
last_out = gr_complex(0, 0);
n_segments_coeff = 0;
last_out_ = gr_complex(0, 0);
n_segments_coeff_ = 0;
}
if (n_segments_coeff == 0)
if (n_segments_coeff_ == 0)
{
volk_32fc_x2_multiply_conjugate_32fc(&c_samples1, (in + 1), in, 1);
volk_32fc_s32f_atan2_32f(&angle1, &c_samples1, static_cast<float>(1.0), 1);
volk_32fc_x2_multiply_conjugate_32fc(&c_samples2, (in + length_ - 1), (in + length_ - 2), 1);
volk_32fc_s32f_atan2_32f(&angle2, &c_samples2, static_cast<float>(1.0), 1);
float angle_ = (angle1 + angle2) / 2.0F;
z_0 = std::exp(gr_complex(0, 1) * angle_);
volk_32fc_x2_multiply_conjugate_32fc(&c_samples1_, (in + 1), in, 1);
volk_32fc_s32f_atan2_32f(&angle1_, &c_samples1_, static_cast<float>(1.0), 1);
volk_32fc_x2_multiply_conjugate_32fc(&c_samples2_, (in + length_ - 1), (in + length_ - 2), 1);
volk_32fc_s32f_atan2_32f(&angle2_, &c_samples2_, static_cast<float>(1.0), 1);
float angle_ = (angle1_ + angle2_) / 2.0F;
z_0_ = std::exp(gr_complex(0, 1) * angle_);
}
for (int32_t aux = 0; aux < length_; aux++)
{
*(out + aux) = *(in + aux) - z_0 * (*(in + aux - 1)) + p_c_factor * z_0 * last_out;
last_out = *(out + aux);
*(out + aux) = *(in + aux) - z_0_ * (*(in + aux - 1)) + p_c_factor_ * z_0_ * last_out_;
last_out_ = *(out + aux);
}
n_segments_coeff++;
n_segments_coeff = n_segments_coeff % n_segments_coeff_reset;
n_segments_coeff_++;
n_segments_coeff_ = n_segments_coeff_ % n_segments_coeff_reset_;
}
else
{
if (n_segments > n_segments_reset)
if (n_segments_ > n_segments_reset_)
{
n_segments = 0;
n_segments_ = 0;
}
filter_state_ = false;
memcpy(out, in, sizeof(gr_complex) * length_);
}
}
index_out += length_;
n_segments++;
n_segments_++;
in += length_;
out += length_;
}

View File

@ -41,7 +41,7 @@ using notch_lite_sptr = boost::shared_ptr<NotchLite>;
notch_lite_sptr make_notch_filter_lite(
float p_c_factor,
float pfa,
int32_t length_,
int32_t length,
int32_t n_segments_est,
int32_t n_segments_reset,
int32_t n_segments_coeff);
@ -59,27 +59,27 @@ public:
gr_vector_void_star &output_items);
private:
friend notch_lite_sptr make_notch_filter_lite(float p_c_factor, float pfa, int32_t length_, int32_t n_segments_est, int32_t n_segments_reset, int32_t n_segments_coeff);
NotchLite(float p_c_factor, float pfa, int32_t length_, int32_t n_segments_est, int32_t n_segments_reset, int32_t n_segments_coeff);
std::unique_ptr<gr::fft::fft_complex> d_fft;
volk_gnsssdr::vector<float> power_spect;
gr_complex last_out;
gr_complex z_0;
gr_complex p_c_factor;
gr_complex c_samples1;
gr_complex c_samples2;
float pfa;
friend notch_lite_sptr make_notch_filter_lite(float p_c_factor, float pfa, int32_t length, int32_t n_segments_est, int32_t n_segments_reset, int32_t n_segments_coeff);
NotchLite(float p_c_factor, float pfa, int32_t length, int32_t n_segments_est, int32_t n_segments_reset, int32_t n_segments_coeff);
std::unique_ptr<gr::fft::fft_complex> d_fft_;
volk_gnsssdr::vector<float> power_spect_;
gr_complex last_out_;
gr_complex z_0_;
gr_complex p_c_factor_;
gr_complex c_samples1_;
gr_complex c_samples2_;
float pfa_;
float thres_;
float noise_pow_est;
float angle1;
float angle2;
float noise_pow_est_;
float angle1_;
float angle2_;
int32_t length_;
int32_t n_segments;
int32_t n_segments_est;
int32_t n_segments_reset;
int32_t n_segments_coeff_reset;
int32_t n_segments_coeff;
int32_t n_deg_fred;
int32_t n_segments_;
int32_t n_segments_est_;
int32_t n_segments_reset_;
int32_t n_segments_coeff_reset_;
int32_t n_segments_coeff_;
int32_t n_deg_fred_;
bool filter_state_;
};

View File

@ -24,15 +24,15 @@
#include <algorithm>
pulse_blanking_cc_sptr make_pulse_blanking_cc(float pfa, int32_t length_,
pulse_blanking_cc_sptr make_pulse_blanking_cc(float pfa, int32_t length,
int32_t n_segments_est, int32_t n_segments_reset)
{
return pulse_blanking_cc_sptr(new pulse_blanking_cc(pfa, length_, n_segments_est, n_segments_reset));
return pulse_blanking_cc_sptr(new pulse_blanking_cc(pfa, length, n_segments_est, n_segments_reset));
}
pulse_blanking_cc::pulse_blanking_cc(float pfa,
int32_t length_,
int32_t length,
int32_t n_segments_est,
int32_t n_segments_reset) : gr::block("pulse_blanking_cc",
gr::io_signature::make(1, 1, sizeof(gr_complex)),
@ -40,16 +40,16 @@ pulse_blanking_cc::pulse_blanking_cc(float pfa,
{
const int32_t alignment_multiple = volk_get_alignment() / sizeof(gr_complex);
set_alignment(std::max(1, alignment_multiple));
this->pfa = pfa;
this->length_ = length_;
last_filtered = false;
n_segments = 0;
this->n_segments_est = n_segments_est;
this->n_segments_reset = n_segments_reset;
noise_power_estimation = 0.0;
n_deg_fred = 2 * length_;
boost::math::chi_squared_distribution<float> my_dist_(n_deg_fred);
thres_ = boost::math::quantile(boost::math::complement(my_dist_, pfa));
pfa_ = pfa;
length_ = length;
last_filtered_ = false;
n_segments_ = 0;
n_segments_est_ = n_segments_est;
n_segments_reset_ = n_segments_reset;
noise_power_estimation_ = 0.0;
n_deg_fred_ = 2 * length_;
boost::math::chi_squared_distribution<float> my_dist_(n_deg_fred_);
thres_ = boost::math::quantile(boost::math::complement(my_dist_, pfa_));
zeros_ = volk_gnsssdr::vector<gr_complex>(length_);
}
@ -66,32 +66,32 @@ int pulse_blanking_cc::general_work(int noutput_items, gr_vector_int &ninput_ite
while ((sample_index + length_) < noutput_items)
{
volk_32f_accumulator_s32f(&segment_energy, (magnitude.data() + sample_index), length_);
if ((n_segments < n_segments_est) && (last_filtered == false))
if ((n_segments_ < n_segments_est_) && (last_filtered_ == false))
{
noise_power_estimation = (static_cast<float>(n_segments) * noise_power_estimation + segment_energy / static_cast<float>(n_deg_fred)) / static_cast<float>(n_segments + 1);
noise_power_estimation_ = (static_cast<float>(n_segments_) * noise_power_estimation_ + segment_energy / static_cast<float>(n_deg_fred_)) / static_cast<float>(n_segments_ + 1);
memcpy(out, in, sizeof(gr_complex) * length_);
}
else
{
if ((segment_energy / noise_power_estimation) > thres_)
if ((segment_energy / noise_power_estimation_) > thres_)
{
memcpy(out, zeros_.data(), sizeof(gr_complex) * length_);
last_filtered = true;
last_filtered_ = true;
}
else
{
memcpy(out, in, sizeof(gr_complex) * length_);
last_filtered = false;
if (n_segments > n_segments_reset)
last_filtered_ = false;
if (n_segments_ > n_segments_reset_)
{
n_segments = 0;
n_segments_ = 0;
}
}
}
in += length_;
out += length_;
sample_index += length_;
n_segments++;
n_segments_++;
}
consume_each(sample_index);
return sample_index;

View File

@ -39,7 +39,7 @@ using pulse_blanking_cc_sptr = boost::shared_ptr<pulse_blanking_cc>;
pulse_blanking_cc_sptr make_pulse_blanking_cc(
float pfa,
int32_t length_,
int32_t length,
int32_t n_segments_est,
int32_t n_segments_reset);
@ -52,18 +52,18 @@ public:
gr_vector_const_void_star &input_items, gr_vector_void_star &output_items);
private:
friend pulse_blanking_cc_sptr make_pulse_blanking_cc(float pfa, int32_t length_, int32_t n_segments_est, int32_t n_segments_reset);
pulse_blanking_cc(float pfa, int32_t length_, int32_t n_segments_est, int32_t n_segments_reset);
friend pulse_blanking_cc_sptr make_pulse_blanking_cc(float pfa, int32_t length, int32_t n_segments_est, int32_t n_segments_reset);
pulse_blanking_cc(float pfa, int32_t length, int32_t n_segments_est, int32_t n_segments_reset);
volk_gnsssdr::vector<gr_complex> zeros_;
float noise_power_estimation;
float noise_power_estimation_;
float thres_;
float pfa;
float pfa_;
int32_t length_;
int32_t n_segments;
int32_t n_segments_est;
int32_t n_segments_reset;
int32_t n_deg_fred;
bool last_filtered;
int32_t n_segments_;
int32_t n_segments_est_;
int32_t n_segments_reset_;
int32_t n_deg_fred_;
bool last_filtered_;
};
#endif // GNSS_SDR_PULSE_BLANKING_H