aboutsummaryrefslogtreecommitdiff
path: root/libcrystfel/src
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2023-07-13 17:18:54 +0200
committerThomas White <taw@physics.org>2023-07-28 13:22:05 +0200
commitb1089d5a0b75fb1dc66a6d8384d5e3ff1d0d7d78 (patch)
tree2233e60d39abd2d0dc80654b3dc4f38ce6472107 /libcrystfel/src
parent2501aedda111feaf139f9d8e94c4ab36926e93e3 (diff)
Re-define geometry group labelling scheme
The old version was totally broken. The serial numbers have to contain the complete hierarchy information, otherwise they aren't unique.
Diffstat (limited to 'libcrystfel/src')
-rw-r--r--libcrystfel/src/crystfel-mille.c43
-rw-r--r--libcrystfel/src/crystfel-mille.h2
-rw-r--r--libcrystfel/src/datatemplate.c12
-rw-r--r--libcrystfel/src/detgeom.c4
-rw-r--r--libcrystfel/src/detgeom.h3
5 files changed, 21 insertions, 43 deletions
diff --git a/libcrystfel/src/crystfel-mille.c b/libcrystfel/src/crystfel-mille.c
index 139f2e9e..974ecf27 100644
--- a/libcrystfel/src/crystfel-mille.c
+++ b/libcrystfel/src/crystfel-mille.c
@@ -54,20 +54,15 @@ static const enum gparam rv[] =
};
-int mille_label(int hierarchy_level, int member_index, enum gparam param)
+int mille_label(int group_serial, enum gparam param)
{
- int label;
-
- assert(member_index < 1000);
-
- label = 100000*hierarchy_level + 100*member_index;
switch ( param ) {
- case GPARAM_DET_TX : return label+1; /* x-shift */
- case GPARAM_DET_TY : return label+2; /* y-shift */
- case GPARAM_DET_TZ : return label+3; /* z-shift */
- case GPARAM_DET_RX : return label+4; /* Rotation around x */
- case GPARAM_DET_RY : return label+5; /* Rotation around y */
- case GPARAM_DET_RZ : return label+6; /* Rotation around z */
+ case GPARAM_DET_TX : return group_serial+1; /* x-shift */
+ case GPARAM_DET_TY : return group_serial+2; /* y-shift */
+ case GPARAM_DET_TZ : return group_serial+3; /* z-shift */
+ case GPARAM_DET_RX : return group_serial+4; /* Rotation around x */
+ case GPARAM_DET_RY : return group_serial+5; /* Rotation around y */
+ case GPARAM_DET_RZ : return group_serial+6; /* Rotation around z */
default : abort();
}
}
@@ -112,9 +107,7 @@ void write_mille(Mille *mille, int n, UnitCell *cell,
Minvs[rps[i].peak->pn], 0, 0, 0,
&global_gradients_fs[j],
&global_gradients_ss[j]);
- labels[j] = mille_label(group->hierarchy_level,
- group->member_index,
- GPARAM_DET_TX);
+ labels[j] = mille_label(group->serial, GPARAM_DET_TX);
j++;
fs_ss_gradient(GPARAM_DET_TY, rps[i].refl, cell,
@@ -122,9 +115,7 @@ void write_mille(Mille *mille, int n, UnitCell *cell,
Minvs[rps[i].peak->pn], 0, 0, 0,
&global_gradients_fs[j],
&global_gradients_ss[j]);
- labels[j] = mille_label(group->hierarchy_level,
- group->member_index,
- GPARAM_DET_TY);
+ labels[j] = mille_label(group->serial, GPARAM_DET_TY);
j++;
fs_ss_gradient(GPARAM_DET_TZ, rps[i].refl, cell,
@@ -132,9 +123,7 @@ void write_mille(Mille *mille, int n, UnitCell *cell,
Minvs[rps[i].peak->pn], 0, 0, 0,
&global_gradients_fs[j],
&global_gradients_ss[j]);
- labels[j] = mille_label(group->hierarchy_level,
- group->member_index,
- GPARAM_DET_TZ);
+ labels[j] = mille_label(group->serial, GPARAM_DET_TZ);
j++;
fs_ss_gradient(GPARAM_DET_RX, rps[i].refl, cell,
@@ -142,9 +131,7 @@ void write_mille(Mille *mille, int n, UnitCell *cell,
Minvs[rps[i].peak->pn], cx, cy, cz,
&global_gradients_fs[j],
&global_gradients_ss[j]);
- labels[j] = mille_label(group->hierarchy_level,
- group->member_index,
- GPARAM_DET_RX);
+ labels[j] = mille_label(group->serial, GPARAM_DET_RX);
j++;
fs_ss_gradient(GPARAM_DET_RY, rps[i].refl, cell,
@@ -152,9 +139,7 @@ void write_mille(Mille *mille, int n, UnitCell *cell,
Minvs[rps[i].peak->pn], cx, cy, cz,
&global_gradients_fs[j],
&global_gradients_ss[j]);
- labels[j] = mille_label(group->hierarchy_level,
- group->member_index,
- GPARAM_DET_RX);
+ labels[j] = mille_label(group->serial, GPARAM_DET_RY);
j++;
fs_ss_gradient(GPARAM_DET_RZ, rps[i].refl, cell,
@@ -162,9 +147,7 @@ void write_mille(Mille *mille, int n, UnitCell *cell,
Minvs[rps[i].peak->pn], cx, cy, cz,
&global_gradients_fs[j],
&global_gradients_ss[j]);
- labels[j] = mille_label(group->hierarchy_level,
- group->member_index,
- GPARAM_DET_RZ);
+ labels[j] = mille_label(group->serial, GPARAM_DET_RZ);
j++;
group = group->parent;
diff --git a/libcrystfel/src/crystfel-mille.h b/libcrystfel/src/crystfel-mille.h
index fc290cbb..adec271a 100644
--- a/libcrystfel/src/crystfel-mille.h
+++ b/libcrystfel/src/crystfel-mille.h
@@ -48,7 +48,7 @@ extern Mille *crystfel_mille_new(const char *outFileName,
extern void crystfel_mille_free(Mille *m);
-extern int mille_label(int hierarchy_level, int member_index, enum gparam param);
+extern int mille_label(int group_serial, enum gparam param);
extern void write_mille(Mille *mille, int n, UnitCell *cell,
struct reflpeak *rps, struct image *image,
diff --git a/libcrystfel/src/datatemplate.c b/libcrystfel/src/datatemplate.c
index 2c689a43..6adfb9f3 100644
--- a/libcrystfel/src/datatemplate.c
+++ b/libcrystfel/src/datatemplate.c
@@ -1819,8 +1819,7 @@ static void add_dg_point(const struct detgeom_panel *p,
static struct detgeom_panel_group *walk_group(const DataTemplate *dtempl,
struct panel_group_template *gt,
struct detgeom *detgeom,
- int hierarchy_level,
- int member_index)
+ int serial, int c_mul)
{
struct detgeom_panel_group *gr;
@@ -1872,8 +1871,8 @@ static struct detgeom_panel_group *walk_group(const DataTemplate *dtempl,
}
for ( i=0; i<gt->n_children; i++ ) {
- gr->children[i] = walk_group(dtempl, gt->children[i],
- detgeom, hierarchy_level+1, i);
+ gr->children[i] = walk_group(dtempl, gt->children[i], detgeom,
+ serial + c_mul*(i+1), c_mul*100);
if ( gr->children[i] == NULL ) return NULL;
gr->children[i]->parent = gr;
tx += gr->children[i]->cx;
@@ -1887,8 +1886,7 @@ static struct detgeom_panel_group *walk_group(const DataTemplate *dtempl,
}
- gr->member_index = member_index;
- gr->hierarchy_level = hierarchy_level;
+ gr->serial = serial;
return gr;
}
@@ -2017,7 +2015,7 @@ struct detgeom *create_detgeom(struct image *image,
}
- detgeom->top_group = walk_group(dtempl, find_group(dtempl, "all"), detgeom, 0, 0);
+ detgeom->top_group = walk_group(dtempl, find_group(dtempl, "all"), detgeom, 0, 100);
if ( detgeom->top_group != NULL ) {
detgeom->top_group->parent = NULL;
} else {
diff --git a/libcrystfel/src/detgeom.c b/libcrystfel/src/detgeom.c
index 1e86eb95..eaf7c898 100644
--- a/libcrystfel/src/detgeom.c
+++ b/libcrystfel/src/detgeom.c
@@ -202,9 +202,7 @@ static void detgeom_show_group(const struct detgeom_panel_group *group, int leve
return;
}
- STATUS("%s (level %i, index %i)\n", group->name,
- group->hierarchy_level,
- group->member_index);
+ STATUS("%s (serial %i)\n", group->name, group->serial);
for ( i=0; i<group->n_children; i++ ) {
detgeom_show_group(group->children[i], level+1);
diff --git a/libcrystfel/src/detgeom.h b/libcrystfel/src/detgeom.h
index 5a1a758e..53877b2e 100644
--- a/libcrystfel/src/detgeom.h
+++ b/libcrystfel/src/detgeom.h
@@ -96,8 +96,7 @@ struct detgeom_panel_group
int n_children;
struct detgeom_panel_group *parent;
- int hierarchy_level;
- int member_index;
+ int serial;
/* Center of panel group, in lab coordinate system (metres)
* This will be the rotation center. */