51
51
#include < itpp/itbase.h>
52
52
#include < itpp/signal/transforms.h>
53
53
#include < itpp/stat/misc_stat.h>
54
+ #include < itpp/signal/freq_filt.h>
54
55
#include < math.h>
55
56
#include < list>
56
57
#include < iomanip>
@@ -1883,6 +1884,39 @@ void normalize(
1883
1884
s = sqrt (len)*s/sqrt (acc);
1884
1885
}
1885
1886
1887
+ // FIR 6RB filter
1888
+ void filter_my_fft (
1889
+ // Inputs
1890
+ const vec & coef,
1891
+ // Inputs&Outputs
1892
+ cvec & capbuf
1893
+ ) {
1894
+ uint32 len = length (capbuf);
1895
+ uint16 len_fir = length (coef);
1896
+ uint16 len_half = (len_fir-1 )/2 ;
1897
+
1898
+ vec tmpbufin_re (len+len_fir-1 );
1899
+ vec tmpbufin_im (len+len_fir-1 );
1900
+
1901
+ tmpbufin_re.set_subvector (0 , real (capbuf));
1902
+ tmpbufin_im.set_subvector (0 , imag (capbuf));
1903
+ tmpbufin_re.set_subvector (len, len+len_fir-1 , 0 );
1904
+ tmpbufin_im.set_subvector (len, len+len_fir-1 , 0 );
1905
+
1906
+ Freq_Filt<double > FF (coef, len+len_fir-1 );
1907
+
1908
+ // Real_Timer tt;
1909
+ // tt.tic();
1910
+ vec tmpbufout_re = FF.filter (tmpbufin_re);
1911
+ vec tmpbufout_im = FF.filter (tmpbufin_im);
1912
+ // cout << "2 cost " << tt.get_time() << "s\n";
1913
+ // cout << tmpbufout_re(len_half, len_half+7) << "\n";
1914
+
1915
+ for (uint32 i=0 ; i<len; i++) {
1916
+ capbuf (i) = complex<double >(tmpbufout_re (i+len_half), tmpbufout_im (i+len_half));
1917
+ }
1918
+ }
1919
+
1886
1920
// FIR 6RB filter
1887
1921
void filter_my (
1888
1922
// Inputs
@@ -2248,7 +2282,7 @@ void sampling_ppm_f_search_set_by_pss(
2248
2282
const uint32 pss_period = 19200 /2 ;
2249
2283
2250
2284
const uint32 num_half_radioframe = len_short/pss_period;
2251
- vec peak_to_avg (num_fo_pss);
2285
+ vec peak_to_avg_combined_max (num_fo_pss);
2252
2286
mat corr_store_tmp (num_fo_pss, pss_period);
2253
2287
corr_store_tmp = corr_store.get_cols (0 , pss_period-1 );
2254
2288
for (uint16 j=1 ; j<num_half_radioframe; j++) {
@@ -2278,7 +2312,7 @@ void sampling_ppm_f_search_set_by_pss(
2278
2312
tmp_peak = sum ( corr_store_tmp_col.get (sum_range) );
2279
2313
2280
2314
tmp_avg_val = (sum (corr_store_tmp_col) - tmp_peak)/((double )pss_period-(2.0 *(double )num_half_radioframe+1.0 ));
2281
- peak_to_avg (j) = tmp_peak /tmp_avg_val;
2315
+ peak_to_avg_combined_max (j) = corr_store_tmp (j, tmp_max_idx) /tmp_avg_val;
2282
2316
2283
2317
// tmp_store = corr_store.get_row(j);
2284
2318
// logical_tmp = tmp_store > (max_peak_all(j)*2/3);
@@ -2287,9 +2321,9 @@ void sampling_ppm_f_search_set_by_pss(
2287
2321
2288
2322
ivec sort_idx = sort_index (max_peak_all);
2289
2323
sort_idx = reverse (sort_idx); // from ascending to descending
2290
- cout << " Hit PAR " << 10.0 *log10 ( peak_to_avg .get ( sort_idx (0 , max_reserve-1 ) ) ) << " dB\n " ;
2324
+ cout << " Hit PAR " << 10.0 *log10 ( peak_to_avg_combined_max .get ( sort_idx (0 , max_reserve-1 ) ) ) << " dB\n " ;
2291
2325
2292
- ivec above_par_idx = to_ivec ( peak_to_avg .get ( sort_idx (0 , max_reserve-1 ) ) > pow (10.0 , 16 /10.0 ) );
2326
+ ivec above_par_idx = to_ivec ( peak_to_avg_combined_max .get ( sort_idx (0 , max_reserve-1 ) ) > pow (10.0 , 8.5 /10.0 ) );
2293
2327
uint16 len_sort_idx = sum (above_par_idx);
2294
2328
2295
2329
if (len_sort_idx==0 ) {
0 commit comments