aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2023-02-08 15:52:29 +0100
committerThomas White <taw@physics.org>2023-02-08 15:52:29 +0100
commitc25749106ba046e1d13ec91703952aafc0fb6807 (patch)
tree30835cb398654ad888c21c47f0b44e639b3e0fda
parent129ddd9f60ff61b3bd7ec87b9c5d108d1d54045d (diff)
indexamajig: Use static clen as --camera-length-estimate, if given
This makes it work the same way as --wavelength-estimate.
-rw-r--r--libcrystfel/src/datatemplate.c21
-rw-r--r--libcrystfel/src/datatemplate.h2
-rw-r--r--libcrystfel/src/index.c13
-rw-r--r--src/indexamajig.c11
4 files changed, 47 insertions, 0 deletions
diff --git a/libcrystfel/src/datatemplate.c b/libcrystfel/src/datatemplate.c
index c270b128..4f70560f 100644
--- a/libcrystfel/src/datatemplate.c
+++ b/libcrystfel/src/datatemplate.c
@@ -2101,3 +2101,24 @@ struct detgeom *data_template_get_2d_detgeom_if_possible(const DataTemplate *dt)
{
return create_detgeom(NULL, dt, 1);
}
+
+
+/**
+ * Returns the mean clen in m, or NAN in the following circumstances:
+ * 1. If the individual panel distances vary by more than 10% of the average
+ * 2. If the tilt of the panel creates a distance variation of more than 10%
+ * of the corner value over the extent of the panel
+ * 3. If the detector geometry is not static (per-frame clen)
+ *
+ * \returns the mean camera length, or NAN if impossible.
+ */
+double data_template_get_clen_if_possible(const DataTemplate *dt)
+{
+ struct detgeom *dg;
+ double clen;
+ dg = data_template_get_2d_detgeom_if_possible(dt);
+ if ( dg == NULL ) return NAN;
+ clen = detgeom_mean_camera_length(dg);
+ detgeom_free(dg);
+ return clen;
+}
diff --git a/libcrystfel/src/datatemplate.h b/libcrystfel/src/datatemplate.h
index ddc210e6..fea39ccd 100644
--- a/libcrystfel/src/datatemplate.h
+++ b/libcrystfel/src/datatemplate.h
@@ -96,6 +96,8 @@ extern struct rg_collection *data_template_get_rigid_groups(const DataTemplate *
extern double data_template_get_wavelength_if_possible(const DataTemplate *dt);
+extern double data_template_get_clen_if_possible(const DataTemplate *dt);
+
extern struct detgeom *data_template_get_2d_detgeom_if_possible(const DataTemplate *dt);
#ifdef __cplusplus
diff --git a/libcrystfel/src/index.c b/libcrystfel/src/index.c
index 2e5343ec..02b01757 100644
--- a/libcrystfel/src/index.c
+++ b/libcrystfel/src/index.c
@@ -71,6 +71,7 @@ struct _indexingprivate
UnitCell *target_cell;
double tolerance[6];
double wavelength_estimate;
+ double clen_estimate;
int n_threads;
int n_methods;
@@ -433,6 +434,7 @@ IndexingPrivate *setup_indexing(const char *method_list,
ipriv->n_methods = n;
ipriv->flags = flags;
ipriv->wavelength_estimate = wavelength_estimate;
+ ipriv->clen_estimate = clen_estimate;
ipriv->n_threads = n_threads;
if ( cell != NULL ) {
@@ -951,6 +953,17 @@ void index_pattern_3(struct image *image, IndexingPrivate *ipriv, int *ping,
}
}
+ if ( !isnan(ipriv->clen_estimate) ) {
+ double mean_clen = detgeom_mean_camera_length(image->detgeom);
+ if ( !within_tolerance(mean_clen, ipriv->clen_estimate, 10.0) )
+ {
+ ERROR("WARNING: Camera length for %s %s (%e) differs by "
+ "more than 10%% from estimated value (%e)\n",
+ image->filename, image->ev,
+ mean_clen, ipriv->clen_estimate);
+ }
+ }
+
orig = image->features;
for ( n=0; n<ipriv->n_methods; n++ ) {
diff --git a/src/indexamajig.c b/src/indexamajig.c
index 67206070..2f431636 100644
--- a/src/indexamajig.c
+++ b/src/indexamajig.c
@@ -856,6 +856,7 @@ int main(int argc, char *argv[])
struct fromfile_options *fromfile_opts = NULL;
struct asdf_options *asdf_opts = NULL;
double wl_from_dt;
+ double clen_from_dt;
/* Defaults for "top level" arguments */
args.filename = NULL;
@@ -1260,6 +1261,16 @@ int main(int argc, char *argv[])
args.iargs.wavelength_estimate = wl_from_dt;
}
+ clen_from_dt = data_template_get_clen_if_possible(args.iargs.dtempl);
+ if ( !isnan(clen_from_dt) ) {
+ if ( !isnan(args.iargs.clen_estimate) ) {
+ ERROR("WARNING: Ignoring your value for "
+ "--camera-length-estimate because the geometry file "
+ "already contains a static value.\n");
+ }
+ args.iargs.clen_estimate = clen_from_dt;
+ }
+
/* Prepare the indexing system */
if ( args.indm_str == NULL ) {