Commit bc4edcda authored by Thomas White's avatar Thomas White
Browse files

Put many debug messages behind a --verbose option

parent 851c205e
......@@ -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<ncand[0]; i++ ) {
for ( j=0; j<ncand[1]; j++ ) {
......@@ -495,8 +504,10 @@ UnitCell *match_cell(UnitCell *cell, UnitCell *template)
/* Angle between axes 0 and 1 should be angle 2 */
if ( fabs(ang - angles[2]) > 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<ncand[2]; k++ ) {
if ( same_vector(cand[1][j], cand[2][k]) ) continue;
......@@ -510,7 +521,9 @@ UnitCell *match_cell(UnitCell *cell, UnitCell *template)
/* ... it should be angle 1 ... */
if ( fabs(ang - angles[1]) > 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,
......
......@@ -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 */
......@@ -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;
}
......
......@@ -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 */
......@@ -47,6 +47,8 @@ static void show_help(const char *s)
" --indexing=<method> 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. */
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment