From c25749106ba046e1d13ec91703952aafc0fb6807 Mon Sep 17 00:00:00 2001 From: Thomas White Date: Wed, 8 Feb 2023 15:52:29 +0100 Subject: indexamajig: Use static clen as --camera-length-estimate, if given This makes it work the same way as --wavelength-estimate. --- libcrystfel/src/datatemplate.c | 21 +++++++++++++++++++++ libcrystfel/src/datatemplate.h | 2 ++ libcrystfel/src/index.c | 13 +++++++++++++ 3 files changed, 36 insertions(+) (limited to 'libcrystfel') 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; nn_methods; n++ ) { -- cgit v1.2.3