24 #include "cheetah/sps_clustering/test/SpsClusteringTest.h" 25 #include "cheetah/sps_clustering/SpsClustering.h" 26 #include "cheetah/sps_clustering/Fof.h" 30 namespace sps_clustering {
34 SpsClusteringTest::SpsClusteringTest()
39 SpsClusteringTest::~SpsClusteringTest()
43 void SpsClusteringTest::SetUp()
47 void SpsClusteringTest::TearDown()
51 TEST_F(SpsClusteringTest, test_sps_clustering_no_tf_blocks)
55 std::shared_ptr<data::SpCcl<uint8_t>> cand_list = std::make_shared<data::SpCcl<uint8_t>>();
57 ASSERT_EQ(cand_list->tf_blocks().size(),std::size_t(0));
60 typename Config::Dm dm(12.0 * pss::astrotypes::units::parsecs_per_cube_cm);
62 typename Config::MsecTimeType width(0.001 * boost::units::si::seconds);
64 data::SpCcl<uint8_t>::SpCandidateType::MsecTimeType tstart(2.0 * boost::units::si::seconds);
68 for (std::size_t idx=0; idx<10; ++idx)
70 data::SpCcl<uint8_t>::SpCandidateType candidate(dm, tstart, width, sigma, idx);
71 cand_list->push_back(candidate);
72 tstart += data::SpCcl<uint8_t>::SpCandidateType::MsecTimeType(0.05*boost::units::si::seconds);
73 dm +=
typename Config::Dm(1.0 * pss::astrotypes::units::parsecs_per_cube_cm);
78 typename Config::Dm dm_tolerance(2.0 * pss::astrotypes::units::parsecs_per_cube_cm);
79 typename Config::MsecTimeType width_tolerance(0.01 * boost::units::si::seconds);
80 typename Config::MsecTimeType time_tolerance(0.01 * boost::units::si::seconds);
81 config.dm_tolerance(dm_tolerance);
82 config.pulse_width_tolerance(width_tolerance);
83 config.time_tolerance(time_tolerance);
84 config.linking_length(1.732);
86 SpsClustering merger(config);
87 ASSERT_NO_THROW(merger(cand_list));
90 ASSERT_EQ(cand_list->size(),10U);
93 TEST_F(SpsClusteringTest, test_sps_clustering_clustering_one_candidate)
97 data::TimeFrequency<Cpu, uint8_t> tf1(data::DimensionSize<data::Time>(100),data::DimensionSize<data::Frequency>(16));
99 tf1.sample_interval(data::TimeFrequency<Cpu, uint8_t>::TimeType(1 * boost::units::si::milli * boost::units::si::seconds));
101 data::SpCcl<uint8_t>::BlocksType tf_v;
103 std::fill(tf1.begin(),tf1.end(),0);
105 tf_v.push_back(std::make_shared<data::TimeFrequency<Cpu, uint8_t>>(tf1));
107 std::shared_ptr<data::SpCcl<uint8_t>> cand_list = std::make_shared<data::SpCcl<uint8_t>>(tf_v);
110 typename Config::Dm dm(12.0 * pss::astrotypes::units::parsecs_per_cube_cm);
112 typename Config::MsecTimeType width(0.001 * boost::units::si::seconds);
114 data::SpCcl<uint8_t>::SpCandidateType::MsecTimeType tstart(2.0 * boost::units::si::seconds);
118 for (std::size_t idx=0; idx<5; ++idx)
120 data::SpCcl<uint8_t>::SpCandidateType candidate(dm, tstart, width, sigma, idx);
121 cand_list->push_back(candidate);
122 tstart += data::SpCcl<uint8_t>::SpCandidateType::MsecTimeType(0.001*boost::units::si::seconds);
123 dm += 0.5 * pss::astrotypes::units::parsecs_per_cube_cm;
129 typename Config::Dm dm_tolerance(5.0 * pss::astrotypes::units::parsecs_per_cube_cm);
130 typename Config::MsecTimeType width_tolerance(0.01 * boost::units::si::seconds);
131 typename Config::MsecTimeType time_tolerance(1.0 * boost::units::si::seconds);
132 config.dm_tolerance(dm_tolerance);
133 config.pulse_width_tolerance(width_tolerance);
134 config.time_tolerance(time_tolerance);
135 config.linking_length(1);
137 SpsClustering merger(config);
138 auto grouped_cands = merger(cand_list);
141 ASSERT_EQ(grouped_cands->size(), 1U);
144 TEST_F(SpsClusteringTest, test_sps_clustering_multiple_candidates_within_limits)
147 data::SpCcl<uint8_t>::BlocksType tf_v;
148 data::TimeFrequency<Cpu, uint8_t> tf1(data::DimensionSize<data::Time>(100), data::DimensionSize<data::Frequency>(16));
149 tf1.sample_interval(data::TimeFrequency<Cpu, uint8_t>::TimeType(1 * boost::units::si::milli * boost::units::si::seconds));
150 tf_v.push_back(std::make_shared<data::TimeFrequency<Cpu, uint8_t>>(tf1));
154 std::shared_ptr<data::SpCcl<uint8_t>> cand_list = std::make_shared<data::SpCcl<uint8_t>>(tf_v);
157 typename Config::Dm dm(5000.0 * pss::astrotypes::units::parsecs_per_cube_cm);
159 typename Config::MsecTimeType width(0.256 * boost::units::si::seconds);
161 data::SpCcl<uint8_t>::SpCandidateType::MsecTimeType tstart(2.0 * boost::units::si::seconds);
165 for (std::size_t idx=0; idx<10; ++idx)
167 for (std::size_t ind=0; ind < 50; ++ind)
169 data::SpCcl<uint8_t>::SpCandidateType candidate(dm, tstart, width, sigma, idx);
170 cand_list->push_back(candidate);
171 tstart += data::SpCcl<uint8_t>::SpCandidateType::MsecTimeType(0.002*boost::units::si::seconds);
172 width += data::SpCcl<uint8_t>::SpCandidateType::MsecTimeType(0.002*boost::units::si::seconds);
173 dm += 10.0 * pss::astrotypes::units::parsecs_per_cube_cm;
176 tstart += data::SpCcl<uint8_t>::SpCandidateType::MsecTimeType(0.1*boost::units::si::seconds);
182 typename Config::Dm dm_tolerance(20.0 * pss::astrotypes::units::parsecs_per_cube_cm);
183 typename Config::MsecTimeType width_tolerance(0.002 * boost::units::si::seconds);
184 typename Config::MsecTimeType time_tolerance(0.1 * boost::units::si::seconds);
185 config.dm_tolerance(dm_tolerance);
186 config.pulse_width_tolerance(width_tolerance);
187 config.time_tolerance(time_tolerance);
188 config.linking_length(1.5);
190 SpsClustering merger(config);
191 auto grouped_cands = merger(cand_list);
194 ASSERT_EQ(grouped_cands->size(),1U);
197 TEST_F(SpsClusteringTest, test_sps_clustering_multiple_candidates_beyond_limits)
200 data::SpCcl<uint8_t>::BlocksType tf_v;
201 data::TimeFrequency<Cpu, uint8_t> tf1(data::DimensionSize<data::Time>(100), data::DimensionSize<data::Frequency>(16));
202 tf1.sample_interval(data::TimeFrequency<Cpu, uint8_t>::TimeType(1 * boost::units::si::milli * boost::units::si::seconds));
203 tf_v.push_back(std::make_shared<data::TimeFrequency<Cpu, uint8_t>>(tf1));
207 std::shared_ptr<data::SpCcl<uint8_t>> cand_list = std::make_shared<data::SpCcl<uint8_t>>(tf_v);
210 typename Config::Dm dm(5000.0 * pss::astrotypes::units::parsecs_per_cube_cm);
212 typename Config::MsecTimeType width(0.256 * boost::units::si::seconds);
214 data::SpCcl<uint8_t>::SpCandidateType::MsecTimeType tstart(2.0 * boost::units::si::seconds);
218 for (std::size_t idx=0; idx<10; ++idx)
220 for (std::size_t ind=0; ind < 50; ++ind)
222 data::SpCcl<uint8_t>::SpCandidateType candidate(dm, tstart, width, sigma, idx);
223 cand_list->push_back(candidate);
224 tstart += data::SpCcl<uint8_t>::SpCandidateType::MsecTimeType(0.002*boost::units::si::seconds);
225 width += data::SpCcl<uint8_t>::SpCandidateType::MsecTimeType(0.002*boost::units::si::seconds);
226 dm += 10.0 * pss::astrotypes::units::parsecs_per_cube_cm;
229 tstart += data::SpCcl<uint8_t>::SpCandidateType::MsecTimeType(0.5*boost::units::si::seconds);
235 typename Config::Dm dm_tolerance(20.0 * pss::astrotypes::units::parsecs_per_cube_cm);
236 typename Config::MsecTimeType width_tolerance(0.002 * boost::units::si::seconds);
237 typename Config::MsecTimeType time_tolerance(0.1 * boost::units::si::seconds);
238 config.dm_tolerance(dm_tolerance);
239 config.pulse_width_tolerance(width_tolerance);
240 config.time_tolerance(time_tolerance);
241 config.linking_length(1.5);
243 SpsClustering merger(config);
244 auto grouped_cands = merger(cand_list);
247 ASSERT_EQ(grouped_cands->size(),10U);
Some limits and constants for FLDO.