aboutsummaryrefslogtreecommitdiff
path: root/libcrystfel/src/datatemplate.c
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 /libcrystfel/src/datatemplate.c
parent129ddd9f60ff61b3bd7ec87b9c5d108d1d54045d (diff)
indexamajig: Use static clen as --camera-length-estimate, if given
This makes it work the same way as --wavelength-estimate.
Diffstat (limited to 'libcrystfel/src/datatemplate.c')
-rw-r--r--libcrystfel/src/datatemplate.c21
1 files changed, 21 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;
+}