aboutsummaryrefslogtreecommitdiff
path: root/libcrystfel
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2024-01-12 13:59:41 +0100
committerThomas White <taw@physics.org>2024-01-12 15:22:50 +0100
commitc6448075aef8607ac370bb69782b5b18f82ef120 (patch)
tree2c9ca1aed90fda8faeac5d13403f4222dd86a0b0 /libcrystfel
parent9918b000068b7daceb0c62921a47922f88b17161 (diff)
indexamajig: Implement --max-mille-level
Diffstat (limited to 'libcrystfel')
-rw-r--r--libcrystfel/src/crystfel-mille.c26
-rw-r--r--libcrystfel/src/crystfel-mille.h2
-rw-r--r--libcrystfel/src/index.c14
-rw-r--r--libcrystfel/src/index.h3
-rw-r--r--libcrystfel/src/predict-refine.c6
-rw-r--r--libcrystfel/src/predict-refine.h3
6 files changed, 40 insertions, 14 deletions
diff --git a/libcrystfel/src/crystfel-mille.c b/libcrystfel/src/crystfel-mille.c
index 0fca6f30..8eacaa60 100644
--- a/libcrystfel/src/crystfel-mille.c
+++ b/libcrystfel/src/crystfel-mille.c
@@ -145,11 +145,28 @@ static void mille_add_measurement(Mille *m,
}
+/* group must not be NULL
+ * count_depth() = 0 means this is the top group */
+static int count_depth(const struct detgeom_panel_group *group)
+{
+ int depth = 0;
+ assert(group != NULL);
+ do {
+ depth++;
+ group = group->parent;
+ } while ( group != NULL );
+ return depth-1;
+}
+
+
void write_mille(Mille *mille, int n, UnitCell *cell,
struct reflpeak *rps, struct image *image,
- gsl_matrix **Minvs)
+ int max_level, gsl_matrix **Minvs)
{
int i;
+ int depth;
+
+ assert(max_level >= 0);
/* No groups -> no refinement */
if ( image->detgeom->top_group == NULL ) {
@@ -212,8 +229,13 @@ void write_mille(Mille *mille, int n, UnitCell *cell,
/* Global gradients for each hierarchy level, starting at the
* individual panel and working up to the top level */
j = 0;
- levels = 0;
group = image->detgeom->panels[rps[i].peak->pn].group;
+ depth = count_depth(group);
+ while ( depth > max_level ) {
+ depth--;
+ group = group->parent;
+ }
+ levels = 0;
while ( group != NULL ) {
double cx, cy, cz;
diff --git a/libcrystfel/src/crystfel-mille.h b/libcrystfel/src/crystfel-mille.h
index a4b83815..d6602ef0 100644
--- a/libcrystfel/src/crystfel-mille.h
+++ b/libcrystfel/src/crystfel-mille.h
@@ -51,7 +51,7 @@ extern enum gparam mille_unlabel(int n);
extern void write_mille(Mille *mille, int n, UnitCell *cell,
struct reflpeak *rps, struct image *image,
- gsl_matrix **Minvs);
+ int max_level, gsl_matrix **Minvs);
extern void crystfel_mille_delete_last_record(Mille *m);
diff --git a/libcrystfel/src/index.c b/libcrystfel/src/index.c
index f519c3b9..d93664b1 100644
--- a/libcrystfel/src/index.c
+++ b/libcrystfel/src/index.c
@@ -592,7 +592,7 @@ static float real_time()
/* Return non-zero for "success" */
static int try_indexer(struct image *image, IndexingMethod indm,
IndexingPrivate *ipriv, void *mpriv, char *last_task,
- Mille *mille)
+ Mille *mille, int max_mille_level)
{
int i, r;
int n_bad = 0;
@@ -720,7 +720,7 @@ static int try_indexer(struct image *image, IndexingMethod indm,
{
int r;
profile_start("refine");
- r = refine_prediction(image, cr, mille);
+ r = refine_prediction(image, cr, mille, max_mille_level);
profile_end("refine");
if ( r ) {
crystal_set_user_flag(cr, 1);
@@ -921,25 +921,25 @@ static int finished_retry(IndexingMethod indm, IndexingFlags flags,
void index_pattern(struct image *image, IndexingPrivate *ipriv)
{
- index_pattern_4(image, ipriv, NULL, NULL, NULL);
+ index_pattern_4(image, ipriv, NULL, NULL, NULL, 0);
}
void index_pattern_2(struct image *image, IndexingPrivate *ipriv, int *ping)
{
- index_pattern_4(image, ipriv, ping, NULL, NULL);
+ index_pattern_4(image, ipriv, ping, NULL, NULL, 0);
}
void index_pattern_3(struct image *image, IndexingPrivate *ipriv, int *ping,
char *last_task)
{
- index_pattern_4(image, ipriv, ping, last_task, NULL);
+ index_pattern_4(image, ipriv, ping, last_task, NULL, 0);
}
void index_pattern_4(struct image *image, IndexingPrivate *ipriv, int *ping,
- char *last_task, Mille *mille)
+ char *last_task, Mille *mille, int max_mille_level)
{
int n = 0;
ImageFeatureList *orig;
@@ -994,7 +994,7 @@ void index_pattern_4(struct image *image, IndexingPrivate *ipriv, int *ping,
r = try_indexer(image, ipriv->methods[n],
ipriv, ipriv->engine_private[n],
- last_task, mille);
+ last_task, mille, max_mille_level);
success += r;
ntry++;
done = finished_retry(ipriv->methods[n], ipriv->flags,
diff --git a/libcrystfel/src/index.h b/libcrystfel/src/index.h
index fa371276..10d07f08 100644
--- a/libcrystfel/src/index.h
+++ b/libcrystfel/src/index.h
@@ -253,7 +253,8 @@ extern void index_pattern_3(struct image *image, IndexingPrivate *ipriv,
int *ping, char *last_task);
extern void index_pattern_4(struct image *image, IndexingPrivate *ipriv,
- int *ping, char *last_task, Mille *mille);
+ int *ping, char *last_task, Mille *mille,
+ int max_mille_level);
extern void cleanup_indexing(IndexingPrivate *ipriv);
diff --git a/libcrystfel/src/predict-refine.c b/libcrystfel/src/predict-refine.c
index 32d0f77b..d5a3b403 100644
--- a/libcrystfel/src/predict-refine.c
+++ b/libcrystfel/src/predict-refine.c
@@ -796,7 +796,8 @@ static void free_rps_noreflist(struct reflpeak *rps, int n)
}
-int refine_prediction(struct image *image, Crystal *cr, Mille *mille)
+int refine_prediction(struct image *image, Crystal *cr,
+ Mille *mille, int max_mille_level)
{
int n;
int i;
@@ -879,7 +880,8 @@ int refine_prediction(struct image *image, Crystal *cr, Mille *mille)
if ( mille != NULL ) {
profile_start("mille-calc");
- write_mille(mille, n, crystal_get_cell(cr), rps, image, Minvs);
+ write_mille(mille, n, crystal_get_cell(cr), rps, image,
+ max_mille_level, Minvs);
profile_end("mille-calc");
}
diff --git a/libcrystfel/src/predict-refine.h b/libcrystfel/src/predict-refine.h
index 604799c0..080e5923 100644
--- a/libcrystfel/src/predict-refine.h
+++ b/libcrystfel/src/predict-refine.h
@@ -67,7 +67,8 @@ struct reflpeak {
* Prediction refinement: refinement of indexing solutions before integration.
*/
-extern int refine_prediction(struct image *image, Crystal *cr, Mille *mille);
+extern int refine_prediction(struct image *image, Crystal *cr,
+ Mille *mille, int max_mille_level);
extern int refine_radius(Crystal *cr, struct image *image);