Files
Jungfraujoch/tests/SpotUtilsTest.cpp
2025-10-20 20:43:44 +02:00

30 lines
1.3 KiB
C++

// SPDX-FileCopyrightText: 2024 Filip Leonarski, Paul Scherrer Institute <filip.leonarski@psi.ch>
// SPDX-License-Identifier: GPL-3.0-only
#include <catch2/catch_all.hpp>
#include "../image_analysis/spot_finding/SpotUtils.h"
TEST_CASE("FilterSpuriousHighResolutionSpots") {
std::vector<SpotToSave> spots;
spots.push_back(SpotToSave{.x = 1, .y = 2, .intensity = 3, .d_A = 18.0, .indexed = false});
spots.push_back(SpotToSave{.x = 1, .y = 2, .intensity = 3, .d_A = 20.0, .indexed = false});
spots.push_back(SpotToSave{.x = 1, .y = 2, .intensity = 3, .d_A = 30.0, .indexed = false});
spots.push_back(SpotToSave{.x = 1, .y = 2, .intensity = 3, .d_A = 6.0, .indexed = false});
spots.push_back(SpotToSave{.x = 1, .y = 2, .intensity = 3, .d_A = 2.0, .indexed = false});
spots.push_back(SpotToSave{.x = 1, .y = 2, .intensity = 3, .d_A = 1.9, .indexed = false});
spots.push_back(SpotToSave{.x = 1, .y = 2, .intensity = 3, .d_A = 1.3, .indexed = false});
FilterSpuriousHighResolutionSpots(spots, 1.57); // roughly 0.25 in 1/d
REQUIRE(spots.size() == 4);
// Spots are sorted by resolution
CHECK(spots[0].d_A == Catch::Approx(30.0));
CHECK(spots[1].d_A == Catch::Approx(20.0));
CHECK(spots[2].d_A == Catch::Approx(18.0));
CHECK(spots[3].d_A == Catch::Approx(6.0));
}