Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
MPIfR-BDG
psrdada_cpp
Commits
fc470a17
Commit
fc470a17
authored
Oct 07, 2020
by
sakthipriyas
Browse files
restructured SKRfiReplacement class
parent
4defbf2b
Changes
2
Hide whitespace changes
Inline
Side-by-side
psrdada_cpp/effelsberg/edd/SKRfiReplacementCuda.cuh
View file @
fc470a17
...
...
@@ -31,9 +31,9 @@ public:
~
SKRfiReplacementCuda
();
/**
* @brief Replaces data
in rfi_windows with replacement
data
(
generated using statistics of data from clean_windows
)
.
* @brief Replaces
RFI
data
with
data generated using statistics of data from
chosen number of
clean_windows.
*
* @param(in) rfi_status rfi_status of input data
* @param(in) rfi_status rfi_status of input data
stream
* @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.
*/
...
...
@@ -43,32 +43,11 @@ public:
private:
/**
* @brief Initializes data members of the class
*/
void
init
();
/**
* @brief Gets indices of clean windows, _clean_window_indices
*/
void
get_clean_window_indices
();
/**
* @brief Gets indices of RFI windows, _rfi_window_indices
*/
void
get_rfi_window_indices
();
/**
* @brief Computes statistics of clean (rfi free) data.
*
*/
void
compute_clean_data_statistics
();
/**
* @brief Gathers data from DEFAULT_NUM_CLEAN_WINDOW number of clean windows and computes its statistics
* @brief Initializes the states of the class members for the given data to be processed.
*
* @param(in) data
actual data
* @param(in)
data
Data stream that has to be processed.
*/
void
get_clean_data_statistics
(
const
thrust
::
device_vector
<
thrust
::
complex
<
float
>>
&
data
);
void
init
(
const
thrust
::
device_vector
<
thrust
::
complex
<
float
>>
&
data
);
thrust
::
device_vector
<
int
>
_rfi_status
;
std
::
size_t
_window_size
;
...
...
psrdada_cpp/effelsberg/edd/src/SKRfiReplacementCuda.cu
View file @
fc470a17
...
...
@@ -39,19 +39,13 @@ SKRfiReplacementCuda::~SKRfiReplacementCuda()
BOOST_LOG_TRIVIAL
(
info
)
<<
"Destroying SKRfiReplacementCuda instance..
\n
"
;
}
void
SKRfiReplacementCuda
::
init
()
void
SKRfiReplacementCuda
::
init
(
const
thrust
::
device_vector
<
thrust
::
complex
<
float
>>
&
data
)
{
BOOST_LOG_TRIVIAL
(
info
)
<<
"initializing data_members of SKRfiReplacementCuda class..
\n
"
;
BOOST_LOG_TRIVIAL
(
info
)
<<
"initializing the states of SKRfiReplacementCuda"
<<
" class members for the data to be processed..
\n
"
;
_nwindows
=
_rfi_status
.
size
();
_rfi_window_indices
.
reserve
(
_nwindows
);
get_rfi_window_indices
();
_clean_window_indices
.
reserve
(
_nwindows
);
get_clean_window_indices
();
}
void
SKRfiReplacementCuda
::
get_rfi_window_indices
()
{
nvtxRangePushA
(
"get_rfi_window_indices"
);
//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
);
thrust
::
copy_if
(
thrust
::
make_counting_iterator
<
int
>
(
0
),
...
...
@@ -59,58 +53,42 @@ void SKRfiReplacementCuda::get_rfi_window_indices()
_rfi_status
.
begin
(),
_rfi_window_indices
.
begin
(),
thrust
::
placeholders
::
_1
==
1
);
nvtxRangePop
();
}
void
SKRfiReplacementCuda
::
get_clean_window_indices
()
{
nvtxRangePushA
(
"get_clean_window_indices"
);
//get_clean_window_indices();
BOOST_LOG_TRIVIAL
(
debug
)
<<
"getting clean window indices..
\n
"
;
_nclean_windows
=
thrust
::
count
(
_rfi_status
.
begin
(),
_rfi_status
.
end
(),
0
);
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
);
}
_clean_window_indices
.
resize
(
_nclean_windows
);
thrust
::
copy_if
(
thrust
::
make_counting_iterator
<
int
>
(
0
),
thrust
::
make_counting_iterator
<
int
>
(
_nwindows
),
_rfi_status
.
begin
(),
_clean_window_indices
.
begin
(),
thrust
::
placeholders
::
_1
==
0
);
nvtxRangePop
();
}
void
SKRfiReplacementCuda
::
get_clean_data_statistics
(
const
thrust
::
device_vector
<
thrust
::
complex
<
float
>>
&
data
)
{
nvtxRangePushA
(
"get_clean_data_statistics"
);
_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_index
=
_clean_window_indices
[
ii
];
std
::
size_t
ibegin
=
window_index
*
_window_size
;
std
::
size_t
iend
=
ibegin
+
_window_size
-
1
;
std
::
size_t
jj
=
ii
*
_window_size
;
thrust
::
copy
((
data
.
begin
()
+
ibegin
),
(
data
.
begin
()
+
iend
),
(
_clean_data
.
begin
()
+
jj
));
BOOST_LOG_TRIVIAL
(
debug
)
<<
"clean_win_index = "
<<
window_index
<<
" ibegin = "
<<
ibegin
<<
" iend = "
<<
iend
;
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
;
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_index
=
_clean_window_indices
[
ii
];
std
::
size_t
ibegin
=
window_index
*
_window_size
;
std
::
size_t
iend
=
ibegin
+
_window_size
-
1
;
std
::
size_t
jj
=
ii
*
_window_size
;
thrust
::
copy
((
data
.
begin
()
+
ibegin
),
(
data
.
begin
()
+
iend
),
(
_clean_data
.
begin
()
+
jj
));
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.
//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.0
f
,
0.0
f
))).
real
()
/
length
;
_ref_sd
=
std
::
sqrt
(
thrust
::
transform_reduce
(
_clean_data
.
begin
(),
_clean_data
.
end
(),
mean_subtraction_square
(
_ref_mean
),
0.0
f
,
thrust
::
plus
<
float
>
())
/
length
);
BOOST_LOG_TRIVIAL
(
debug
)
<<
"DataStatistics mean = "
<<
_ref_mean
<<
" sd = "
<<
_ref_sd
;
}
nvtxRangePop
();
compute_clean_data_statistics
();
}
void
SKRfiReplacementCuda
::
compute_clean_data_statistics
()
{
nvtxRangePushA
(
"compute_clean_data_statistics"
);
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.0
f
,
0.0
f
))).
real
()
/
length
;
_ref_sd
=
std
::
sqrt
(
thrust
::
transform_reduce
(
_clean_data
.
begin
(),
_clean_data
.
end
(),
mean_subtraction_square
(
_ref_mean
),
0.0
f
,
thrust
::
plus
<
float
>
())
/
length
);
nvtxRangePop
();
BOOST_LOG_TRIVIAL
(
debug
)
<<
"DataStatistics mean = "
<<
_ref_mean
<<
" sd = "
<<
_ref_sd
;
}
void
SKRfiReplacementCuda
::
replace_rfi_data
(
const
thrust
::
device_vector
<
int
>
&
rfi_status
,
...
...
@@ -122,10 +100,9 @@ void SKRfiReplacementCuda::replace_rfi_data(const thrust::device_vector<int> &rf
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
init
();
init
(
data
);
//RFI present and not in all windows
if
(
_nclean_windows
<
_nwindows
){
get_clean_data_statistics
(
data
);
//Replacing RFI
thrust
::
counting_iterator
<
unsigned
int
>
sequence_index_begin
(
0
);
nvtxRangePushA
(
"replace_rfi_datai_loop"
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment