mirror of
https://github.com/gnss-sdr/gnss-sdr
synced 2025-01-17 20:53:02 +00:00
Simplify gnuplot interface usage in tests
This commit is contained in:
parent
785d6185c3
commit
0164d6725d
@ -3,7 +3,7 @@
|
|||||||
* \brief A C++ interface to gnuplot.
|
* \brief A C++ interface to gnuplot.
|
||||||
* \author Carles Fernandez-Prades, 2017. cfernandez(at)cttc.es
|
* \author Carles Fernandez-Prades, 2017. cfernandez(at)cttc.es
|
||||||
*
|
*
|
||||||
* Source code found at https://code.google.com/archive/p/gnuplot-cpp/
|
* Original source code found at https://code.google.com/archive/p/gnuplot-cpp/
|
||||||
* by Jeremy Conlin jeremit0(at)gmail.com
|
* by Jeremy Conlin jeremit0(at)gmail.com
|
||||||
*
|
*
|
||||||
* Version history:
|
* Version history:
|
||||||
@ -16,6 +16,8 @@
|
|||||||
* 3. some member functions added, corrections for Win32 and Linux
|
* 3. some member functions added, corrections for Win32 and Linux
|
||||||
* compatibility
|
* compatibility
|
||||||
* by M. Burgis (10/03/08)
|
* by M. Burgis (10/03/08)
|
||||||
|
* 4. Some fixes and improvements for Linux and macOS
|
||||||
|
* by C. Fernandez (22/10/17)
|
||||||
* -------------------------------------------------------------------------
|
* -------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* Copyright (C) 2013-2017 (see AUTHORS file for a list of contributors)
|
* Copyright (C) 2013-2017 (see AUTHORS file for a list of contributors)
|
||||||
@ -121,6 +123,7 @@ private:
|
|||||||
/// \return <-- void
|
/// \return <-- void
|
||||||
// ---------------------------------------------------
|
// ---------------------------------------------------
|
||||||
void init();
|
void init();
|
||||||
|
|
||||||
// ---------------------------------------------------
|
// ---------------------------------------------------
|
||||||
///\brief creates tmpfile and returns its name
|
///\brief creates tmpfile and returns its name
|
||||||
///
|
///
|
||||||
@ -228,7 +231,8 @@ public:
|
|||||||
///
|
///
|
||||||
/// \return <-- a reference to the gnuplot object
|
/// \return <-- a reference to the gnuplot object
|
||||||
// ---------------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------------
|
||||||
inline Gnuplot& operator<<(const std::string &cmdstr){
|
inline Gnuplot& operator<<(const std::string &cmdstr)
|
||||||
|
{
|
||||||
cmd(cmdstr);
|
cmd(cmdstr);
|
||||||
return(*this);
|
return(*this);
|
||||||
}
|
}
|
||||||
@ -396,14 +400,12 @@ public:
|
|||||||
Gnuplot& set_zlabel(const std::string &label = "z");
|
Gnuplot& set_zlabel(const std::string &label = "z");
|
||||||
|
|
||||||
/// set axis - ranges
|
/// set axis - ranges
|
||||||
Gnuplot& set_xrange(const double iFrom,
|
Gnuplot& set_xrange(const double iFrom, const double iTo);
|
||||||
const double iTo);
|
|
||||||
/// set y-axis - ranges
|
/// set y-axis - ranges
|
||||||
Gnuplot& set_yrange(const double iFrom,
|
Gnuplot& set_yrange(const double iFrom, const double iTo);
|
||||||
const double iTo);
|
|
||||||
/// set z-axis - ranges
|
/// set z-axis - ranges
|
||||||
Gnuplot& set_zrange(const double iFrom,
|
Gnuplot& set_zrange(const double iFrom, const double iTo);
|
||||||
const double iTo);
|
|
||||||
/// autoscale axis (set by default) of xaxis
|
/// autoscale axis (set by default) of xaxis
|
||||||
///
|
///
|
||||||
/// \param ---
|
/// \param ---
|
||||||
@ -531,13 +533,11 @@ public:
|
|||||||
/// special functions: erf(x), erfc(x), inverf(x), gamma(x), igamma(a,x), lgamma(x), ibeta(p,q,x),
|
/// special functions: erf(x), erfc(x), inverf(x), gamma(x), igamma(a,x), lgamma(x), ibeta(p,q,x),
|
||||||
/// besj0(x), besj1(x), besy0(x), besy1(x), lambertw(x)
|
/// besj0(x), besj1(x), besy0(x), besy1(x), lambertw(x)
|
||||||
/// statistical fuctions: norm(x), invnorm(x)
|
/// statistical fuctions: norm(x), invnorm(x)
|
||||||
Gnuplot& plot_equation(const std::string &equation,
|
Gnuplot& plot_equation(const std::string &equation, const std::string &title = "");
|
||||||
const std::string &title = "");
|
|
||||||
|
|
||||||
/// plot an equation supplied as a std::string z=f(x,y), write only the function f(x,y) not z=
|
/// plot an equation supplied as a std::string z=f(x,y), write only the function f(x,y) not z=
|
||||||
/// the independent variables have to be x and y
|
/// the independent variables have to be x and y
|
||||||
Gnuplot& plot_equation3d(const std::string &equation,
|
Gnuplot& plot_equation3d(const std::string &equation, const std::string &title = "");
|
||||||
const std::string &title = "");
|
|
||||||
|
|
||||||
/// plot image
|
/// plot image
|
||||||
Gnuplot& plot_image(const unsigned char *ucPicBuf,
|
Gnuplot& plot_image(const unsigned char *ucPicBuf,
|
||||||
@ -844,7 +844,6 @@ Gnuplot& Gnuplot::plot_xyz(const X &x,
|
|||||||
//
|
//
|
||||||
bool Gnuplot::set_GNUPlotPath(const std::string &path)
|
bool Gnuplot::set_GNUPlotPath(const std::string &path)
|
||||||
{
|
{
|
||||||
|
|
||||||
std::string tmp = path + "/" + Gnuplot::m_sGNUPlotFileName;
|
std::string tmp = path + "/" + Gnuplot::m_sGNUPlotFileName;
|
||||||
|
|
||||||
#if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__TOS_WIN__)
|
#if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__TOS_WIN__)
|
||||||
|
42
src/tests/common-files/test_flags.h
Normal file
42
src/tests/common-files/test_flags.h
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
/*!
|
||||||
|
* \file test_flags.h
|
||||||
|
* \brief Helper file for unit testing
|
||||||
|
* \author Carles Fernandez-Prades, 2017. cfernandez(at)cttc.es
|
||||||
|
*
|
||||||
|
* -------------------------------------------------------------------------
|
||||||
|
*
|
||||||
|
* Copyright (C) 2010-2017 (see AUTHORS file for a list of contributors)
|
||||||
|
*
|
||||||
|
* GNSS-SDR is a software defined Global Navigation
|
||||||
|
* Satellite Systems receiver
|
||||||
|
*
|
||||||
|
* This file is part of GNSS-SDR.
|
||||||
|
*
|
||||||
|
* GNSS-SDR is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* GNSS-SDR is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with GNSS-SDR. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
* -------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef GNSS_SDR_TEST_FLAGS_H_
|
||||||
|
#define GNSS_SDR_TEST_FLAGS_H_
|
||||||
|
|
||||||
|
#include <gflags/gflags.h>
|
||||||
|
|
||||||
|
#if defined GNUPLOT_EXECUTABLE
|
||||||
|
DEFINE_string(gnuplot_executable, std::string(GNUPLOT_EXECUTABLE), "Gnuplot binary path");
|
||||||
|
#elif !defined GNUPLOT_EXECUTABLE
|
||||||
|
DEFINE_string(gnuplot_executable, "", "Gnuplot binary path");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
@ -35,14 +35,8 @@
|
|||||||
#include <random>
|
#include <random>
|
||||||
#include <boost/filesystem.hpp>
|
#include <boost/filesystem.hpp>
|
||||||
#include <gnuradio/fft/fft.h>
|
#include <gnuradio/fft/fft.h>
|
||||||
|
|
||||||
|
|
||||||
#if defined GNUPLOT_EXECUTABLE
|
|
||||||
#include "gnuplot_i.h"
|
#include "gnuplot_i.h"
|
||||||
const bool exists_gnuplot_fft_test_length = true;
|
#include "test_flags.h"
|
||||||
#elif !defined GNUPLOT_EXECUTABLE
|
|
||||||
const bool exists_gnuplot_fft_test_length = false;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
DEFINE_int32(fft_iterations_test, 1000, "Number of averaged iterations in FFT length timing test");
|
DEFINE_int32(fft_iterations_test, 1000, "Number of averaged iterations in FFT length timing test");
|
||||||
@ -108,7 +102,8 @@ TEST(FFTLengthTest, MeasureExecutionTime)
|
|||||||
|
|
||||||
if(FLAGS_plot_fft_length_test == true)
|
if(FLAGS_plot_fft_length_test == true)
|
||||||
{
|
{
|
||||||
if(!exists_gnuplot_fft_test_length)
|
const std::string gnuplot_executable(FLAGS_gnuplot_executable);
|
||||||
|
if(gnuplot_executable.empty())
|
||||||
{
|
{
|
||||||
std::cout << "WARNING: Although the flag plot_fft_length_test has been set to TRUE," << std::endl;
|
std::cout << "WARNING: Although the flag plot_fft_length_test has been set to TRUE," << std::endl;
|
||||||
std::cout << "gnuplot has not been found in your system." << std::endl;
|
std::cout << "gnuplot has not been found in your system." << std::endl;
|
||||||
@ -116,10 +111,8 @@ TEST(FFTLengthTest, MeasureExecutionTime)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
#if defined GNUPLOT_EXECUTABLE
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
std::string gnuplot_executable = std::string(GNUPLOT_EXECUTABLE);
|
|
||||||
boost::filesystem::path p(gnuplot_executable);
|
boost::filesystem::path p(gnuplot_executable);
|
||||||
boost::filesystem::path dir = p.parent_path();
|
boost::filesystem::path dir = p.parent_path();
|
||||||
std::string gnuplot_path = dir.native();
|
std::string gnuplot_path = dir.native();
|
||||||
@ -150,7 +143,6 @@ TEST(FFTLengthTest, MeasureExecutionTime)
|
|||||||
{
|
{
|
||||||
std::cout << ge.what() << std::endl;
|
std::cout << ge.what() << std::endl;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user