XtalOptimizer: Accept std::vector<std::vector<SpotToSave>> for spots input, to distinguish spots between different images
This commit is contained in:
@@ -11,6 +11,7 @@
|
||||
RotationIndexer::RotationIndexer(const DiffractionExperiment &x, IndexerThreadPool &indexer)
|
||||
: experiment(x),
|
||||
index_ice_rings(x.GetIndexingSettings().GetIndexIceRings()),
|
||||
v_(experiment.GetImageNum()),
|
||||
axis_(x.GetGoniometer()),
|
||||
geom_(x.GetDiffractionGeometry()),
|
||||
updated_geom_(geom_),
|
||||
@@ -40,39 +41,8 @@ RotationIndexer::RotationIndexer(const DiffractionExperiment &x, IndexerThreadPo
|
||||
|
||||
void RotationIndexer::TryIndex() {
|
||||
// Index
|
||||
std::vector<SpotToSave> v_sel;
|
||||
std::vector<Coord> coords_sel;
|
||||
|
||||
if (coords_.size() > max_spots) {
|
||||
|
||||
// Indices into v_ / coords_
|
||||
std::vector<std::size_t> idx(coords_.size());
|
||||
std::iota(idx.begin(), idx.end(), std::size_t{0});
|
||||
|
||||
// Sort indices by descending intensity
|
||||
std::partial_sort(
|
||||
idx.begin(),
|
||||
idx.begin() + max_spots,
|
||||
idx.end(),
|
||||
[this](std::size_t a, std::size_t b) {
|
||||
return v_[a].intensity > v_[b].intensity;
|
||||
}
|
||||
);
|
||||
|
||||
v_sel.reserve(max_spots);
|
||||
coords_sel.reserve(max_spots);
|
||||
|
||||
for (std::size_t i = 0; i < max_spots; ++i) {
|
||||
const std::size_t k = idx[i];
|
||||
v_sel.emplace_back(v_[k]);
|
||||
coords_sel.emplace_back(coords_[k]);
|
||||
}
|
||||
} else {
|
||||
v_sel = v_;
|
||||
coords_sel = coords_;
|
||||
}
|
||||
|
||||
auto indexer_result = indexer_.Run(experiment, coords_sel);
|
||||
auto indexer_result = indexer_.Run(experiment, coords_);
|
||||
if (!indexer_result.lattice.empty() && indexer_result.lattice[0].CalcVolume() > 1.0) {
|
||||
auto sg = experiment.GetGemmiSpaceGroup();
|
||||
if (sg) {
|
||||
@@ -108,7 +78,7 @@ void RotationIndexer::TryIndex() {
|
||||
if (data.crystal_system == gemmi::CrystalSystem::Monoclinic)
|
||||
data.latt.ReorderMonoclinic();
|
||||
|
||||
if (XtalOptimizer(data, v_sel)) {
|
||||
if (XtalOptimizer(data, v_)) {
|
||||
indexed_lattice = data.latt;
|
||||
updated_geom_ = data.geom;
|
||||
axis_ = data.axis;
|
||||
@@ -135,12 +105,12 @@ std::optional<RotationIndexerResult> RotationIndexer::ProcessImage(int64_t image
|
||||
const auto rot = axis_->GetTransformationAngle(angle_deg);
|
||||
|
||||
if (!indexed_lattice && image >= last_accumulated_image + image_stride) {
|
||||
v_.reserve(v_.size() + spots.size());
|
||||
v_[image].reserve(spots.size());
|
||||
coords_.reserve(coords_.size() + spots.size());
|
||||
|
||||
for (const auto &s: spots) {
|
||||
if (index_ice_rings || !s.ice_ring) {
|
||||
v_.emplace_back(s);
|
||||
v_[image].emplace_back(s);
|
||||
coords_.emplace_back(rot * s.ReciprocalCoord(geom_));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user