diff options
author | Thomas White <taw@physics.org> | 2017-09-11 13:32:19 +0200 |
---|---|---|
committer | Thomas White <taw@physics.org> | 2017-09-15 14:33:12 +0200 |
commit | 9e1d57633c8e788acd9a966857f112386aad52f1 (patch) | |
tree | 021fdf6accdbe001cc10de1c56367bcf5b52c43e /libcrystfel | |
parent | 60c48f3876b0d3c30bf729ce691dbd3f56665c4c (diff) |
Factorise cell parameter check
Diffstat (limited to 'libcrystfel')
-rw-r--r-- | libcrystfel/src/index.c | 75 |
1 files changed, 48 insertions, 27 deletions
diff --git a/libcrystfel/src/index.c b/libcrystfel/src/index.c index e7ae7a37..d8810716 100644 --- a/libcrystfel/src/index.c +++ b/libcrystfel/src/index.c @@ -356,6 +356,36 @@ void map_all_peaks(struct image *image) } +static int check_cell(IndexingFlags flags, Crystal *cr, UnitCell *target, + float *tolerance) +{ + if ( (flags & INDEXING_CHECK_CELL_COMBINATIONS) + || (flags & INDEXING_CHECK_CELL_AXES) ) + { + UnitCell *out; + int reduce; + + if ( flags & INDEXING_CHECK_CELL_COMBINATIONS ) + { + reduce = 1; + } else { + reduce = 0; + } + + out = match_cell(crystal_get_cell(cr), + target, 0, tolerance, reduce); + + if ( out == NULL ) { + return 1; + } + + cell_free(crystal_get_cell(cr)); + crystal_set_cell(cr, out); + } + return 0; +} + + /* Return non-zero for "success" */ static int try_indexer(struct image *image, IndexingMethod indm, IndexingPrivate *ipriv, void *mpriv) @@ -416,6 +446,18 @@ static int try_indexer(struct image *image, IndexingMethod indm, crystal_set_profile_radius(cr, 0.02e9); crystal_set_mosaicity(cr, 0.0); + assert( !((ipriv->flags & INDEXING_CHECK_CELL_COMBINATIONS) + && (ipriv->flags & INDEXING_CHECK_CELL_AXES)) ); + + /* Pre-refinement unit cell check if requested */ + if ( check_cell(ipriv->flags, cr, ipriv->target_cell, + ipriv->tolerance) ) + { + crystal_set_user_flag(cr, 1); + n_bad++; + continue; + } + /* Prediction refinement if requested */ if ( ipriv->flags & INDEXING_REFINE ) { @@ -426,34 +468,13 @@ static int try_indexer(struct image *image, IndexingMethod indm, } } - /* Unit cell check if requested */ - assert( !((ipriv->flags & INDEXING_CHECK_CELL_COMBINATIONS) - && (ipriv->flags & INDEXING_CHECK_CELL_AXES)) ); - if ( (ipriv->flags & INDEXING_CHECK_CELL_COMBINATIONS) - || (ipriv->flags & INDEXING_CHECK_CELL_AXES) ) + /* After refinement unit cell check if requested */ + if ( check_cell(ipriv->flags, cr, ipriv->target_cell, + ipriv->tolerance) ) { - UnitCell *out; - int reduce; - - if ( ipriv->flags & INDEXING_CHECK_CELL_COMBINATIONS ) - { - reduce = 1; - } else { - reduce = 0; - } - - out = match_cell(crystal_get_cell(cr), - ipriv->target_cell, 0, - ipriv->tolerance, reduce); - - if ( out == NULL ) { - crystal_set_user_flag(cr, 1); - n_bad++; - continue; - } - - cell_free(crystal_get_cell(cr)); - crystal_set_cell(cr, out); + crystal_set_user_flag(cr, 1); + n_bad++; + continue; } /* Don't do similarity check if this crystal is bad */ |