aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2020-10-26 15:06:38 +0100
committerThomas White <taw@physics.org>2020-10-26 15:08:50 +0100
commit2089e6e3c0a34430239dce596bc27db30611ac2f (patch)
tree0b269fba30065b28c51ca3456313d26347fc58e5
parent6819e268a8401fec0001812e7612909b3211fab1 (diff)
Label all uses of cell tolerances
I'm sick of fixing this same issue over and over again. New rule: any code handling unit cell tolerances MUST be labelled with details of units.
-rw-r--r--libcrystfel/src/cell-utils.c3
-rw-r--r--libcrystfel/src/index.c2
-rw-r--r--src/crystfelindexingopts.c3
-rw-r--r--src/crystfelindexingopts.h6
-rw-r--r--src/gui_project.c4
-rw-r--r--src/indexamajig.c14
6 files changed, 23 insertions, 9 deletions
diff --git a/libcrystfel/src/cell-utils.c b/libcrystfel/src/cell-utils.c
index 2e2e431a..22610ce1 100644
--- a/libcrystfel/src/cell-utils.c
+++ b/libcrystfel/src/cell-utils.c
@@ -1354,6 +1354,7 @@ int compare_cell_parameters(UnitCell *cell, UnitCell *reference,
cell_get_parameters(cell, &a1, &b1, &c1, &al1, &be1, &ga1);
cell_get_parameters(reference, &a2, &b2, &c2, &al2, &be2, &ga2);
+ /* within_tolerance() takes a percentage */
if ( !within_tolerance(a1, a2, tols[0]*100.0) ) return 0;
if ( !within_tolerance(b1, b2, tols[1]*100.0) ) return 0;
if ( !within_tolerance(c1, c2, tols[2]*100.0) ) return 0;
@@ -1399,6 +1400,7 @@ static double moduli_check(double ax, double ay, double az,
* \returns non-zero if the cells match.
*
*/
+/* 'tols' is in frac (not %) and radians */
int compare_cell_parameters_and_orientation(UnitCell *cell, UnitCell *reference,
const double *tols)
{
@@ -1454,6 +1456,7 @@ int compare_cell_parameters_and_orientation(UnitCell *cell, UnitCell *reference,
* \returns non-zero if the cells match.
*
*/
+/* 'tols' is in frac (not %) and radians */
int compare_permuted_cell_parameters_and_orientation(UnitCell *cell,
UnitCell *reference,
const double *tols,
diff --git a/libcrystfel/src/index.c b/libcrystfel/src/index.c
index f9c02c28..457fd7fe 100644
--- a/libcrystfel/src/index.c
+++ b/libcrystfel/src/index.c
@@ -354,6 +354,7 @@ IndexingMethod *parse_indexing_methods(const char *method_list,
}
+/* 'tols' is in frac (not %) and radians */
IndexingPrivate *setup_indexing(const char *method_list, UnitCell *cell,
const DataTemplate *dtempl,
float *tols, IndexingFlags flags,
@@ -776,6 +777,7 @@ static int try_indexer(struct image *image, IndexingMethod indm,
for ( j=0; j<this_crystal; j++ ) {
Crystal *that_cr = image->crystals[j];
+ /* 'tols' is in frac (not %) and radians */
const double tols[] = {0.1, 0.1, 0.1,
deg2rad(5.0),
deg2rad(5.0),
diff --git a/src/crystfelindexingopts.c b/src/crystfelindexingopts.c
index e4e2ffd3..e9e9ab3e 100644
--- a/src/crystfelindexingopts.c
+++ b/src/crystfelindexingopts.c
@@ -567,6 +567,8 @@ int crystfel_indexing_opts_get_cell_check(CrystFELIndexingOpts *opts)
}
+
+/* Values in 'tols' are in frac (not %) and rad */
void crystfel_indexing_opts_get_tolerances(CrystFELIndexingOpts *opts,
float *tols)
{
@@ -785,6 +787,7 @@ void crystfel_indexing_opts_set_cell_check(CrystFELIndexingOpts *opts,
}
+/* Values in 'tols' are in frac (not %) and rad */
void crystfel_indexing_opts_set_tolerances(CrystFELIndexingOpts *opts,
float *tols)
{
diff --git a/src/crystfelindexingopts.h b/src/crystfelindexingopts.h
index ddf6b1b2..32c8de44 100644
--- a/src/crystfelindexingopts.h
+++ b/src/crystfelindexingopts.h
@@ -64,7 +64,7 @@ struct _crystfelindexingopts
GtkWidget *retry;
GtkWidget *check_peaks;
GtkWidget *check_cell;
- GtkWidget *tols[6];
+ GtkWidget *tols[6]; /* frac (not %) and radians */
GtkWidget *enable_hitfind;
GtkWidget *ignore_fewer_peaks;
@@ -97,7 +97,7 @@ extern int crystfel_indexing_opts_get_retry(CrystFELIndexingOpts *opts);
extern int crystfel_indexing_opts_get_peak_check(CrystFELIndexingOpts *opts);
extern int crystfel_indexing_opts_get_cell_check(CrystFELIndexingOpts *opts);
extern void crystfel_indexing_opts_get_tolerances(CrystFELIndexingOpts *opts,
- float *tols);
+ float *tols); /* frac (not %) and rad */
extern int crystfel_indexing_opts_get_min_peaks(CrystFELIndexingOpts *opts);
extern char *crystfel_indexing_opts_get_integration_method_string(CrystFELIndexingOpts *opts);
@@ -124,7 +124,7 @@ extern void crystfel_indexing_opts_set_peak_check(CrystFELIndexingOpts *opts,
extern void crystfel_indexing_opts_set_cell_check(CrystFELIndexingOpts *opts,
int cell_check);
extern void crystfel_indexing_opts_set_tolerances(CrystFELIndexingOpts *opts,
- float *tols);
+ float *tols); /* frac (not %) and rad */
extern void crystfel_indexing_opts_set_min_peaks(CrystFELIndexingOpts *opts,
int min_peaks);
diff --git a/src/gui_project.c b/src/gui_project.c
index f0bb2b38..38e800ba 100644
--- a/src/gui_project.c
+++ b/src/gui_project.c
@@ -120,6 +120,7 @@ int match_filename(const char *fn, enum match_type_id mt)
}
+/* "tols" is in frac (not %) and radians */
static void parse_tols(const char *text, float *tols)
{
int r;
@@ -597,6 +598,9 @@ int save_project(struct crystfelproject *proj)
proj->indexing_params.no_peak_check);
fprintf(fh, "indexing.no_cell_check %i\n",
proj->indexing_params.no_cell_check);
+
+ /* Values in file are in percent and degrees */
+ /* Values in "tol" are in frac (not %) and radians */
fprintf(fh, "indexing.cell_tolerance %f,%f,%f,%f,%f,%f\n",
proj->indexing_params.tols[0]*100.0,
proj->indexing_params.tols[1]*100.0,
diff --git a/src/indexamajig.c b/src/indexamajig.c
index 8285f780..2f96ecac 100644
--- a/src/indexamajig.c
+++ b/src/indexamajig.c
@@ -382,6 +382,8 @@ static error_t parse_arg(int key, char *arg, struct argp_state *state)
break;
case 401 :
+ /* Values in 'tols' are in frac (not %) and rad
+ * Conversion happens a few lines below */
r = sscanf(arg, "%f,%f,%f,%f,%f,%f",
&args->iargs.tols[0], &args->iargs.tols[1], &args->iargs.tols[2],
&args->iargs.tols[3], &args->iargs.tols[4], &args->iargs.tols[5]);
@@ -620,12 +622,12 @@ int main(int argc, char *argv[])
args.iargs.cell = NULL;
args.iargs.noisefilter = 0;
args.iargs.median_filter = 0;
- args.iargs.tols[0] = 0.05;
- args.iargs.tols[1] = 0.05;
- args.iargs.tols[2] = 0.05;
- args.iargs.tols[3] = deg2rad(1.5);
- args.iargs.tols[4] = deg2rad(1.5);
- args.iargs.tols[5] = deg2rad(1.5);
+ args.iargs.tols[0] = 0.05; /* frac (not %) */
+ args.iargs.tols[1] = 0.05; /* frac (not %) */
+ args.iargs.tols[2] = 0.05; /* frac (not %) */
+ args.iargs.tols[3] = deg2rad(1.5); /* radians */
+ args.iargs.tols[4] = deg2rad(1.5); /* radians */
+ args.iargs.tols[5] = deg2rad(1.5); /* radians */
args.iargs.threshold = 800.0;
args.iargs.min_sq_gradient = 100000.0;
args.iargs.min_snr = 5.0;