RotationIndexer: Only one indexing try after enough rotation
Some checks failed
Build Packages / Generate python client (push) Has been cancelled
Build Packages / build:rpm (ubuntu2404) (push) Has been cancelled
Build Packages / Build documentation (push) Has been cancelled
Build Packages / Unit tests (push) Has been cancelled
Build Packages / Create release (push) Has been cancelled
Build Packages / build:rpm (rocky8_sls9) (push) Has started running
Build Packages / build:rpm (rocky9_nocuda) (push) Has been cancelled
Build Packages / build:rpm (rocky8_nocuda) (push) Has been cancelled
Build Packages / build:rpm (rocky8) (push) Has been cancelled
Build Packages / build:rpm (ubuntu2204_nocuda) (push) Has been cancelled
Build Packages / build:rpm (ubuntu2404_nocuda) (push) Has been cancelled
Build Packages / build:rpm (ubuntu2204) (push) Has been cancelled
Build Packages / build:rpm (rocky9) (push) Has been cancelled

This commit is contained in:
2025-12-06 11:28:48 +01:00
parent c67e5ecac7
commit 3b257ca572
4 changed files with 12 additions and 24 deletions

View File

@@ -158,6 +158,6 @@ void IndexAndRefine::ProcessImage(DataMessage &msg,
std::optional<RotationIndexerResult> IndexAndRefine::Finalize() {
if (rotation_indexer)
return rotation_indexer->Finalize();
return rotation_indexer->GetLattice();
return {};
}

View File

@@ -41,6 +41,8 @@ void RotationIndexer::SetLattice(const CrystalLattice &lattice) {
}
void RotationIndexer::TryIndex() {
indexing_tried = true;
// Index
std::vector<SpotToSave> v_sel;
std::vector<Coord> coords_sel;
@@ -57,7 +59,6 @@ void RotationIndexer::TryIndex() {
idx.begin() + max_spots,
idx.end(),
[this](std::size_t a, std::size_t b) {
// Replace `.intensity` with the actual SpotToSave intensity member
return v_[a].intensity > v_[b].intensity;
}
);
@@ -111,7 +112,7 @@ std::optional<RotationIndexerResult> RotationIndexer::ProcessImage(int64_t image
const auto rot = axis_->GetTransformation(image);
if (!indexed_lattice && image >= last_accumulated_image + image_stride) {
if (!indexing_tried && image >= last_accumulated_image + image_stride) {
v_.reserve(v_.size() + spots.size());
coords_.reserve(coords_.size() + spots.size());
@@ -125,29 +126,16 @@ std::optional<RotationIndexerResult> RotationIndexer::ProcessImage(int64_t image
accumulated_images++;
last_accumulated_image = image;
if (!indexed_lattice && accumulated_images >= min_images_for_indexing && image >= first_image_to_try_indexing) {
if (accumulated_images >= min_images_for_indexing && image >= first_image_to_try_indexing)
TryIndex();
// If fails increase rotation range by a factor of two
if (!indexed_lattice)
first_image_to_try_indexing *= 2;
}
}
if (indexed_lattice) {
return RotationIndexerResult{
.lattice = indexed_lattice->Multiply(rot.transpose()),
.search_result = search_result_,
.geom = updated_geom_
};
}
return {};
return GetLattice();
}
std::optional<RotationIndexerResult> RotationIndexer::Finalize() {
std::optional<RotationIndexerResult> RotationIndexer::GetLattice() {
if (!indexed_lattice)
TryIndex();
if (!indexed_lattice)
return std::nullopt;
return {};
return RotationIndexerResult{
.lattice = indexed_lattice.value(),
.search_result = search_result_,

View File

@@ -28,10 +28,11 @@ class RotationIndexer {
mutable std::mutex m;
const DiffractionExperiment& experiment;
constexpr static int64_t max_spots = 60000;
constexpr static int64_t max_spots = 10000;
constexpr static int64_t min_images_for_indexing = 10;
const bool index_ice_rings;
bool indexing_tried = false;
std::vector<SpotToSave> v_;
std::vector<Coord> coords_;
@@ -50,13 +51,12 @@ class RotationIndexer {
std::optional<CrystalLattice> indexed_lattice;
void TryIndex();
public:
RotationIndexer(const DiffractionExperiment& x, IndexerThreadPool& indexer);
void SetLattice(const CrystalLattice &lattice);
std::optional<RotationIndexerResult> ProcessImage(int64_t image, const std::vector<SpotToSave>& spots);
std::optional<RotationIndexerResult> Finalize();
std::optional<RotationIndexerResult> GetLattice();
};
#endif //JFJOCH_ROTATIONINDEXER_H

View File

@@ -74,7 +74,7 @@ TEST_CASE("RotationIndexer") {
CHECK(cnt == 20);
auto ret = indexer.Finalize();
auto ret = indexer.GetLattice();
REQUIRE(ret.has_value());
auto uc = ret->lattice.GetUnitCell();
auto uc_ref = latt_base.GetUnitCell();