Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
psrdada_cpp
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
MPIfR-BDG
psrdada_cpp
Commits
c2bfdae2
Commit
c2bfdae2
authored
5 years ago
by
spriyas
Browse files
Options
Downloads
Patches
Plain Diff
updated SK test cases
parent
a9374f14
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
psrdada_cpp/effelsberg/edd/test/SpectralKurtosisTester.hpp
+16
-2
16 additions, 2 deletions
psrdada_cpp/effelsberg/edd/test/SpectralKurtosisTester.hpp
psrdada_cpp/effelsberg/edd/test/src/SpectralKurtosisTester.cpp
+71
-36
71 additions, 36 deletions
...da_cpp/effelsberg/edd/test/src/SpectralKurtosisTester.cpp
with
87 additions
and
38 deletions
psrdada_cpp/effelsberg/edd/test/SpectralKurtosisTester.hpp
+
16
−
2
View file @
c2bfdae2
#include
"psrdada_cpp/common.hpp"
#include
"psrdada_cpp/common.hpp"
#include
"psrdada_cpp/effelsberg/edd/
test/SKTestVector
.hpp"
#include
"psrdada_cpp/effelsberg/edd/
SKRfiReplacement
.hpp"
#include
"psrdada_cpp/effelsberg/edd/SpectralKurtosis.hpp"
#include
"psrdada_cpp/effelsberg/edd/SpectralKurtosis.hpp"
#include
"psrdada_cpp/effelsberg/edd/test/SKTestVector.hpp"
#include
<gtest/gtest.h>
#include
<gtest/gtest.h>
namespace
psrdada_cpp
{
namespace
psrdada_cpp
{
...
@@ -13,7 +14,20 @@ class SpectralKurtosisTester: public ::testing::Test
...
@@ -13,7 +14,20 @@ class SpectralKurtosisTester: public ::testing::Test
public:
public:
SpectralKurtosisTester
();
SpectralKurtosisTester
();
~
SpectralKurtosisTester
();
~
SpectralKurtosisTester
();
/**
* @brief creates SKTestVector class instance and generates test vector
*
*/
void
test_vector_generation
(
std
::
size_t
sample_size
,
std
::
size_t
window_size
,
bool
with_rfi
,
float
rfi_freq
,
float
rfi_amp
,
const
std
::
vector
<
int
>
&
rfi_window_indices
,
std
::
vector
<
std
::
complex
<
float
>>
&
samples
);
/**
* @brief creates SpectralKurtosis class instance and computes spectral kurtosis
*
*/
void
sk_computation
(
std
::
size_t
nch
,
std
::
size_t
window_size
,
const
std
::
vector
<
std
::
complex
<
float
>>
&
samples
,
RFIStatistics
&
stat
);
protected:
protected:
void
SetUp
()
override
;
void
SetUp
()
override
;
void
TearDown
()
override
;
void
TearDown
()
override
;
...
...
This diff is collapsed.
Click to expand it.
psrdada_cpp/effelsberg/edd/test/src/SpectralKurtosisTester.cpp
+
71
−
36
View file @
c2bfdae2
...
@@ -22,66 +22,101 @@ void SpectralKurtosisTester::TearDown()
...
@@ -22,66 +22,101 @@ void SpectralKurtosisTester::TearDown()
{
{
}
}
TEST_F
(
SpectralKurtosisTester
,
sk_window_size_chk
)
void
SpectralKurtosisTester
::
test_vector_generation
(
std
::
size_t
sample_size
,
std
::
size_t
window_size
,
bool
with_rfi
,
float
rfi_freq
,
float
rfi_amp
,
const
std
::
vector
<
int
>
&
rfi_window_indices
,
std
::
vector
<
std
::
complex
<
float
>>
&
samples
)
{
{
bool
with_rfi
=
0
;
SKTestVector
tv
(
sample_size
,
window_size
,
with_rfi
,
rfi_freq
,
rfi_amp
);
std
::
size_t
sample_size
=
2000
;
tv
.
generate_test_vector
(
rfi_window_indices
,
samples
);
std
::
size_t
window_size
=
150
;
}
SKTestVector
tv
(
sample_size
,
window_size
,
with_rfi
);
std
::
vector
<
int
>
rfi_ind
{};
void
SpectralKurtosisTester
::
sk_computation
(
std
::
size_t
nch
,
std
::
size_t
window_size
,
const
std
::
vector
<
std
::
complex
<
float
>>
&
samples
,
RFIStatistics
&
stat
)
{
float
sk_min
=
0.8
;
float
sk_max
=
1.2
;
SpectralKurtosis
sk
(
nch
,
window_size
,
sk_min
,
sk_max
);
sk
.
compute_sk
(
samples
,
stat
);
}
TEST_F
(
SpectralKurtosisTester
,
sk_window_size_check
)
{
std
::
vector
<
int
>
rfi_window_indices
{};
std
::
vector
<
std
::
complex
<
float
>>
samples
;
std
::
vector
<
std
::
complex
<
float
>>
samples
;
tv
.
generate_test_vector
(
rfi_ind
,
samples
);
test_vector_generation
(
4000
,
150
,
0
,
0
,
0
,
rfi_window_indices
,
samples
);
std
::
size_t
nch
=
1
;
SpectralKurtosis
sk
(
nch
,
window_size
);
RFIStatistics
stat
;
RFIStatistics
stat
;
sk
.
compute_sk
(
samples
,
stat
);
try
{
sk_computation
(
1
,
150
,
samples
,
stat
);
FAIL
()
<<
"Expected std::runtime_error
\n
"
;
}
catch
(
std
::
runtime_error
const
&
err
){
EXPECT_EQ
(
err
.
what
(),
std
::
string
(
"sample size is not a multiple of window_size. Give different window size
\n
"
));
}
}
}
TEST_F
(
SpectralKurtosisTester
,
sk_withoutRFI
)
TEST_F
(
SpectralKurtosisTester
,
sk_withoutRFI
)
{
{
bool
with_rfi
=
0
;
std
::
vector
<
int
>
rfi_window_indices
{};
std
::
size_t
sample_size
=
20000
;
std
::
size_t
window_size
=
200
;
SKTestVector
tv
(
sample_size
,
window_size
,
with_rfi
);
std
::
vector
<
int
>
rfi_ind
{};
std
::
vector
<
std
::
complex
<
float
>>
samples
;
std
::
vector
<
std
::
complex
<
float
>>
samples
;
tv
.
generate_test_vector
(
rfi_ind
,
samples
);
//generate test vector
test_vector_generation
(
40000
,
400
,
0
,
0
,
0
,
rfi_window_indices
,
samples
);
std
::
size_t
nch
=
1
;
float
sk_min
=
0.8
;
float
sk_max
=
1.2
;
SpectralKurtosis
sk
(
nch
,
window_size
,
sk_min
,
sk_max
);
RFIStatistics
stat
;
RFIStatistics
stat
;
sk
.
compute_sk
(
samples
,
stat
);
//computing SK
sk_computation
(
1
,
400
,
samples
,
stat
);
float
expected_rfi_fraction
=
0
;
EXPECT_EQ
(
expected_rfi_fraction
,
stat
.
rfi_fraction
);
}
}
TEST_F
(
SpectralKurtosisTester
,
sk_withRFI
)
TEST_F
(
SpectralKurtosisTester
,
sk_withRFI
)
{
{
std
::
vector
<
int
>
rfi_window_indices
{
3
,
4
,
6
,
7
,
8
,
20
,
30
,
40
};
std
::
vector
<
std
::
complex
<
float
>>
samples
;
test_vector_generation
(
40000
,
400
,
1
,
10
,
1
,
rfi_window_indices
,
samples
);
RFIStatistics
stat
;
sk_computation
(
1
,
400
,
samples
,
stat
);
float
expected_rfi_fraction
=
rfi_window_indices
.
size
()
/
float
(
40000
/
400
);
EXPECT_EQ
(
expected_rfi_fraction
,
stat
.
rfi_fraction
);
}
TEST_F
(
SpectralKurtosisTester
,
sk_replacement
)
{
//Test vector
bool
with_rfi
=
1
;
bool
with_rfi
=
1
;
std
::
size_t
sample_size
=
40000
;
std
::
size_t
sample_size
=
40000
;
std
::
size_t
window_size
=
400
;
std
::
size_t
window_size
=
400
;
SKTestVector
tv
(
sample_size
,
window_size
,
with_rfi
);
float
rfi_freq
=
10
;
std
::
vector
<
int
>
rfi_ind
{
1
,
2
,
5
,
7
,
9
,
20
,
30
,
40
};
float
rfi_amp
=
1
;
SKTestVector
tv
(
sample_size
,
window_size
,
with_rfi
,
rfi_freq
,
rfi_amp
);
std
::
vector
<
int
>
rfi_window_indices
{
1
,
2
,
3
,
4
,
6
,
7
,
8
,
9
,
20
,
30
,
40
};
std
::
vector
<
std
::
complex
<
float
>>
samples
;
std
::
vector
<
std
::
complex
<
float
>>
samples
;
tv
.
generate_test_vector
(
rfi_ind
,
samples
);
//generating test vector
tv
.
generate_test_vector
(
rfi_window_indices
,
samples
);
//generating test vector
//SK
std
::
size_t
nch
=
1
;
std
::
size_t
nch
=
1
;
float
sk_min
=
0.8
;
float
sk_min
=
0.8
;
float
sk_max
=
1.2
;
float
sk_max
=
1.2
;
SpectralKurtosis
sk
(
nch
,
window_size
,
sk_min
,
sk_max
);
RFIStatistics
stat
;
RFIStatistics
stat
;
SpectralKurtosis
sk
(
nch
,
window_size
,
sk_min
,
sk_max
);
sk
.
compute_sk
(
samples
,
stat
);
//computing SK
sk
.
compute_sk
(
samples
,
stat
);
//computing SK
BOOST_LOG_TRIVIAL
(
info
)
<<
"RFI status: "
;
float
expected_rfi_fraction
=
rfi_window_indices
.
size
()
/
float
(
40000
/
400
);
for
(
int
ii
=
0
;
ii
<
10
;
ii
++
){
EXPECT_EQ
(
expected_rfi_fraction
,
stat
.
rfi_fraction
);
printf
(
"RFI[%d] = %d
\n
"
,
ii
,
stat
.
rfi_status
[
ii
]);
}
//RFI replacement
BOOST_LOG_TRIVIAL
(
info
)
<<
"RFI replacement
\n
"
;
SKRfiReplacement
rr
(
samples
,
stat
.
rfi_status
);
rr
.
replace_rfi_data
(
samples
);
//SK computation after RFI replacement
BOOST_LOG_TRIVIAL
(
info
)
<<
"computing SK after RFI replacement..
\n
"
;
sk
.
compute_sk
(
samples
,
stat
);
//computing SK
float
expected_val_after_rfi_replacement
=
0
;
EXPECT_EQ
(
expected_val_after_rfi_replacement
,
stat
.
rfi_fraction
);
}
}
}
//test
}
//test
}
//edd
}
//edd
}
//effelsberg
}
//effelsberg
}
//psrdada_cpp
}
//psrdada_cpp
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment