mirror of
https://github.com/gnss-sdr/gnss-sdr
synced 2024-12-14 20:20:35 +00:00
Adapt tests to .mat dump files
This commit is contained in:
parent
3270debac7
commit
f6aa86f60c
@ -444,6 +444,9 @@ void pcps_acquisition_cc::acquisition_core( unsigned long int samp_count )
|
||||
std::string filename = d_dump_filename;
|
||||
filename.append("_");
|
||||
filename.append(1, d_gnss_synchro->System);
|
||||
filename.append("_");
|
||||
filename.append(1, d_gnss_synchro->Signal[0]);
|
||||
filename.append(1, d_gnss_synchro->Signal[1]);
|
||||
filename.append("_sat_");
|
||||
filename.append(std::to_string(d_gnss_synchro->PRN));
|
||||
filename.append(".mat");
|
||||
|
@ -158,7 +158,7 @@ void GalileoE1PcpsAmbiguousAcquisitionTest::init()
|
||||
{
|
||||
config->set_property("Acquisition_1B.dump", "false");
|
||||
}
|
||||
config->set_property("Acquisition_1B.dump_filename", "./tmp-acq-gal1/acquisition.dat");
|
||||
config->set_property("Acquisition_1B.dump_filename", "./tmp-acq-gal1/acquisition");
|
||||
config->set_property("Acquisition_1B.threshold", "0.0001");
|
||||
config->set_property("Acquisition_1B.doppler_max", std::to_string(doppler_max));
|
||||
config->set_property("Acquisition_1B.doppler_step", std::to_string(doppler_step));
|
||||
|
@ -157,7 +157,7 @@ void GpsL1CaPcpsAcquisitionTest::init()
|
||||
{
|
||||
config->set_property("Acquisition_1C.dump", "false");
|
||||
}
|
||||
config->set_property("Acquisition_1C.dump_filename", "./tmp-acq-gps1/acquisition.dat");
|
||||
config->set_property("Acquisition_1C.dump_filename", "./tmp-acq-gps1/acquisition");
|
||||
config->set_property("Acquisition_1C.threshold", "0.00001");
|
||||
config->set_property("Acquisition_1C.doppler_max", std::to_string(doppler_max));
|
||||
config->set_property("Acquisition_1C.doppler_step", std::to_string(doppler_step));
|
||||
|
@ -164,7 +164,7 @@ void GpsL2MPcpsAcquisitionTest::init()
|
||||
{
|
||||
config->set_property("Acquisition_2S.dump", "false");
|
||||
}
|
||||
config->set_property("Acquisition_2S.dump_filename", "./tmp-acq-gps2/acquisition.dat");
|
||||
config->set_property("Acquisition_2S.dump_filename", "./tmp-acq-gps2/acquisition");
|
||||
config->set_property("Acquisition_2S.threshold", "0.001");
|
||||
config->set_property("Acquisition_2S.doppler_max", std::to_string(doppler_max));
|
||||
config->set_property("Acquisition_2S.doppler_step", std::to_string(doppler_step));
|
||||
@ -178,9 +178,8 @@ void GpsL2MPcpsAcquisitionTest::plot_grid()
|
||||
std::string basename = "./tmp-acq-gps2/acquisition_G_2S";
|
||||
unsigned int sat = static_cast<unsigned int>(gnss_synchro.PRN);
|
||||
|
||||
unsigned int samples_per_code = static_cast<unsigned int>(floor(sampling_frequency_hz / (GPS_L2_M_CODE_RATE_HZ / GPS_L2_M_CODE_LENGTH_CHIPS)) - 1000); // !!
|
||||
unsigned int samples_per_code = static_cast<unsigned int>(floor(static_cast<double>(sampling_frequency_hz) / (GPS_L2_M_CODE_RATE_HZ / static_cast<double>(GPS_L2_M_CODE_LENGTH_CHIPS))));
|
||||
acquisition_dump_reader acq_dump(basename, sat, doppler_max, doppler_step, samples_per_code);
|
||||
|
||||
if(!acq_dump.read_binary_acq()) std::cout << "Error reading files" << std::endl;
|
||||
|
||||
std::vector<int> *doppler = &acq_dump.doppler;
|
||||
@ -204,7 +203,7 @@ void GpsL2MPcpsAcquisitionTest::plot_grid()
|
||||
std::string gnuplot_path = dir.native();
|
||||
Gnuplot::set_GNUPlotPath(gnuplot_path);
|
||||
|
||||
Gnuplot g1("lines");
|
||||
Gnuplot g1("impulses");
|
||||
g1.set_title("GPS L2CM signal acquisition for satellite PRN #" + std::to_string(gnss_synchro.PRN));
|
||||
g1.set_xlabel("Doppler [Hz]");
|
||||
g1.set_ylabel("Sample");
|
||||
|
@ -1,11 +1,13 @@
|
||||
/*!
|
||||
* \file acquisition_dump_reader.cc
|
||||
* \brief Helper file for unit testing
|
||||
* \author Carles Fernandez-Prades, 2017. cfernandez(at)cttc.es
|
||||
* \authors Carles Fernandez-Prades, 2017. cfernandez(at)cttc.es
|
||||
* Antonio Ramos, 2018. antonio.ramos(at)cttc.es
|
||||
*
|
||||
*
|
||||
* -------------------------------------------------------------------------
|
||||
*
|
||||
* Copyright (C) 2010-2017 (see AUTHORS file for a list of contributors)
|
||||
* Copyright (C) 2010-2018 (see AUTHORS file for a list of contributors)
|
||||
*
|
||||
* GNSS-SDR is a software defined Global Navigation
|
||||
* Satellite Systems receiver
|
||||
@ -28,44 +30,65 @@
|
||||
* -------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#include <complex>
|
||||
#include <iostream>
|
||||
#include <cmath>
|
||||
#include <matio.h>
|
||||
#include "acquisition_dump_reader.h"
|
||||
|
||||
bool acquisition_dump_reader::read_binary_acq()
|
||||
{
|
||||
std::complex<float>* aux = new std::complex<float>[1];
|
||||
for(unsigned int i = 0; i < d_num_doppler_bins; i++)
|
||||
mat_t* matfile = Mat_Open(d_dump_filename.c_str(), MAT_ACC_RDONLY);
|
||||
if( matfile == NULL)
|
||||
{
|
||||
try
|
||||
{
|
||||
std::ifstream ifs;
|
||||
ifs.exceptions( std::ifstream::failbit | std::ifstream::badbit );
|
||||
ifs.open(d_dump_filenames.at(i).c_str(), std::ios::in | std::ios::binary);
|
||||
d_dump_files.at(i).swap(ifs);
|
||||
if (d_dump_files.at(i).is_open())
|
||||
{
|
||||
for(unsigned int k = 0; k < d_samples_per_code; k++)
|
||||
{
|
||||
d_dump_files.at(i).read(reinterpret_cast<char *>(&aux[0]), sizeof(std::complex<float>));
|
||||
mag.at(i).at(k) = std::abs(*aux) / std::pow(d_samples_per_code, 2);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << "File " << d_dump_filenames.at(i).c_str() << " not found." << std::endl;
|
||||
delete[] aux;
|
||||
std::cout << "¡¡¡Unreachable Acquisition dump file!!!" << std::endl;
|
||||
return false;
|
||||
}
|
||||
d_dump_files.at(i).close();
|
||||
}
|
||||
catch (const std::ifstream::failure &e)
|
||||
matvar_t* var_= Mat_VarRead(matfile, "grid");
|
||||
if( var_ == NULL)
|
||||
{
|
||||
std::cout << e.what() << std::endl;
|
||||
delete[] aux;
|
||||
std::cout << "¡¡¡Unreachable grid variable into Acquisition dump file!!!" << std::endl;
|
||||
Mat_Close(matfile);
|
||||
return false;
|
||||
}
|
||||
if(var_->rank != 2)
|
||||
{
|
||||
std::cout << "Invalid Acquisition dump file: rank error" << std::endl;
|
||||
Mat_VarFree(var_);
|
||||
Mat_Close(matfile);
|
||||
return false;
|
||||
}
|
||||
delete[] aux;
|
||||
if((var_->dims[0] != d_samples_per_code) or (var_->dims[1] != d_num_doppler_bins))
|
||||
{
|
||||
std::cout << "Invalid Acquisition dump file: dimension matrix error" << std::endl;
|
||||
if(var_->dims[0] != d_samples_per_code) std::cout << "Expected " << d_samples_per_code << " samples per code. Obtained " << var_->dims[0] << std::endl;
|
||||
if(var_->dims[1] != d_num_doppler_bins) std::cout << "Expected " << d_num_doppler_bins << " Doppler bins. Obtained " << var_->dims[1] << std::endl;
|
||||
Mat_VarFree(var_);
|
||||
Mat_Close(matfile);
|
||||
return false;
|
||||
}
|
||||
if(var_->data_type != MAT_T_SINGLE)
|
||||
{
|
||||
std::cout << "Invalid Acquisition dump file: data type error" << std::endl;
|
||||
Mat_VarFree(var_);
|
||||
Mat_Close(matfile);
|
||||
return false;
|
||||
}
|
||||
std::vector<std::vector<float> >::iterator it1;
|
||||
std::vector<float>::iterator it2;
|
||||
float* aux = static_cast<float*>(var_->data);
|
||||
int k = 0;
|
||||
float normalization_factor = std::pow(d_samples_per_code, 2);
|
||||
for(it1 = mag.begin(); it1 != mag.end(); it1++)
|
||||
{
|
||||
for(it2 = it1->begin(); it2 != it1->end(); it2++)
|
||||
{
|
||||
*it2 = static_cast<float>(std::sqrt(aux[k])) / normalization_factor;
|
||||
k++;
|
||||
}
|
||||
}
|
||||
Mat_VarFree(var_);
|
||||
Mat_Close(matfile);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -80,12 +103,10 @@ acquisition_dump_reader::acquisition_dump_reader(const std::string & basename, u
|
||||
d_num_doppler_bins = static_cast<unsigned int>(ceil( static_cast<double>(static_cast<int>(d_doppler_max) - static_cast<int>(-d_doppler_max)) / static_cast<double>(d_doppler_step)));
|
||||
std::vector<std::vector<float> > mag_aux(d_num_doppler_bins, std::vector<float>(d_samples_per_code));
|
||||
mag = mag_aux;
|
||||
d_dump_filename = d_basename + "_sat_" + std::to_string(d_sat) + ".mat";
|
||||
for (unsigned int doppler_index = 0; doppler_index < d_num_doppler_bins; doppler_index++)
|
||||
{
|
||||
doppler.push_back(-static_cast<int>(d_doppler_max) + d_doppler_step * doppler_index);
|
||||
d_dump_filenames.push_back(d_basename + "_sat_" + std::to_string(d_sat) + "_doppler_" + std::to_string(doppler.at(doppler_index)) + ".dat");
|
||||
std::ifstream ifs;
|
||||
d_dump_files.push_back(std::move(ifs));
|
||||
}
|
||||
for (unsigned int k = 0; k < d_samples_per_code; k++)
|
||||
{
|
||||
@ -95,12 +116,4 @@ acquisition_dump_reader::acquisition_dump_reader(const std::string & basename, u
|
||||
|
||||
|
||||
acquisition_dump_reader::~acquisition_dump_reader()
|
||||
{
|
||||
for(unsigned int i = 0; i < d_num_doppler_bins; i++)
|
||||
{
|
||||
if (d_dump_files.at(i).is_open() == true)
|
||||
{
|
||||
d_dump_files.at(i).close();
|
||||
}
|
||||
}
|
||||
}
|
||||
{}
|
||||
|
@ -1,11 +1,12 @@
|
||||
/*!
|
||||
* \file acquisition_dump_reader.h
|
||||
* \brief Helper file for unit testing
|
||||
* \author Carles Fernandez-Prades, 2017. cfernandez(at)cttc.es
|
||||
* \authors Carles Fernandez-Prades, 2017. cfernandez(at)cttc.es
|
||||
* Antonio Ramos, 2018. antonio.ramos(at)cttc.es
|
||||
*
|
||||
* -------------------------------------------------------------------------
|
||||
*
|
||||
* Copyright (C) 2010-2017 (see AUTHORS file for a list of contributors)
|
||||
* Copyright (C) 2010-2018 (see AUTHORS file for a list of contributors)
|
||||
*
|
||||
* GNSS-SDR is a software defined Global Navigation
|
||||
* Satellite Systems receiver
|
||||
@ -31,8 +32,6 @@
|
||||
#ifndef GNSS_SDR_ACQUISITION_DUMP_READER_H
|
||||
#define GNSS_SDR_ACQUISITION_DUMP_READER_H
|
||||
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
@ -54,8 +53,7 @@ private:
|
||||
unsigned int d_doppler_step;
|
||||
unsigned int d_samples_per_code;
|
||||
unsigned int d_num_doppler_bins;
|
||||
std::vector<std::string> d_dump_filenames;
|
||||
std::vector<std::ifstream> d_dump_files;
|
||||
std::string d_dump_filename;
|
||||
};
|
||||
|
||||
#endif // GNSS_SDR_ACQUISITION_DUMP_READER_H
|
||||
|
@ -32,10 +32,10 @@
|
||||
|
||||
%%%%%%%%% ¡¡¡ CONFIGURE !!! %%%%%%%%%%%%%
|
||||
|
||||
path = '/home/aramos/signals/GNSS-IN-THE-SPACE/CAPTURES SPIRENT/acq/';
|
||||
path = '/home/aramos/gnss-sdr/install/';
|
||||
file = 'acq';
|
||||
|
||||
sat = 9;
|
||||
sat = 7;
|
||||
|
||||
% Signal:
|
||||
% 1 GPS L1
|
||||
@ -47,10 +47,10 @@ sat = 9;
|
||||
signal_type = 1;
|
||||
|
||||
%%% True for light grid representation
|
||||
lite_view = false;
|
||||
lite_view = true;
|
||||
|
||||
%%% If lite_view, it sets the number of samples per chip in the graphical representation
|
||||
n_samples_per_chip = 4;
|
||||
n_samples_per_chip = 3;
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
||||
@ -58,20 +58,25 @@ switch(signal_type)
|
||||
case 1
|
||||
n_chips = 1023;
|
||||
system = 'G';
|
||||
signal = '1C';
|
||||
case 2
|
||||
n_chips = 10230;
|
||||
system = 'G';
|
||||
signal = '2S';
|
||||
case 3
|
||||
n_chips = 10230;
|
||||
system = 'G';
|
||||
signal = 'L5';
|
||||
case 4
|
||||
n_chips = 4092;
|
||||
system = 'E';
|
||||
signal = '1B';
|
||||
case 5
|
||||
n_chips = 10230;
|
||||
system = 'E';
|
||||
signal = '5X';
|
||||
end
|
||||
filename = [path file '_' system '_sat_' num2str(sat) '.mat'];
|
||||
filename = [path file '_' system '_' signal '_sat_' num2str(sat) '.mat'];
|
||||
load(filename);
|
||||
[n_fft n_dop_bins] = size(grid);
|
||||
[d_max f_max] = find(grid == max(max(grid)));
|
||||
|
Loading…
Reference in New Issue
Block a user