Commit 4defbf2b authored by sakthipriyas's avatar sakthipriyas
Browse files

updated with previous review comments

parent 775f0528
...@@ -16,9 +16,7 @@ set(psrdada_cpp_effelsberg_edd_src ...@@ -16,9 +16,7 @@ set(psrdada_cpp_effelsberg_edd_src
src/EDDRoach.cpp src/EDDRoach.cpp
src/EDDRoach_merge.cpp src/EDDRoach_merge.cpp
src/ScaledTransposeTFtoTFT.cu src/ScaledTransposeTFtoTFT.cu
src/SKRfiReplacement.cpp
src/SKRfiReplacementCuda.cu src/SKRfiReplacementCuda.cu
src/SpectralKurtosis.cpp
src/SpectralKurtosisCuda.cu src/SpectralKurtosisCuda.cu
src/Tools.cu src/Tools.cu
src/Unpacker.cu src/Unpacker.cu
......
#ifndef PSRDADA_CPP_EFFELSBERG_EDD_SKRFIREPLACEMENTCUDA_CUH
#define PSRDADA_CPP_EFFELSBERG_EDD_SKRFIREPLACEMENTCUDA_CUH
#include "psrdada_cpp/common.hpp" #include "psrdada_cpp/common.hpp"
#include <thrust/host_vector.h> #include <thrust/host_vector.h>
#include <thrust/device_vector.h> #include <thrust/device_vector.h>
...@@ -15,8 +18,6 @@ namespace psrdada_cpp { ...@@ -15,8 +18,6 @@ namespace psrdada_cpp {
namespace effelsberg { namespace effelsberg {
namespace edd { namespace edd {
#define DEFAULT_NUM_CLEAN_WINDOWS 1 //number of clean windows used for computing DataStatistics
class SKRfiReplacementCuda{ class SKRfiReplacementCuda{
public: public:
/** /**
...@@ -32,11 +33,13 @@ public: ...@@ -32,11 +33,13 @@ public:
/** /**
* @brief Replaces data in rfi_windows with replacement data (generated using statistics of data from clean_windows). * @brief Replaces data in rfi_windows with replacement data (generated using statistics of data from clean_windows).
* *
* @param(in) rfi_status rfi_status of input data * @param(in) rfi_status rfi_status of input data
* @param(in & out) data Data on which RFI has to be replaced. Returns the same but with RFI replaced. * @param(in & out) data Data on which RFI has to be replaced. Returns the same but with RFI replaced.
* @param(in) clean_windows number of clean windows used for computing data statistics.
*/ */
void replace_rfi_data(const thrust::device_vector<int> &rfi_status, void replace_rfi_data(const thrust::device_vector<int> &rfi_status,
thrust::device_vector<thrust::complex<float>> &data); thrust::device_vector<thrust::complex<float>> &data,
std::size_t clean_windows = 5);
private: private:
/** /**
...@@ -70,6 +73,7 @@ private: ...@@ -70,6 +73,7 @@ private:
thrust::device_vector<int> _rfi_status; thrust::device_vector<int> _rfi_status;
std::size_t _window_size; std::size_t _window_size;
std::size_t _nwindows, _nrfi_windows, _nclean_windows; std::size_t _nwindows, _nrfi_windows, _nclean_windows;
std::size_t _nclean_windows_stat; //number of clean windows used for computing DataStatistics
thrust::device_vector<int> _rfi_window_indices; thrust::device_vector<int> _rfi_window_indices;
thrust::device_vector<int> _clean_window_indices; thrust::device_vector<int> _clean_window_indices;
thrust::device_vector<thrust::complex <float>> _clean_data; thrust::device_vector<thrust::complex <float>> _clean_data;
...@@ -78,3 +82,5 @@ private: ...@@ -78,3 +82,5 @@ private:
} //edd } //edd
} //effelsberg } //effelsberg
} //psrdada_cpp } //psrdada_cpp
#endif //PSRDADA_CPP_EFFELSBERG_EDD_SKRFIREPLACEMENTCUDA_CUH
#ifndef PSRDADA_CPP_EFFELSBERG_EDD_SPECTRALKURTOSISCUDA_CUH
#define PSRDADA_CPP_EFFELSBERG_EDD_SPECTRALKURTOSISCUDA_CUH
#include "psrdada_cpp/common.hpp" #include "psrdada_cpp/common.hpp"
#include <thrust/device_vector.h> #include <thrust/device_vector.h>
#include <thrust/host_vector.h> #include <thrust/host_vector.h>
...@@ -14,8 +17,6 @@ namespace psrdada_cpp { ...@@ -14,8 +17,6 @@ namespace psrdada_cpp {
namespace effelsberg { namespace effelsberg {
namespace edd { namespace edd {
#define DEFAULT_SK_MIN 0.9
#define DEFAULT_SK_MAX 1.1
#define BLOCK_DIM 1024 #define BLOCK_DIM 1024
struct RFIStatistics{ struct RFIStatistics{
...@@ -33,27 +34,28 @@ public: ...@@ -33,27 +34,28 @@ public:
* @param(in) sk_min minimum value of spectral kurtosis. * @param(in) sk_min minimum value of spectral kurtosis.
* @param(in) sk_max maximum value of spectral kurtosis. * @param(in) sk_max maximum value of spectral kurtosis.
*/ */
SpectralKurtosisCuda(std::size_t nchannels, std::size_t window_size, float sk_min = DEFAULT_SK_MIN, SpectralKurtosisCuda(std::size_t nchannels, std::size_t window_size, float sk_min = 0.8,
float sk_max = DEFAULT_SK_MAX); float sk_max = 1.2);
~SpectralKurtosisCuda(); ~SpectralKurtosisCuda();
/** /**
* @brief computes spectral kurtosis for the given data and returns its rfi statistics. * @brief computes spectral kurtosis for the given data using thrust calls and returns its rfi statistics.
* This is used to compare and verify the results generated by compute_sk - an optimized kernel implementation.
* *
* @param(in) data input data * @param(in) data input data
* @param(out) stats RFI statistics * @param(out) stats RFI statistics
* *
*/ */
void compute_sk(thrust::device_vector<thrust::complex<float>> const& data, RFIStatistics &stats); void compute_sk_thrust(thrust::device_vector<thrust::complex<float>> const& data, RFIStatistics &stats);
/** /**
* @brief computes spectral kurtosis (using optimized kernel fucntion) for the given data and returns its rfi statistics. * @brief computes spectral kurtosis (using optimized kernel function) for the given data and returns its rfi statistics.
* *
* @param(in) data input data * @param(in) data input data
* @param(out) stats RFI statistics * @param(out) stats RFI statistics
* *
*/ */
void compute_sk_k(thrust::device_vector<thrust::complex<float>> &data, RFIStatistics &stats); void compute_sk(thrust::device_vector<thrust::complex<float>> &data, RFIStatistics &stats);
private: private:
/** /**
...@@ -67,7 +69,10 @@ private: ...@@ -67,7 +69,10 @@ private:
std::size_t _sample_size; //size of input data std::size_t _sample_size; //size of input data
float _sk_min, _sk_max; float _sk_min, _sk_max;
thrust::device_vector<float> _d_s1, _d_s2; thrust::device_vector<float> _d_s1, _d_s2;
cudaStream_t _stream;
}; };
} //edd } //edd
} //effelsberg } //effelsberg
} //psrdada_cpp } //psrdada_cpp
#endif //PSRDADA_CPP_EFFELSBERG_EDD_SPECTRALKURTOSISCUDA_CUH
...@@ -66,7 +66,13 @@ void SKRfiReplacementCuda::get_clean_window_indices() ...@@ -66,7 +66,13 @@ void SKRfiReplacementCuda::get_clean_window_indices()
{ {
nvtxRangePushA("get_clean_window_indices"); nvtxRangePushA("get_clean_window_indices");
_nclean_windows = thrust::count(_rfi_status.begin(), _rfi_status.end(), 0); _nclean_windows = thrust::count(_rfi_status.begin(), _rfi_status.end(), 0);
_clean_window_indices.resize(DEFAULT_NUM_CLEAN_WINDOWS); if (_nclean_windows > _nclean_windows_stat) _clean_window_indices.resize(_nclean_windows_stat);
else{
BOOST_LOG_TRIVIAL(info) << "Total number of clean windows is less than number of clean windows (_nclean_windows_stat)"
<< "chosen to compute data statistics.\n"
<<" Therefore choosing total clean windows for statistics computation.\n";
_clean_window_indices.resize(_nclean_windows);
}
thrust::copy_if(thrust::make_counting_iterator<int>(0), thrust::copy_if(thrust::make_counting_iterator<int>(0),
thrust::make_counting_iterator<int>(_nwindows), thrust::make_counting_iterator<int>(_nwindows),
_rfi_status.begin(), _rfi_status.begin(),
...@@ -79,8 +85,8 @@ void SKRfiReplacementCuda::get_clean_data_statistics(const thrust::device_vector ...@@ -79,8 +85,8 @@ void SKRfiReplacementCuda::get_clean_data_statistics(const thrust::device_vector
{ {
nvtxRangePushA("get_clean_data_statistics"); nvtxRangePushA("get_clean_data_statistics");
_window_size = data.size() / _nwindows; _window_size = data.size() / _nwindows;
_clean_data.resize(DEFAULT_NUM_CLEAN_WINDOWS * _window_size); _clean_data.resize(_nclean_windows_stat * _window_size);
for(std::size_t ii = 0; ii < DEFAULT_NUM_CLEAN_WINDOWS; ii++){ for(std::size_t ii = 0; ii < _nclean_windows_stat; ii++){
std::size_t window_index = _clean_window_indices[ii]; std::size_t window_index = _clean_window_indices[ii];
std::size_t ibegin = window_index * _window_size; std::size_t ibegin = window_index * _window_size;
std::size_t iend = ibegin + _window_size - 1; std::size_t iend = ibegin + _window_size - 1;
...@@ -97,6 +103,8 @@ void SKRfiReplacementCuda::compute_clean_data_statistics() ...@@ -97,6 +103,8 @@ void SKRfiReplacementCuda::compute_clean_data_statistics()
{ {
nvtxRangePushA("compute_clean_data_statistics"); nvtxRangePushA("compute_clean_data_statistics");
std::size_t length = _clean_data.size(); std::size_t length = _clean_data.size();
//The distribution of both real and imag have same mean and standard deviation.
//Therefore computing _ref_mean, _ref_sd for real distribution only.
_ref_mean = (thrust::reduce(_clean_data.begin(), _clean_data.end(), thrust::complex<float> (0.0f, 0.0f))). real() / length; _ref_mean = (thrust::reduce(_clean_data.begin(), _clean_data.end(), thrust::complex<float> (0.0f, 0.0f))). real() / length;
_ref_sd = std::sqrt(thrust::transform_reduce(_clean_data.begin(), _clean_data.end(), mean_subtraction_square(_ref_mean), _ref_sd = std::sqrt(thrust::transform_reduce(_clean_data.begin(), _clean_data.end(), mean_subtraction_square(_ref_mean),
0.0f, thrust::plus<float> ()) / length); 0.0f, thrust::plus<float> ()) / length);
...@@ -106,15 +114,17 @@ void SKRfiReplacementCuda::compute_clean_data_statistics() ...@@ -106,15 +114,17 @@ void SKRfiReplacementCuda::compute_clean_data_statistics()
} }
void SKRfiReplacementCuda::replace_rfi_data(const thrust::device_vector<int> &rfi_status, void SKRfiReplacementCuda::replace_rfi_data(const thrust::device_vector<int> &rfi_status,
thrust::device_vector<thrust::complex<float>> &data) thrust::device_vector<thrust::complex<float>> &data,
std::size_t clean_windows)
{ {
nvtxRangePushA("replace_rfi_data"); nvtxRangePushA("replace_rfi_data");
_rfi_status = rfi_status; _rfi_status = rfi_status;
thrust::device_vector<thrust::complex<float>> replacement_data; thrust::device_vector<thrust::complex<float>> replacement_data;
//initialize data members of the class //initialize data members of the class
_nclean_windows_stat = clean_windows; //no. of clean windows used for computing statistics
init(); init();
//RFI present and not in all windows //RFI present and not in all windows
if((_nrfi_windows > 0) && (_nrfi_windows < _nwindows)){ if(_nclean_windows < _nwindows){
get_clean_data_statistics(data); get_clean_data_statistics(data);
//Replacing RFI //Replacing RFI
thrust::counting_iterator<unsigned int> sequence_index_begin(0); thrust::counting_iterator<unsigned int> sequence_index_begin(0);
......
...@@ -97,11 +97,13 @@ SpectralKurtosisCuda::SpectralKurtosisCuda(std::size_t nchannels, std::size_t wi ...@@ -97,11 +97,13 @@ SpectralKurtosisCuda::SpectralKurtosisCuda(std::size_t nchannels, std::size_t wi
_sk_max(sk_max) _sk_max(sk_max)
{ {
BOOST_LOG_TRIVIAL(debug) << "Creating new SpectralKurtosisCuda instance... \n"; BOOST_LOG_TRIVIAL(debug) << "Creating new SpectralKurtosisCuda instance... \n";
cudaStreamCreate(&_stream);
} }
SpectralKurtosisCuda::~SpectralKurtosisCuda() SpectralKurtosisCuda::~SpectralKurtosisCuda()
{ {
BOOST_LOG_TRIVIAL(debug) << "Destroying SpectralKurtosisCuda instance... \n"; BOOST_LOG_TRIVIAL(debug) << "Destroying SpectralKurtosisCuda instance... \n";
cudaStreamDestroy(_stream);
} }
void SpectralKurtosisCuda::init() void SpectralKurtosisCuda::init()
...@@ -112,17 +114,17 @@ void SpectralKurtosisCuda::init() ...@@ -112,17 +114,17 @@ void SpectralKurtosisCuda::init()
throw std::runtime_error("Data(sample) size is not a multiple of window_size. Give different window size. \n"); throw std::runtime_error("Data(sample) size is not a multiple of window_size. Give different window size. \n");
} }
_nwindows = _sample_size /_window_size; _nwindows = _sample_size /_window_size;
_d_s1.resize(_nwindows);
_d_s2.resize(_nwindows);
} }
void SpectralKurtosisCuda::compute_sk(const thrust::device_vector<thrust::complex<float>> &data, RFIStatistics &stats){ void SpectralKurtosisCuda::compute_sk_thrust(const thrust::device_vector<thrust::complex<float>> &data, RFIStatistics &stats){
nvtxRangePushA("compute_sk"); nvtxRangePushA("compute_sk");
_sample_size = data.size(); _sample_size = data.size();
BOOST_LOG_TRIVIAL(debug) << "Computing SK (thrust version) for sample_size " << _sample_size BOOST_LOG_TRIVIAL(debug) << "Computing SK (thrust version) for sample_size " << _sample_size
<< " and window_size " << _window_size <<".\n"; << " and window_size " << _window_size <<".\n";
//initializing class variables //initializing class variables
init(); init();
_d_s1.resize(_nwindows);
_d_s2.resize(_nwindows);
//computing _d_s1 for all windows //computing _d_s1 for all windows
nvtxRangePushA("compute_sk_reduce_by_key_call"); nvtxRangePushA("compute_sk_reduce_by_key_call");
thrust::reduce_by_key(thrust::device, thrust::reduce_by_key(thrust::device,
...@@ -149,20 +151,18 @@ void SpectralKurtosisCuda::compute_sk(const thrust::device_vector<thrust::comple ...@@ -149,20 +151,18 @@ void SpectralKurtosisCuda::compute_sk(const thrust::device_vector<thrust::comple
nvtxRangePop(); nvtxRangePop();
} }
void SpectralKurtosisCuda::compute_sk_k(thrust::device_vector<thrust::complex<float>> &data, RFIStatistics &stats){ void SpectralKurtosisCuda::compute_sk(thrust::device_vector<thrust::complex<float>> &data, RFIStatistics &stats){
nvtxRangePushA("compute_sk_kernel"); nvtxRangePushA("compute_sk_kernel");
_sample_size = data.size(); _sample_size = data.size();
BOOST_LOG_TRIVIAL(debug) << "Computing SK (kernel version) for sample_size " << _sample_size BOOST_LOG_TRIVIAL(debug) << "Computing SK (kernel version) for sample_size " << _sample_size
<< " and window_size " << _window_size <<".\n"; << " and window_size " << _window_size <<".\n";
//initializing variables
_nwindows = _sample_size / _window_size; init();
stats.rfi_status.resize(_nwindows); stats.rfi_status.resize(_nwindows);
thrust::complex<float> *k_data = thrust::raw_pointer_cast(data.data());
int *k_rfi_status = thrust::raw_pointer_cast(stats.rfi_status.data()); int *k_rfi_status = thrust::raw_pointer_cast(stats.rfi_status.data());
int blockSize = BLOCK_DIM; thrust::complex<float> *k_data = thrust::raw_pointer_cast(data.data());
int gridSize = _nwindows;
nvtxRangePushA("compute_sk_kernel_call"); nvtxRangePushA("compute_sk_kernel_call");
compute_sk_kernel<<<gridSize, blockSize>>> (k_data, _sample_size, _window_size, _sk_max, _sk_min, k_rfi_status); compute_sk_kernel<<<_nwindows, BLOCK_DIM, 0, _stream>>> (k_data, _sample_size, _window_size, _sk_max, _sk_min, k_rfi_status);
cudaDeviceSynchronize(); cudaDeviceSynchronize();
nvtxRangePop(); nvtxRangePop();
nvtxRangePushA("compute_sk_kernel_rfi_fraction"); nvtxRangePushA("compute_sk_kernel_rfi_fraction");
......
...@@ -14,6 +14,8 @@ set( ...@@ -14,6 +14,8 @@ set(
src/VLBITest.cu src/VLBITest.cu
src/EDDPolnMergeTester.cpp src/EDDPolnMergeTester.cpp
src/SKTestVector.cpp src/SKTestVector.cpp
src/SpectralKurtosis.cpp
src/SKRfiReplacement.cpp
src/SpectralKurtosisTester.cpp src/SpectralKurtosisTester.cpp
src/SpectralKurtosisCudaTester.cu src/SpectralKurtosisCudaTester.cu
) )
......
#include "psrdada_cpp/common.hpp"
#include <fstream>
#include <complex>
#include <vector>
namespace psrdada_cpp {
namespace effelsberg {
namespace edd {
# define DADA_HDR_SIZE 4096
class ReadData
{
public:
std::vector<std::complex<float>> _pol0, _pol1;
std::size_t _sample_size;
//int _sample_size;
ReadData(std::string filename);
void read_file();
private:
std::string _filename;
};
} //edd
} //effelsberg
} //psrdada_cpp
#ifndef PSRDADA_CPP_EFFELSBERG_EDD_SKRFIREPLACEMENT_HPP
#define PSRDADA_CPP_EFFELSBERG_EDD_SKRFIREPLACEMENT_HPP
#include "psrdada_cpp/common.hpp" #include "psrdada_cpp/common.hpp"
#include <vector> #include <vector>
#include <complex> #include <complex>
...@@ -89,3 +92,5 @@ private: ...@@ -89,3 +92,5 @@ private:
} //edd } //edd
} //effelsberg } //effelsberg
} //psrdada_cpp } //psrdada_cpp
#endif //PSRDADA_CPP_EFFELSBERG_EDD_SKRFIREPLACEMENT_HPP
#ifndef PSRDADA_CPP_EFFELSBERG_EDD_SKTESTVECTOR_HPP
#define PSRDADA_CPP_EFFELSBERG_EDD_SKTESTVECTOR_HPP
#include "psrdada_cpp/common.hpp" #include "psrdada_cpp/common.hpp"
#include <complex> #include <complex>
...@@ -67,3 +70,4 @@ private: ...@@ -67,3 +70,4 @@ private:
} //effelsberg } //effelsberg
} //psrdada_cpp } //psrdada_cpp
#endif //PSRDADA_CPP_EFFELSBERG_EDD_SKTESTVECTOR_HPP
#ifndef PSRDADA_CPP_EFFELSBERG_EDD_SPECTRALKURTOSIS_HPP
#define PSRDADA_CPP_EFFELSBERG_EDD_SPECTRALKURTOSIS_HPP
#include "psrdada_cpp/common.hpp" #include "psrdada_cpp/common.hpp"
#include <complex> #include <complex>
#include <vector> #include <vector>
...@@ -7,9 +10,6 @@ namespace psrdada_cpp { ...@@ -7,9 +10,6 @@ namespace psrdada_cpp {
namespace effelsberg { namespace effelsberg {
namespace edd { namespace edd {
#define DEFAULT_SK_MIN 0.9
#define DEFAULT_SK_MAX 1.1
struct RFIStatistics{ struct RFIStatistics{
std::vector<int> rfi_status; std::vector<int> rfi_status;
float rfi_fraction; float rfi_fraction;
...@@ -25,8 +25,8 @@ public: ...@@ -25,8 +25,8 @@ public:
* sk_min minimum value of spectral kurtosis. * sk_min minimum value of spectral kurtosis.
* sk_max maximum value of spectral kurtosis. * sk_max maximum value of spectral kurtosis.
*/ */
SpectralKurtosis(std::size_t nchannels, std::size_t window_size, float sk_min = DEFAULT_SK_MIN, SpectralKurtosis(std::size_t nchannels, std::size_t window_size, float sk_min = 0.9,
float sk_max = DEFAULT_SK_MAX); float sk_max = 1.1);
~SpectralKurtosis(); ~SpectralKurtosis();
/** /**
...@@ -56,3 +56,4 @@ private: ...@@ -56,3 +56,4 @@ private:
} //effelsberg } //effelsberg
} //psrdada_cpp } //psrdada_cpp
#endif //PSRDADA_CPP_EFFELSBERG_EDD_SPECTRALKURTOSIS_HPP
#ifndef PSRDADA_CPP_EFFELSBERG_EDD_SPECTRALKURTOSISCUDATESTER_CUH
#define PSRDADA_CPP_EFFELSBERG_EDD_SPECTRALKURTOSISCUDATESTER_CUH
#include "psrdada_cpp/common.hpp" #include "psrdada_cpp/common.hpp"
#include "psrdada_cpp/effelsberg/edd/test/SKTestVector.hpp" #include "psrdada_cpp/effelsberg/edd/test/SKTestVector.hpp"
#include "psrdada_cpp/effelsberg/edd/SpectralKurtosisCuda.cuh" #include "psrdada_cpp/effelsberg/edd/SpectralKurtosisCuda.cuh"
...@@ -40,6 +43,4 @@ protected: ...@@ -40,6 +43,4 @@ protected:
} //effelsberg } //effelsberg
} //psrdada_cpp } //psrdada_cpp
#endif //PSRDADA_CPP_EFFELSBERG_EDD_SPECTRALKURTOSISCUDATESTER_CUH
#ifndef PSRDADA_CPP_EFFELSBERG_EDD_SPECTRALKURTOSISTESTER_HPP
#define PSRDADA_CPP_EFFELSBERG_EDD_SPECTRALKURTOSISTESTER_HPP
#include "psrdada_cpp/common.hpp" #include "psrdada_cpp/common.hpp"
#include "psrdada_cpp/effelsberg/edd/SKRfiReplacement.hpp" #include "psrdada_cpp/effelsberg/edd/test/SKRfiReplacement.hpp"
#include "psrdada_cpp/effelsberg/edd/SpectralKurtosis.hpp" #include "psrdada_cpp/effelsberg/edd/test/SpectralKurtosis.hpp"
#include "psrdada_cpp/effelsberg/edd/test/SKTestVector.hpp" #include "psrdada_cpp/effelsberg/edd/test/SKTestVector.hpp"
#include <gtest/gtest.h> #include <gtest/gtest.h>
...@@ -38,6 +41,4 @@ protected: ...@@ -38,6 +41,4 @@ protected:
} //effelsberg } //effelsberg
} //psrdada_cpp } //psrdada_cpp
#endif //PSRDADA_CPP_EFFELSBERG_EDD_SPECTRALKURTOSISTESTER_HPP
#include "psrdada_cpp/effelsberg/edd/SKRfiReplacement.hpp" #include "psrdada_cpp/effelsberg/edd/test/SKRfiReplacement.hpp"
namespace psrdada_cpp { namespace psrdada_cpp {
namespace effelsberg { namespace effelsberg {
......
#include "psrdada_cpp/effelsberg/edd/SpectralKurtosis.hpp" #include "psrdada_cpp/effelsberg/edd/test/SpectralKurtosis.hpp"
namespace psrdada_cpp { namespace psrdada_cpp {
namespace effelsberg { namespace effelsberg {
......
...@@ -49,20 +49,32 @@ TEST_F(SpectralKurtosisCudaTester, sk_window_size_check) ...@@ -49,20 +49,32 @@ TEST_F(SpectralKurtosisCudaTester, sk_window_size_check)
{ {
std::vector<int> rfi_window_indices{}; std::vector<int> rfi_window_indices{};
std::vector<std::complex<float>> samples; std::vector<std::complex<float>> samples;
test_vector_generation(4000, 150, 0, 0, 0, rfi_window_indices, samples); std::size_t sample_size = 4000;
std::size_t window_size = 150;
bool with_rfi = 0;
float rfi_freq = 0;
float rfi_amp = 0;
test_vector_generation(sample_size, window_size, with_rfi, rfi_freq, rfi_amp, rfi_window_indices, samples);
RFIStatistics stat; RFIStatistics stat;
EXPECT_THROW(sk_computation(1, 150, samples, stat), std::runtime_error); std::size_t nch = 1;
EXPECT_THROW(sk_computation(nch, window_size, samples, stat), std::runtime_error);
} }
TEST_F(SpectralKurtosisCudaTester, sk_withoutRFI) TEST_F(SpectralKurtosisCudaTester, sk_withoutRFI)
{ {
std::vector<int> rfi_window_indices{}; std::vector<int> rfi_window_indices{};
std::vector<std::complex<float>> samples; std::vector<std::complex<float>> samples;
test_vector_generation(40000, 400, 0, 0, 0, rfi_window_indices, samples); std::size_t sample_size = 40000;
std::size_t window_size = 400;
bool with_rfi = 0;
float rfi_freq = 0;
float rfi_amp = 0;
test_vector_generation(sample_size, window_size, with_rfi, rfi_freq, rfi_amp, rfi_window_indices, samples);
RFIStatistics stat; RFIStatistics stat;
sk_computation(1, 400, samples, stat); std::size_t nch = 1;
sk_computation(nch, window_size, samples, stat);
float expected_rfi_fraction = 0; float expected_rfi_fraction = 0;
EXPECT_EQ(expected_rfi_fraction, stat.rfi_fraction); EXPECT_EQ(expected_rfi_fraction, stat.rfi_fraction);
} }
...@@ -71,34 +83,41 @@ TEST_F(SpectralKurtosisCudaTester, sk_withRFI) ...@@ -71,34 +83,41 @@ TEST_F(SpectralKurtosisCudaTester, sk_withRFI)
{ {
std::vector<int> rfi_window_indices{3, 4, 6, 7, 8, 20, 30, 40, 45, 75}; std::vector<int> rfi_window_indices{3, 4, 6, 7, 8, 20, 30, 40, 45, 75};
std::vector<std::complex<float>> samples; std::vector<std::complex<float>> samples;
test_vector_generation(40000, 400, 1, 30, 10, rfi_window_indices, samples); std::size_t sample_size = 40000;
std::size_t window_size = 400;
bool with_rfi = 1;
float rfi_freq = 30;
float rfi_amp = 10;
test_vector_generation(sample_size, window_size, with_rfi, rfi_freq, rfi_amp, rfi_window_indices, samples);