Commit 6118c967 authored by Tobias Winchen's avatar Tobias Winchen
Browse files

Removed unnecessary variables

parent 5746500b
......@@ -43,14 +43,9 @@ public:
private:
thrust::device_vector<int> _rfi_status;
std::size_t _window_size;
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> _clean_window_indices;
thrust::device_vector<thrust::complex <float>> _clean_data;
float _ref_mean, _ref_sd;
};
} //edd
} //effelsberg
......
......@@ -31,12 +31,12 @@ struct generate_replacement_data{
SKRfiReplacementCuda::SKRfiReplacementCuda()
{
BOOST_LOG_TRIVIAL(info) << "Creating new SKRfiReplacementCuda instance..\n";
BOOST_LOG_TRIVIAL(debug) << "Creating new SKRfiReplacementCuda instance..\n";
}
SKRfiReplacementCuda::~SKRfiReplacementCuda()
{
BOOST_LOG_TRIVIAL(info) << "Destroying SKRfiReplacementCuda instance..\n";
BOOST_LOG_TRIVIAL(debug) << "Destroying SKRfiReplacementCuda instance..\n";
}
......@@ -45,40 +45,37 @@ void SKRfiReplacementCuda::replace_rfi_data(const thrust::device_vector<int> &rf
std::size_t clean_windows)
{
nvtxRangePushA("replace_rfi_data");
_rfi_status = rfi_status;
thrust::device_vector<thrust::complex<float>> replacement_data;
//initialize data members of the class
_nclean_windows_stat = clean_windows; //no. of clean windows used for computing statistics
BOOST_LOG_TRIVIAL(info) << "initializing the states of SKRfiReplacementCuda"
<< " class members for the data to be processed..\n";
_nwindows = _rfi_status.size();
//get_rfi_window_indices();
BOOST_LOG_TRIVIAL(debug) << "getting RFI window indices..\n";
_nrfi_windows = thrust::count(_rfi_status.begin(), _rfi_status.end(), 1);
_rfi_window_indices.resize(_nrfi_windows);
_rfi_window_indices.resize(thrust::count(rfi_status.begin(), rfi_status.end(), 1));
thrust::copy_if(thrust::make_counting_iterator<int>(0),
thrust::make_counting_iterator<int>(_nwindows),
_rfi_status.begin(),
thrust::make_counting_iterator<int>(rfi_status.size()),
rfi_status.begin(),
_rfi_window_indices.begin(),
thrust::placeholders::_1 == 1);
//get_clean_window_indices();
BOOST_LOG_TRIVIAL(debug) << "getting clean window indices..\n";
_nclean_windows = thrust::count(_rfi_status.begin(), _rfi_status.end(), 0);
size_t _nclean_windows = thrust::count(rfi_status.begin(), rfi_status.end(), 0);
_clean_window_indices.resize(_nclean_windows);
thrust::copy_if(thrust::make_counting_iterator<int>(0),
thrust::make_counting_iterator<int>(_nwindows),
_rfi_status.begin(),
thrust::make_counting_iterator<int>(rfi_status.size()),
rfi_status.begin(),
_clean_window_indices.begin(),
thrust::placeholders::_1 == 0);
if(_nclean_windows < _nwindows){ //if RFI is present
//Getting clean data statistics of chosen number of clean windows
if (_nclean_windows < _nclean_windows_stat) _nclean_windows_stat = _nclean_windows;
if(_nclean_windows < rfi_status.size()){
//RFI present and not in all windows
if (_nclean_windows < clean_windows) {
clean_windows = _nclean_windows;
}
BOOST_LOG_TRIVIAL(debug) << "collecting clean data from chosen number of clean windows..\n";
_window_size = data.size() / _nwindows;
_clean_data.resize(_nclean_windows_stat * _window_size);
for(std::size_t ii = 0; ii < _nclean_windows_stat; ii++){
std::size_t _window_size = data.size() / rfi_status.size();
_clean_data.resize(clean_windows * _window_size);
for(std::size_t ii = 0; ii < clean_windows; ii++){
std::size_t window_index = _clean_window_indices[ii];
std::size_t ibegin = window_index * _window_size;
std::size_t iend = ibegin + _window_size - 1;
......@@ -87,24 +84,20 @@ void SKRfiReplacementCuda::replace_rfi_data(const thrust::device_vector<int> &rf
BOOST_LOG_TRIVIAL(debug) <<"clean_win_index = " << window_index
<< " ibegin = " << ibegin << " iend = " << iend;
}
//computing clean data statistics
BOOST_LOG_TRIVIAL(debug) << "computing statistics of clean data..\n";
//The distribution of both real and imag have same mean and standard deviation.
//The distribution of both real and imag are expected to ahve same mean and standard deviation.
//Therefore computing _ref_mean, _ref_sd for real distribution only.
std::size_t length = _clean_data.size();
_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),
float _ref_mean = (thrust::reduce(_clean_data.begin(), _clean_data.end(), thrust::complex<float> (0.0f, 0.0f))). real() / length;
float _ref_sd = std::sqrt(thrust::transform_reduce(_clean_data.begin(), _clean_data.end(), mean_subtraction_square(_ref_mean),
0.0f, thrust::plus<float> ()) / length);
BOOST_LOG_TRIVIAL(debug) << "DataStatistics mean = " << _ref_mean
<< " sd = " << _ref_sd;
}
//RFI present and not in all windows
if(_nclean_windows < _nwindows){
//Replacing RFI
thrust::counting_iterator<unsigned int> sequence_index_begin(0);
nvtxRangePushA("replace_rfi_datai_loop");
for(std::size_t ii = 0; ii < _nrfi_windows; ii++){
for(std::size_t ii = 0; ii < _rfi_window_indices.size(); ii++){
std::size_t index = _rfi_window_indices[ii] * _window_size;
thrust::transform(sequence_index_begin, (sequence_index_begin + _window_size),
(data.begin() + index), generate_replacement_data(_ref_mean, _ref_sd));
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment