aboutsummaryrefslogtreecommitdiff
path: root/libcrystfel
diff options
context:
space:
mode:
Diffstat (limited to 'libcrystfel')
-rw-r--r--libcrystfel/src/index.c6
-rw-r--r--libcrystfel/src/index.h1
-rw-r--r--libcrystfel/src/indexers/pinkindexer.c61
-rw-r--r--libcrystfel/src/indexers/pinkindexer.h3
4 files changed, 22 insertions, 49 deletions
diff --git a/libcrystfel/src/index.c b/libcrystfel/src/index.c
index 1c78cc58..37ced03d 100644
--- a/libcrystfel/src/index.c
+++ b/libcrystfel/src/index.c
@@ -204,6 +204,7 @@ static char *friendly_indexer_name(IndexingMethod m)
static void *prepare_method(IndexingMethod *m, UnitCell *cell,
double wavelength_estimate,
+ double clen_estimate,
struct xgandalf_options *xgandalf_opts,
struct pinkIndexer_options* pinkIndexer_opts,
struct felix_options *felix_opts,
@@ -254,7 +255,8 @@ static void *prepare_method(IndexingMethod *m, UnitCell *cell,
case INDEXING_PINKINDEXER :
priv = pinkIndexer_prepare(m, cell, pinkIndexer_opts,
- wavelength_estimate);
+ wavelength_estimate,
+ clen_estimate);
break;
default :
@@ -331,6 +333,7 @@ IndexingPrivate *setup_indexing(const char *method_list,
float *tols,
IndexingFlags flags,
double wavelength_estimate,
+ double clen_estimate,
int n_threads,
struct taketwo_options *ttopts,
struct xgandalf_options *xgandalf_opts,
@@ -402,6 +405,7 @@ IndexingPrivate *setup_indexing(const char *method_list,
ipriv->engine_private[i] = prepare_method(&methods[i], cell,
wavelength_estimate,
+ clen_estimate,
xgandalf_opts,
pinkIndexer_opts,
felix_opts,
diff --git a/libcrystfel/src/index.h b/libcrystfel/src/index.h
index 88b9b67e..a4aef671 100644
--- a/libcrystfel/src/index.h
+++ b/libcrystfel/src/index.h
@@ -171,6 +171,7 @@ extern IndexingPrivate *setup_indexing(const char *methods,
float *ltl,
IndexingFlags flags,
double wavelength_estimate,
+ double clen_estimate,
int n_threads,
struct taketwo_options *ttopts,
struct xgandalf_options *xgandalf_opts,
diff --git a/libcrystfel/src/indexers/pinkindexer.c b/libcrystfel/src/indexers/pinkindexer.c
index 149bb5bd..5cb979a9 100644
--- a/libcrystfel/src/indexers/pinkindexer.c
+++ b/libcrystfel/src/indexers/pinkindexer.c
@@ -43,8 +43,6 @@
#include "peaks.h"
-#define FAKE_CLEN (0.25)
-
struct pinkIndexer_options {
unsigned int considered_peaks_count;
unsigned int angle_resolution;
@@ -81,39 +79,6 @@ static void restoreReciprocalCell(UnitCell *cell, LatticeTransform_t* appliedRed
static void makeRightHanded(UnitCell* cell);
-/* Return mean clen in m */
-static double mean_clen(struct detgeom *dg)
-{
- int i;
- double total = 0.0;
- for ( i=0; i<dg->n_panels; i++ ) {
- total += dg->panels[i].cnz * dg->panels[i].pixel_pitch;
- }
- return total / dg->n_panels;
-}
-
-
-static void scale_detector_shift(double fake_clen,
- struct detgeom *dg,
- double inx, double iny,
- double *pdx, double *pdy)
-{
- int i;
- double mean = mean_clen(dg);
- for ( i=0; i<dg->n_panels; i++ ) {
- if ( !within_tolerance(dg->panels[i].cnz*dg->panels[i].pixel_pitch, mean, 2.0) ) {
- ERROR("WARNING: Detector is not flat enough to apply "
- "detector position offset\n");
- *pdx = 0.0;
- *pdy = 0.0;
- return;
- }
- }
- *pdx = (mean/fake_clen)*inx;
- *pdy = (mean/fake_clen)*iny;
-}
-
-
int run_pinkIndexer(struct image *image, void *ipriv, int n_threads)
{
struct pinkIndexer_private_data *pinkIndexer_private_data = ipriv;
@@ -206,19 +171,14 @@ int run_pinkIndexer(struct image *image, void *ipriv, int n_threads)
ERROR("pinkIndexer: problem with returned cell!\n");
} else {
- double dx, dy;
Crystal *cr = crystal_new();
if ( cr == NULL ) {
ERROR("Failed to allocate crystal.\n");
return 0;
}
crystal_set_cell(cr, new_cell_trans);
- scale_detector_shift(FAKE_CLEN,
- image->detgeom,
- center_shift[0],
- center_shift[1],
- &dx, &dy);
- crystal_set_det_shift(cr, dx, dy);
+ crystal_set_det_shift(cr, center_shift[0],
+ center_shift[1]);
image_add_crystal(image, cr);
indexed++;
@@ -233,7 +193,8 @@ int run_pinkIndexer(struct image *image, void *ipriv, int n_threads)
void *pinkIndexer_prepare(IndexingMethod *indm,
UnitCell *cell,
struct pinkIndexer_options *pinkIndexer_opts,
- double wavelength_estimate)
+ double wavelength_estimate,
+ double clen_estimate)
{
float beamEenergy_eV;
@@ -245,9 +206,14 @@ void *pinkIndexer_prepare(IndexingMethod *indm,
beamEenergy_eV = J_to_eV(ph_lambda_to_en(wavelength_estimate));
}
+ if ( isnan(clen_estimate) ) {
+ ERROR("PinkIndexer requires a camera length estimate. "
+ "Try again with --camera-length-estimate=xx\n");
+ return NULL;
+ }
+
if ( cell == NULL ) {
- ERROR("Unit cell information is required for "
- "PinkIndexer.\n");
+ ERROR("Unit cell information is required for PinkIndexer.\n");
return NULL;
}
@@ -294,7 +260,7 @@ void *pinkIndexer_prepare(IndexingMethod *indm,
Lattice_t sampleReciprocalLattice_1_per_A = lattice;
float detectorRadius_m = 0.03; //fake, only for prediction
ExperimentSettings *experimentSettings = ExperimentSettings_new(beamEenergy_eV,
- FAKE_CLEN,
+ clen_estimate,
detectorRadius_m,
divergenceAngle_deg,
nonMonochromaticity,
@@ -420,7 +386,8 @@ int run_pinkIndexer(struct image *image, void *ipriv, int n_threads)
extern void *pinkIndexer_prepare(IndexingMethod *indm,
UnitCell *cell,
struct pinkIndexer_options *pinkIndexer_opts,
- double wavelength_estimate)
+ double wavelength_estimate,
+ double clen_estimate)
{
ERROR("This copy of CrystFEL was compiled without PINKINDEXER support.\n");
ERROR("To use PINKINDEXER indexing, recompile with PINKINDEXER.\n");
diff --git a/libcrystfel/src/indexers/pinkindexer.h b/libcrystfel/src/indexers/pinkindexer.h
index 358a8221..122bac87 100644
--- a/libcrystfel/src/indexers/pinkindexer.h
+++ b/libcrystfel/src/indexers/pinkindexer.h
@@ -42,7 +42,8 @@ extern int run_pinkIndexer(struct image *image, void *ipriv, int n_threads);
extern void *pinkIndexer_prepare(IndexingMethod *indm,
UnitCell *cell,
struct pinkIndexer_options *pinkIndexer_opts,
- double wavelength_estimate);
+ double wavelength_estimate,
+ double clen_estimate);
extern void pinkIndexer_cleanup(void *pp);