diff options
-rw-r--r-- | libcrystfel/src/detector.c | 14 | ||||
-rw-r--r-- | libcrystfel/src/image.h | 2 | ||||
-rw-r--r-- | libcrystfel/src/index.c | 12 | ||||
-rw-r--r-- | libcrystfel/src/index.h | 3 | ||||
-rw-r--r-- | libcrystfel/src/pinkindexer.c | 30 | ||||
-rw-r--r-- | libcrystfel/src/pinkindexer.h | 11 | ||||
-rw-r--r-- | src/indexamajig.c | 10 |
7 files changed, 47 insertions, 35 deletions
diff --git a/libcrystfel/src/detector.c b/libcrystfel/src/detector.c index 201b9041..aab72341 100644 --- a/libcrystfel/src/detector.c +++ b/libcrystfel/src/detector.c @@ -1070,6 +1070,19 @@ static void parse_toplevel(struct detector *det, struct beam_params *beam, } } + } else if ( strcmp(key, "photon_energy_bandwidth") == 0 ) { + if ( beam != NULL ) { + double v; + char *end; + v = strtod(val, &end); + if ( (val[0] != '\0') && (end[0] == '\0') ) { + beam->bandwidth = v; + } else { + ERROR("Invalid value for " + "photon_energy_bandwidth\n"); + } + } + } else if ( strcmp(key, "photon_energy_scale") == 0 ) { if ( beam != NULL ) { beam->photon_energy_scale = atof(val); @@ -1202,6 +1215,7 @@ struct detector *get_detector_geometry_from_string(const char *string, beam->photon_energy = 0.0; beam->photon_energy_from = NULL; beam->photon_energy_scale = 1.0; + beam->bandwidth = 0.0; } det->n_panels = 0; diff --git a/libcrystfel/src/image.h b/libcrystfel/src/image.h index 706b06b1..04fb18a0 100644 --- a/libcrystfel/src/image.h +++ b/libcrystfel/src/image.h @@ -110,6 +110,8 @@ struct beam_params char *photon_energy_from; /**< HDF5 dataset name */ double photon_energy_scale; /**< Scale factor for photon energy, if it * comes from an image header */ + double bandwidth; /**< FWHM bandwidth as a fraction of + * wavelength */ }; diff --git a/libcrystfel/src/index.c b/libcrystfel/src/index.c index 80a773ab..d48a6634 100644 --- a/libcrystfel/src/index.c +++ b/libcrystfel/src/index.c @@ -238,6 +238,7 @@ static char *friendly_indexer_name(IndexingMethod m) static void *prepare_method(IndexingMethod *m, UnitCell *cell, + struct detector *det, struct beam_params *beam, struct xgandalf_options *xgandalf_opts, struct pinkIndexer_options* pinkIndexer_opts, struct felix_options *felix_opts) @@ -285,7 +286,8 @@ static void *prepare_method(IndexingMethod *m, UnitCell *cell, break; case INDEXING_PINKINDEXER : - priv = pinkIndexer_prepare(m, cell, pinkIndexer_opts); + priv = pinkIndexer_prepare(m, cell, pinkIndexer_opts, + det, beam); break; default : @@ -316,8 +318,8 @@ static void *prepare_method(IndexingMethod *m, UnitCell *cell, IndexingPrivate *setup_indexing(const char *method_list, UnitCell *cell, - struct detector *det, float *tols, - IndexingFlags flags, + struct detector *det, struct beam_params *beam, + float *tols, IndexingFlags flags, struct taketwo_options *ttopts, struct xgandalf_options *xgandalf_opts, struct pinkIndexer_options *pinkIndexer_opts, @@ -415,7 +417,9 @@ IndexingPrivate *setup_indexing(const char *method_list, UnitCell *cell, int j; ipriv->engine_private[i] = prepare_method(&methods[i], cell, - xgandalf_opts, pinkIndexer_opts, + det, beam, + xgandalf_opts, + pinkIndexer_opts, felix_opts); if ( ipriv->engine_private[i] == NULL ) return NULL; diff --git a/libcrystfel/src/index.h b/libcrystfel/src/index.h index ab38016f..883df4a3 100644 --- a/libcrystfel/src/index.h +++ b/libcrystfel/src/index.h @@ -153,7 +153,8 @@ extern IndexingMethod get_indm_from_string_2(const char *method, int *err); #include "felix.h" extern IndexingPrivate *setup_indexing(const char *methods, UnitCell *cell, - struct detector *det, float *ltl, + struct detector *det, + struct beam_params *beam, float *ltl, IndexingFlags flags, struct taketwo_options *ttopts, struct xgandalf_options *xgandalf_opts, diff --git a/libcrystfel/src/pinkindexer.c b/libcrystfel/src/pinkindexer.c index fe3b1625..eb8ec05e 100644 --- a/libcrystfel/src/pinkindexer.c +++ b/libcrystfel/src/pinkindexer.c @@ -154,26 +154,19 @@ int run_pinkIndexer(struct image *image, void *ipriv) } void *pinkIndexer_prepare(IndexingMethod *indm, UnitCell *cell, - struct pinkIndexer_options *pinkIndexer_opts) + struct pinkIndexer_options *pinkIndexer_opts, + struct detector *det, struct beam_params *beam) { - if (pinkIndexer_opts->beamEnergy == 0.0) { + if ( beam->photon_energy_from != NULL ) { ERROR("For pinkIndexer, the photon_energy must be defined as a " "constant in the geometry file\n"); return NULL; } - if (pinkIndexer_opts->beamBandwidth == 0.0) { - STATUS("Using default bandwidth of 0.01 for pinkIndexer\n"); - pinkIndexer_opts->beamBandwidth = 0.01; - } - if (pinkIndexer_opts->detectorDistance == 0.0 && pinkIndexer_opts->refinement_type == + if ( (det->panels[0].clen_from != NULL) && pinkIndexer_opts->refinement_type == REFINEMENT_TYPE_firstFixedThenVariableLatticeParametersCenterAdjustmentMultiSeed) { ERROR("Using center refinement makes it necessary to have the detector distance fixed in the geometry file!"); } - if(pinkIndexer_opts->detectorDistance <= 0.0){ - pinkIndexer_opts->detectorDistance = 0.25; //fake value - } - struct pinkIndexer_private_data* pinkIndexer_private_data = malloc(sizeof(struct pinkIndexer_private_data)); allocReciprocalPeaks(&(pinkIndexer_private_data->reciprocalPeaks_1_per_A)); pinkIndexer_private_data->intensities = malloc(MAX_PEAK_COUNT_FOR_INDEXER * sizeof(float)); @@ -199,9 +192,15 @@ void *pinkIndexer_prepare(IndexingMethod *indm, UnitCell *cell, .bx = bsz * 1e-10, .by = bsx * 1e-10, .bz = bsy * 1e-10, .cx = csz * 1e-10, .cy = csx * 1e-10, .cz = csy * 1e-10 }; - float detectorDistance_m = pinkIndexer_opts->detectorDistance; - float beamEenergy_eV = pinkIndexer_opts->beamEnergy; - float nonMonochromaticity = pinkIndexer_opts->beamBandwidth; + float detectorDistance_m; + if ( det->panels[0].clen_from != NULL ) { + detectorDistance_m = 0.25; /* fake value */ + } else { + detectorDistance_m = det->panels[0].clen + det->panels[0].coffset; + } + + float beamEenergy_eV = beam->photon_energy; + float nonMonochromaticity = beam->bandwidth; float reflectionRadius_1_per_A; if (pinkIndexer_opts->reflectionRadius < 0) { reflectionRadius_1_per_A = 0.02 @@ -350,7 +349,8 @@ int run_pinkIndexer(struct image *image, void *ipriv) } extern void *pinkIndexer_prepare(IndexingMethod *indm, UnitCell *cell, - struct pinkIndexer_options *pinkIndexer_opts) + struct pinkIndexer_options *pinkIndexer_opts, + struct detector *det, struct beam_params *beam) { 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/pinkindexer.h b/libcrystfel/src/pinkindexer.h index 5be2c1e7..1fcb3711 100644 --- a/libcrystfel/src/pinkindexer.h +++ b/libcrystfel/src/pinkindexer.h @@ -42,14 +42,8 @@ struct pinkIndexer_options { int multi; int thread_count; int min_peaks; - int no_check_indexed; - - float beamEnergy; //in eV - float beamBandwidth; //(delta lambda)/lambda - float detectorDistance; //in m - - float reflectionRadius; //in 1/A + float reflectionRadius; /* In m^-1 */ }; #include <stddef.h> @@ -58,7 +52,8 @@ struct pinkIndexer_options { extern int run_pinkIndexer(struct image *image, void *ipriv); extern void *pinkIndexer_prepare(IndexingMethod *indm, UnitCell *cell, - struct pinkIndexer_options *pinkIndexer_opts); + struct pinkIndexer_options *pinkIndexer_opts, + struct detector *det, struct beam_params *beam); extern void pinkIndexer_cleanup(void *pp); diff --git a/src/indexamajig.c b/src/indexamajig.c index 9aef3f2e..9fe14c65 100644 --- a/src/indexamajig.c +++ b/src/indexamajig.c @@ -1048,6 +1048,8 @@ int main(int argc, char *argv[]) "--pinkIndexer-reflection-radius\n"); return 1; } + /* A^-1 to m^-1 */ + iargs.pinkIndexer_opts.reflectionRadius /= 1e10; break; case 0 : @@ -1149,12 +1151,6 @@ int main(int argc, char *argv[]) return 1; } add_geom_beam_stuff_to_field_list(iargs.copyme, iargs.det, iargs.beam); - iargs.pinkIndexer_opts.beamEnergy = iargs.beam->photon_energy; - iargs.pinkIndexer_opts.beamBandwidth = 0.01; - iargs.pinkIndexer_opts.detectorDistance = iargs.det->panels[0].clen; - if(iargs.det->panels[0].clen_from != NULL){ - iargs.pinkIndexer_opts.detectorDistance = 0; - } /* If no peak path from geometry file, use these (but see later) */ if ( iargs.hdf5_peak_path == NULL ) { @@ -1394,7 +1390,7 @@ int main(int argc, char *argv[]) } iargs.ipriv = setup_indexing(indm_str, iargs.cell, iargs.det, - iargs.tols, flags, + iargs.beam, iargs.tols, flags, &iargs.taketwo_opts, &iargs.xgandalf_opts, &iargs.pinkIndexer_opts, |