diff options
Diffstat (limited to 'libcrystfel/src/index.c')
-rw-r--r-- | libcrystfel/src/index.c | 81 |
1 files changed, 27 insertions, 54 deletions
diff --git a/libcrystfel/src/index.c b/libcrystfel/src/index.c index 6d1828a9..58e90437 100644 --- a/libcrystfel/src/index.c +++ b/libcrystfel/src/index.c @@ -42,6 +42,7 @@ #include <string.h> #include <assert.h> #include <fenv.h> +#include <unistd.h> #include "image.h" #include "utils.h" @@ -58,10 +59,12 @@ #include "indexers/taketwo.h" #include "indexers/xgandalf.h" #include "indexers/pinkindexer.h" +#include "fromfile.h" +#include "uthash.h" -/** \file index.h */ +/** \file index.h */ struct _indexingprivate { @@ -76,7 +79,6 @@ struct _indexingprivate void **engine_private; }; - static const char *onoff(int a) { if ( a ) return "on"; @@ -97,7 +99,6 @@ static void set_last_task(char *lt, const char *task) strcpy(lt, task); } - static void show_indexing_flags(IndexingFlags flags) { STATUS("Indexing parameters:\n"); @@ -114,41 +115,6 @@ static void show_indexing_flags(IndexingFlags flags) } -static int debug_index(struct image *image) -{ - FILE *fh; - Crystal *cr; - UnitCell *cell; - float asx, asy, asz, bsx, bsy, bsz, csx, csy, csz; - - fh = fopen("../../indexing.debug", "r"); - if ( fh == NULL ) { - ERROR("indexing.debug not found\n"); - return 0; - } - - if ( fscanf(fh, "%e %e %e", &asx, &asy, &asz) != 3 ) { - ERROR("Failed to read a* from indexing.debug\n"); - return 0; - } - if ( fscanf(fh, "%e %e %e", &bsx, &bsy, &bsz) != 3 ) { - ERROR("Failed to read b* from indexing.debug\n"); - return 0; - } - if ( fscanf(fh, "%e %e %e", &csx, &csy, &csz) != 3 ) { - ERROR("Failed to read c* from indexing.debug\n"); - return 0; - } - - cr = crystal_new(); - cell = cell_new(); - cell_set_reciprocal(cell, asx, asy, asz, bsx, bsy, bsz, csx, csy, csz); - crystal_set_cell(cr, cell); - image_add_crystal(image, cr); - return 1; -} - - char *base_indexer_str(IndexingMethod indm) { char *str; @@ -202,8 +168,8 @@ char *base_indexer_str(IndexingMethod indm) strcpy(str, "simulation"); break; - case INDEXING_DEBUG : - strcpy(str, "debug"); + case INDEXING_FILE : + strcpy(str, "file"); break; default : @@ -239,7 +205,8 @@ static void *prepare_method(IndexingMethod *m, UnitCell *cell, struct xgandalf_options *xgandalf_opts, struct pinkIndexer_options* pinkIndexer_opts, struct felix_options *felix_opts, - struct taketwo_options *taketwo_opts) + struct taketwo_options *taketwo_opts, + char *filename) { char *str; IndexingMethod in = *m; @@ -267,8 +234,8 @@ static void *prepare_method(IndexingMethod *m, UnitCell *cell, priv = xds_prepare(m, cell); break; - case INDEXING_DEBUG : - priv = (IndexingPrivate *)strdup("Hello!"); + case INDEXING_FILE : + priv = fromfile_prepare(filename, cell); break; case INDEXING_FELIX : @@ -366,7 +333,8 @@ IndexingPrivate *setup_indexing(const char *method_list, struct taketwo_options *ttopts, struct xgandalf_options *xgandalf_opts, struct pinkIndexer_options *pinkIndexer_opts, - struct felix_options *felix_opts) + struct felix_options *felix_opts, + char *filename) { IndexingPrivate *ipriv; IndexingMethod *methods; @@ -435,7 +403,8 @@ IndexingPrivate *setup_indexing(const char *method_list, xgandalf_opts, pinkIndexer_opts, felix_opts, - ttopts); + ttopts, + filename); if ( ipriv->engine_private[i] == NULL ) return NULL; @@ -538,7 +507,7 @@ void cleanup_indexing(IndexingPrivate *ipriv) felix_cleanup(ipriv->engine_private[n]); break; - case INDEXING_DEBUG : + case INDEXING_FILE : free(ipriv->engine_private[n]); break; @@ -668,9 +637,10 @@ static int try_indexer(struct image *image, IndexingMethod indm, r = run_xds(image, mpriv); break; - case INDEXING_DEBUG : - set_last_task(last_task, "indexing:debug"); - r = debug_index(image); + case INDEXING_FILE : + set_last_task(last_task, "indexing:file"); + int crystal_number = 0; + r = fromfile_index(image, mpriv, crystal_number); break; case INDEXING_FELIX : @@ -972,7 +942,9 @@ void index_pattern_3(struct image *image, IndexingPrivate *ipriv, int *ping, int ntry = 0; int success = 0; - image->features = sort_peaks(orig); + if ( ipriv->methods[0] != INDEXING_FILE){ + image->features = sort_peaks(orig); + } do { @@ -988,7 +960,9 @@ void index_pattern_3(struct image *image, IndexingPrivate *ipriv, int *ping, } while ( !done ); - image_feature_list_free(image->features); + if ( ipriv->methods[0] != INDEXING_FILE){ + image_feature_list_free(image->features); + } /* Stop now if the pattern is indexed (don't try again for more * crystals with a different indexing method) */ @@ -1005,7 +979,6 @@ void index_pattern_3(struct image *image, IndexingPrivate *ipriv, int *ping, image->indexed_by = INDEXING_NONE; } - image->features = orig; } @@ -1133,9 +1106,9 @@ IndexingMethod get_indm_from_string_2(const char *str, int *err) method = INDEXING_SIMULATION; return method; - } else if ( strcmp(bits[i], "debug") == 0) { + } else if ( strcmp(bits[i], "file") == 0) { if ( have_method ) return warn_method(str); - method = INDEXING_DEBUG; + method = INDEXING_FILE; return method; } else if ( strcmp(bits[i], "latt") == 0) { |