Select Git revision
test_predictplanexec.cpp
-
Mattia Mancini authoredMattia Mancini authored
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
test_predictplanexec.cpp 2.97 KiB
// Copyright (C) 2025 ASTRON (Netherlands Institute for Radio Astronomy)
// SPDX-License-Identifier: Apache2.0
#define BOOST_TEST_MODULE PREDICT_PLAN_EXEC_TEST
#include <PredictPlanExec.h>
#include <boost/test/unit_test.hpp>
#include <test/Common.h>
BOOST_AUTO_TEST_SUITE(PredictPlanExecTestSuite)
BOOST_AUTO_TEST_CASE(test_PredictPlanExec) { BOOST_CHECK(true); }
BOOST_AUTO_TEST_CASE(compute_smear_terms) {
static constexpr size_t test_n_stations = 4;
static constexpr size_t test_n_channels = 2;
static constexpr size_t test_n_sources = 10;
const Direction test_reference_point{0.5, 0.1};
const Direction test_offset_point{test_reference_point.ra + 0.02,
test_reference_point.dec + 0.02};
// Create a SimulationPlanExec object
std::unique_ptr<PredictRun> run =
MakePredictRun(test_reference_point, test_offset_point, test_n_stations,
test_n_channels, false, true);
run->Initialize();
PredictPlan plan;
PointSourceCollection sources;
PredictPlanExec sim_plan_exec(run->plan);
for (size_t s = 0; s < test_n_sources; ++s) {
sources.Add(run->makeSource<PointSource>());
}
// Precompute the station phases and shifts
sim_plan_exec.Precompute(sources);
for (size_t bl_idx = 0; bl_idx < sim_plan_exec.baselines.size(); bl_idx++) {
const auto &baseline = sim_plan_exec.baselines[bl_idx];
double phase_diff = sim_plan_exec.GetStationPhases()[baseline.second] -
sim_plan_exec.GetStationPhases()[baseline.first];
for (size_t f_idx = 0; f_idx < sim_plan_exec.channel_widths.size();
f_idx++) {
double expected = ComputeSmearterm(
phase_diff, sim_plan_exec.channel_widths[f_idx] * 0.5);
BOOST_CHECK_CLOSE(expected, sim_plan_exec.smear_terms(bl_idx, f_idx),
1e-4);
}
}
}
BOOST_AUTO_TEST_CASE(dont_compute_smear_terms) {
static constexpr size_t test_n_stations = 4;
static constexpr size_t test_n_channels = 2;
static constexpr size_t test_n_sources = 10;
const Direction test_reference_point{0.5, 0.1};
const Direction test_offset_point{test_reference_point.ra + 0.02,
test_reference_point.dec + 0.02};
// Create a SimulationPlanExec object
std::unique_ptr<PredictRun> run =
MakePredictRun(test_reference_point, test_offset_point, test_n_stations,
test_n_channels, false, false);
run->Initialize();
PredictPlan plan;
PointSourceCollection sources;
PredictPlanExec sim_plan_exec(run->plan);
for (size_t s = 0; s < test_n_sources; ++s) {
sources.Add(run->makeSource<PointSource>());
}
// Precompute the station phases and shifts
sim_plan_exec.Precompute(sources);
for (size_t bl_idx = 0; bl_idx < sim_plan_exec.baselines.size(); bl_idx++) {
for (size_t f_idx = 0; f_idx < sim_plan_exec.channel_widths.size();
f_idx++) {
BOOST_CHECK_CLOSE(1.0, sim_plan_exec.smear_terms(bl_idx, f_idx), 1e-4);
}
}
}
BOOST_AUTO_TEST_SUITE_END()