aboutsummaryrefslogtreecommitdiff
path: root/libcrystfel/src/crystfel-mille.c
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/src/crystfel-mille.c
parent9918b000068b7daceb0c62921a47922f88b17161 (diff)
indexamajig: Implement --max-mille-level
Diffstat (limited to 'libcrystfel/src/crystfel-mille.c')
-rw-r--r--libcrystfel/src/crystfel-mille.c26
1 files changed, 24 insertions, 2 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;