From a9d289c5c9c5c3491b8ecd6580c381a423094734 Mon Sep 17 00:00:00 2001 From: Thomas White Date: Tue, 12 Feb 2013 02:16:44 -0800 Subject: Improve handling of indexing methods --- libcrystfel/src/beam-parameters.h | 8 ++- libcrystfel/src/dirax.c | 12 ++-- libcrystfel/src/dirax.h | 2 +- libcrystfel/src/image.h | 3 + libcrystfel/src/index.c | 127 +++++++++++++++++++++++++++++++++----- libcrystfel/src/index.h | 12 ++++ libcrystfel/src/mosflm.c | 15 +++-- libcrystfel/src/mosflm.h | 2 +- libcrystfel/src/reax.c | 10 ++- libcrystfel/src/reax.h | 13 ++-- libcrystfel/src/stream.c | 1 + 11 files changed, 168 insertions(+), 37 deletions(-) (limited to 'libcrystfel') diff --git a/libcrystfel/src/beam-parameters.h b/libcrystfel/src/beam-parameters.h index 8212811b..de777deb 100644 --- a/libcrystfel/src/beam-parameters.h +++ b/libcrystfel/src/beam-parameters.h @@ -3,11 +3,11 @@ * * Beam parameters * - * Copyright © 2012 Deutsches Elektronen-Synchrotron DESY, - * a research centre of the Helmholtz Association. + * Copyright © 2013-2013 Deutsches Elektronen-Synchrotron DESY, + * a research centre of the Helmholtz Association. * * Authors: - * 2010,2012 Thomas White + * 2010,2012-2013 Thomas White * 2012 Chunhong Yoon * * This file is part of CrystFEL. @@ -34,6 +34,8 @@ #include #endif +struct beam_params; + #include "hdf5-file.h" struct beam_params diff --git a/libcrystfel/src/dirax.c b/libcrystfel/src/dirax.c index fc185fd4..e6ff36b1 100644 --- a/libcrystfel/src/dirax.c +++ b/libcrystfel/src/dirax.c @@ -626,27 +626,31 @@ int run_dirax(struct image *image, IndexingPrivate *ipriv) } -IndexingPrivate *dirax_prepare(IndexingMethod indm, UnitCell *cell, +IndexingPrivate *dirax_prepare(IndexingMethod *indm, UnitCell *cell, const char *filename, struct detector *det, struct beam_params *beam, float *ltl) { struct dirax_private *dp; int need_cell = 0; - if ( indm & INDEXING_CHECK_CELL_COMBINATIONS ) need_cell = 1; - if ( indm & INDEXING_CHECK_CELL_AXES ) need_cell = 1; + if ( *indm & INDEXING_CHECK_CELL_COMBINATIONS ) need_cell = 1; + if ( *indm & INDEXING_CHECK_CELL_AXES ) need_cell = 1; if ( need_cell && (cell == NULL) ) { ERROR("DirAx needs a unit cell for this set of flags.\n"); return NULL; } + /* Flags that DirAx knows about */ + *indm &= INDEXING_METHOD_MASK | INDEXING_CHECK_CELL_COMBINATIONS + | INDEXING_CHECK_CELL_AXES | INDEXING_CHECK_PEAKS; + dp = malloc(sizeof(struct dirax_private)); if ( dp == NULL ) return NULL; dp->ltl = ltl; dp->template = cell; - dp->indm = indm; + dp->indm = *indm; return (IndexingPrivate *)dp; } diff --git a/libcrystfel/src/dirax.h b/libcrystfel/src/dirax.h index 9e746a1b..6be8451a 100644 --- a/libcrystfel/src/dirax.h +++ b/libcrystfel/src/dirax.h @@ -37,7 +37,7 @@ extern int run_dirax(struct image *image, IndexingPrivate *ipriv); -extern IndexingPrivate *dirax_prepare(IndexingMethod indm, +extern IndexingPrivate *dirax_prepare(IndexingMethod *indm, UnitCell *cell, const char *filename, struct detector *det, struct beam_params *beam, float *ltl); diff --git a/libcrystfel/src/image.h b/libcrystfel/src/image.h index 91950e76..3739c01f 100644 --- a/libcrystfel/src/image.h +++ b/libcrystfel/src/image.h @@ -42,6 +42,7 @@ #include "detector.h" #include "reflist.h" #include "crystal.h" +#include "index.h" /* Structure describing a feature in an image */ @@ -79,6 +80,7 @@ typedef struct _imagefeaturelist ImageFeatureList; * * Crystal **crystals; * int n_crystals; + * IndexingMethod indexed_by; * * struct detector *det; * struct beam_params *beam; @@ -128,6 +130,7 @@ struct image { Crystal **crystals; int n_crystals; + IndexingMethod indexed_by; struct detector *det; struct beam_params *beam; /* The nominal beam parameters */ diff --git a/libcrystfel/src/index.c b/libcrystfel/src/index.c index 28f33388..f65265ae 100644 --- a/libcrystfel/src/index.c +++ b/libcrystfel/src/index.c @@ -65,20 +65,26 @@ IndexingPrivate **prepare_indexing(IndexingMethod *indm, UnitCell *cell, for ( n=0; nindexed_by = indms[n]; } @@ -242,6 +261,14 @@ static IndexingMethod set_axes(IndexingMethod a) } +/* Set the indexer flags for "combination mode" ("--cell-reduction=reduce") */ +static IndexingMethod set_comb(IndexingMethod a) +{ + return (a & ~INDEXING_CHECK_CELL_AXES) + | INDEXING_CHECK_CELL_COMBINATIONS; +} + + /* Set the indexer flags for "use no lattice type information" */ static IndexingMethod set_nolattice(IndexingMethod a) { @@ -249,6 +276,71 @@ static IndexingMethod set_nolattice(IndexingMethod a) } +/* Set the indexer flags for "use lattice type information" */ +static IndexingMethod set_lattice(IndexingMethod a) +{ + return a | INDEXING_USE_LATTICE_TYPE; +} + + +char *indexer_str(IndexingMethod indm) +{ + char *str; + + str = malloc(32); + if ( str == NULL ) { + ERROR("Failed to allocate string.\n"); + return NULL; + } + str[0] = '\0'; + + switch ( indm & INDEXING_METHOD_MASK ) { + + case INDEXING_NONE : + strcpy(str, "none"); + return str; + + case INDEXING_DIRAX : + strcpy(str, "dirax"); + break; + + case INDEXING_MOSFLM : + strcpy(str, "mosflm"); + break; + + case INDEXING_REAX : + strcpy(str, "reax"); + break; + + default : + ERROR("Unrecognised indexing method %i\n", indm); + strcpy(str, "(unknown)"); + break; + + } + + if ( indm & INDEXING_CHECK_CELL_COMBINATIONS ) { + strcat(str, "-comb"); + } else if ( indm & INDEXING_CHECK_CELL_AXES ) { + strcat(str, "-axes"); + } else { + strcat(str, "-raw"); + } + + if ( !(indm & INDEXING_CHECK_PEAKS) ) { + strcat(str, "-bad"); + } + + if ( indm & INDEXING_USE_LATTICE_TYPE ) { + strcat(str, "-latt"); + } else { + strcat(str, "-nolatt"); + } + + return str; +} + + IndexingMethod *build_indexer_list(const char *str) { int n, i; @@ -263,14 +355,13 @@ IndexingMethod *build_indexer_list(const char *str) for ( i=0; iltl = ltl; mp->template = cell; - mp->indm = indm; + mp->indm = *indm; return (IndexingPrivate *)mp; } diff --git a/libcrystfel/src/mosflm.h b/libcrystfel/src/mosflm.h index 4bb26afc..a87232b6 100644 --- a/libcrystfel/src/mosflm.h +++ b/libcrystfel/src/mosflm.h @@ -40,7 +40,7 @@ extern int run_mosflm(struct image *image, IndexingPrivate *ipriv); -extern IndexingPrivate *mosflm_prepare(IndexingMethod indm, UnitCell *cell, +extern IndexingPrivate *mosflm_prepare(IndexingMethod *indm, UnitCell *cell, const char *filename, struct detector *det, struct beam_params *beam, float *ltl); diff --git a/libcrystfel/src/reax.c b/libcrystfel/src/reax.c index f454503c..3460a4f2 100644 --- a/libcrystfel/src/reax.c +++ b/libcrystfel/src/reax.c @@ -1084,7 +1084,7 @@ void reax_index(IndexingPrivate *pp, struct image *image, UnitCell *cell) } -IndexingPrivate *reax_prepare(IndexingMethod indm, UnitCell *cell, +IndexingPrivate *reax_prepare(IndexingMethod *indm, UnitCell *cell, const char *filename, struct detector *det, struct beam_params *beam, float *ltl) { @@ -1100,6 +1100,12 @@ IndexingPrivate *reax_prepare(IndexingMethod indm, UnitCell *cell, p = calloc(1, sizeof(*p)); if ( p == NULL ) return NULL; + /* Flags that ReAx knows about */ + *indm &= INDEXING_METHOD_MASK | INDEXING_CHECK_PEAKS; + + /* Flags that ReAx requires */ + *indm |= INDEXING_USE_LATTICE_TYPE; + p->angular_inc = deg2rad(1.0); /* Reserve memory, over-estimating the number of directions */ @@ -1160,7 +1166,7 @@ IndexingPrivate *reax_prepare(IndexingMethod indm, UnitCell *cell, p->r_plan = fftw_plan_dft_2d(p->cw, p->ch, p->r_fft_in, p->r_fft_out, 1, FFTW_MEASURE); - p->indm = indm; + p->indm = *indm; return (IndexingPrivate *)p; } diff --git a/libcrystfel/src/reax.h b/libcrystfel/src/reax.h index af383e29..657a2cdf 100644 --- a/libcrystfel/src/reax.h +++ b/libcrystfel/src/reax.h @@ -33,15 +33,16 @@ #include #endif +#include "index.h" #include "cell.h" #include "beam-parameters.h" #include "detector.h" #ifdef HAVE_FFTW -extern IndexingPrivate *reax_prepare(UnitCell *cell, const char *filename, - struct detector *det, - struct beam_params *beam); +extern IndexingPrivate *reax_prepare(IndexingMethod *indm, UnitCell *cell, + const char *filename, struct detector *det, + struct beam_params *beam, float *ltl); extern void reax_cleanup(IndexingPrivate *pp); @@ -49,9 +50,9 @@ extern int reax_index(struct image *image, IndexingPrivate *p); #else /* HAVE_FFTW */ -static IndexingPrivate *reax_prepare(UnitCell *cell, const char *filename, - struct detector *det, - struct beam_params *beam) +static IndexingPrivate *reax_prepare(IndexingMethod *indm, UnitCell *cell, + const char *filename, struct detector *det, + struct beam_params *beam, float *ltl) { return NULL; } diff --git a/libcrystfel/src/stream.c b/libcrystfel/src/stream.c index 842c90b9..692a860a 100644 --- a/libcrystfel/src/stream.c +++ b/libcrystfel/src/stream.c @@ -199,6 +199,7 @@ void write_chunk(Stream *st, struct image *i, struct hdfile *hdfile, fprintf(st->fh, CHUNK_START_MARKER"\n"); fprintf(st->fh, "Image filename: %s\n", i->filename); + fprintf(st->fh, "indexed_by = %s\n", indexer_str(i->indexed_by)); if ( i->det != NULL ) { -- cgit v1.2.3