From bc4edcdaeae690a1d0d848e53b4f61286a1298ef Mon Sep 17 00:00:00 2001 From: Thomas White Date: Wed, 3 Mar 2010 15:39:15 +0100 Subject: Put many debug messages behind a --verbose option --- src/cell.c | 37 ++++++++++++++++++++++++++----------- src/cell.h | 2 +- src/index.c | 7 ++++--- src/index.h | 2 +- src/indexamajig.c | 7 ++++++- 5 files changed, 38 insertions(+), 17 deletions(-) diff --git a/src/cell.c b/src/cell.c index c6d64af0..889f9576 100644 --- a/src/cell.c +++ b/src/cell.c @@ -383,7 +383,7 @@ static int same_vector(struct cvec a, struct cvec b) /* Attempt to make 'cell' fit into 'template' somehow */ -UnitCell *match_cell(UnitCell *cell, UnitCell *template) +UnitCell *match_cell(UnitCell *cell, UnitCell *template, int verbose) { signed int n1l, n2l, n3l; double asx, asy, asz; @@ -399,9 +399,13 @@ UnitCell *match_cell(UnitCell *cell, UnitCell *template) float angtol = deg2rad(5.0); UnitCell *new_cell = NULL; - STATUS("Matching with this model cell: ----------------------------\n"); - cell_print(template); - STATUS("-----------------------------------------------------------\n"); + if ( verbose ) { + STATUS("Matching with this model cell: " + "----------------------------\n"); + cell_print(template); + STATUS("-------------------------------" + "----------------------------\n"); + } cell_get_reciprocal(template, &asx, &asy, &asz, &bsx, &bsy, &bsz, @@ -414,8 +418,11 @@ UnitCell *match_cell(UnitCell *cell, UnitCell *template) angles[0] = angle_between(bsx, bsy, bsz, csx, csy, csz); angles[1] = angle_between(asx, asy, asz, csx, csy, csz); angles[2] = angle_between(asx, asy, asz, bsx, bsy, bsz); - STATUS("Looking for %f %f %f\n", rad2deg(angles[0]), rad2deg(angles[1]), - rad2deg(angles[2])); + if ( verbose ) { + STATUS("Looking for %f %f %f\n", rad2deg(angles[0]), + rad2deg(angles[1]), + rad2deg(angles[2])); + } cand[0] = malloc(MAX_CAND*sizeof(struct cvec)); cand[1] = malloc(MAX_CAND*sizeof(struct cvec)); @@ -477,7 +484,9 @@ UnitCell *match_cell(UnitCell *cell, UnitCell *template) } } - STATUS("Candidates: %i %i %i\n", ncand[0], ncand[1], ncand[2]); + if ( verbose ) { + STATUS("Candidates: %i %i %i\n", ncand[0], ncand[1], ncand[2]); + } for ( i=0; i angtol ) continue; - STATUS("Matched %i-%i (0-1 %f deg)\n", i, j, rad2deg(ang)); - + if ( verbose ) { + STATUS("Matched %i-%i (0-1 %f deg)\n", i, j, + rad2deg(ang)); + } for ( k=0; k angtol ) continue; - STATUS("0-2 %f\n", rad2deg(ang)); + if ( verbose ) { + STATUS("0-2 %f\n", rad2deg(ang)); + } /* Finally, the angle between the current candidate for * axis 1 and the kth candidate for axis 2 */ @@ -519,7 +532,9 @@ UnitCell *match_cell(UnitCell *cell, UnitCell *template) cand[2][k].vec.v, cand[2][k].vec.w); /* ... it should be angle 0 ... */ - STATUS("1-2 %f\n", rad2deg(ang)); + if ( verbose ) { + STATUS("1-2 %f\n", rad2deg(ang)); + } if ( fabs(ang - angles[0]) > angtol ) continue; new_cell = cell_new_from_axes(cand[0][i].vec, diff --git a/src/cell.h b/src/cell.h index db5cab0b..4c74b283 100644 --- a/src/cell.h +++ b/src/cell.h @@ -74,6 +74,6 @@ extern double resolution(UnitCell *cell, extern void cell_print(UnitCell *cell); -extern UnitCell *match_cell(UnitCell *cell, UnitCell *template); +extern UnitCell *match_cell(UnitCell *cell, UnitCell *template, int verbose); #endif /* CELL_H */ diff --git a/src/index.c b/src/index.c index 865715c2..470d9e4c 100644 --- a/src/index.c +++ b/src/index.c @@ -60,7 +60,8 @@ static void write_drx(struct image *image) } -void index_pattern(struct image *image, IndexingMethod indm, int no_match) +void index_pattern(struct image *image, IndexingMethod indm, int no_match, + int verbose) { int i; UnitCell *new_cell = NULL; @@ -92,7 +93,7 @@ void index_pattern(struct image *image, IndexingMethod indm, int no_match) if ( image->indexed_cell == NULL ) { STATUS("No cell found.\n"); return; - } else { + } else if ( verbose ) { STATUS("--------------------\n"); STATUS("The indexed cell (before matching):\n"); cell_print(image->indexed_cell); @@ -101,7 +102,7 @@ void index_pattern(struct image *image, IndexingMethod indm, int no_match) if ( !no_match ) { new_cell = match_cell(image->indexed_cell, - image->molecule->cell); + image->molecule->cell, verbose); free(image->indexed_cell); image->indexed_cell = new_cell; } diff --git a/src/index.h b/src/index.h index 429e5ec8..26ce1c44 100644 --- a/src/index.h +++ b/src/index.h @@ -26,6 +26,6 @@ typedef enum { extern void index_pattern(struct image *image, IndexingMethod indm, - int no_match); + int no_match, int verbose); #endif /* INDEX_H */ diff --git a/src/indexamajig.c b/src/indexamajig.c index 22bc2ea4..e42991c4 100644 --- a/src/indexamajig.c +++ b/src/indexamajig.c @@ -47,6 +47,8 @@ static void show_help(const char *s) " --indexing= Use 'method' for indexing. Choose from:\n" " none : no indexing\n" " dirax : invoke DirAx\n" +"\n" +" --verbose Be verbose about indexing.\n" " --write-drx Write 'xfel.drx' for visualisation of reciprocal\n" " space. Implied by any indexing method other than\n" " 'none'.\n" @@ -81,6 +83,7 @@ int main(int argc, char *argv[]) int config_clean = 0; int config_nomatch = 0; int config_gpu = 0; + int config_verbose = 0; IndexingMethod indm; char *indm_str = NULL; @@ -97,6 +100,7 @@ int main(int argc, char *argv[]) {"simulate", 0, &config_simulate, 1}, {"clean-image", 0, &config_clean, 1}, {"no-match", 0, &config_nomatch, 1}, + {"verbose", 0, &config_verbose, 1}, {0, 0, NULL, 0} }; @@ -210,7 +214,8 @@ int main(int argc, char *argv[]) /* Calculate orientation matrix (by magic) */ if ( config_writedrx || (indm != INDEXING_NONE) ) { - index_pattern(&image, indm, config_nomatch); + index_pattern(&image, indm, config_nomatch, + config_verbose); } /* No cell at this point? Then we're done. */ -- cgit v1.2.3