diff options
author | Thomas White <taw27@cam.ac.uk> | 2008-10-03 16:54:32 +0100 |
---|---|---|
committer | Thomas White <taw27@cam.ac.uk> | 2008-10-03 16:54:32 +0100 |
commit | 3b34b33302b1bb16b121d6b19a1a5aae34fc9cc7 (patch) | |
tree | 6588c5e7508f04604500fdddfef7778c2221801d | |
parent | b488d74ad965f06a2034a89fc04df64e87864462 (diff) |
Put basic refinement debugging messages in the Messages tab
-rw-r--r-- | src/displaywindow.c | 2 | ||||
-rw-r--r-- | src/displaywindow.h | 1 | ||||
-rw-r--r-- | src/refine.c | 88 | ||||
-rw-r--r-- | src/refinetest2d.c | 1 | ||||
-rw-r--r-- | src/refinetest3d1.c | 1 | ||||
-rw-r--r-- | src/refinetest3d2.c | 1 | ||||
-rw-r--r-- | src/refinetest3d3.c | 1 |
7 files changed, 50 insertions, 45 deletions
diff --git a/src/displaywindow.c b/src/displaywindow.c index 917ff8c..7abc640 100644 --- a/src/displaywindow.c +++ b/src/displaywindow.c @@ -582,7 +582,7 @@ static void displaywindow_scrolltoend(DisplayWindow *dw) { } -static void displaywindow_message(DisplayWindow *dw, const char *text) { +void displaywindow_message(DisplayWindow *dw, const char *text) { GtkTextBuffer *buffer; GtkTextIter iter; diff --git a/src/displaywindow.h b/src/displaywindow.h index a69e807..8330f7e 100644 --- a/src/displaywindow.h +++ b/src/displaywindow.h @@ -100,6 +100,7 @@ extern void displaywindow_update(DisplayWindow *dw); extern void displaywindow_update_dirax(ControlContext *ctx, DisplayWindow *dw); extern void displaywindow_error(const char *msg, DisplayWindow *dw); extern void displaywindow_enable_cell_functions(DisplayWindow *dw, gboolean g); +extern void displaywindow_message(DisplayWindow *dw, const char *text); #endif /* DISPLAYWINDOW_H */ diff --git a/src/refine.c b/src/refine.c index a264ad6..e3bf310 100644 --- a/src/refine.c +++ b/src/refine.c @@ -36,14 +36,8 @@ #define NUM_PARAMS 9 /* Refine debug */ -#define REFINE_DEBUG 1 #define REFINE_DEBUG_MORE 0 -/* REFINE_DEBUG_MORE depends on REFINE_DEBUG */ -#if !REFINE_DEBUG && REFINE_DEBUG_MORE -#error You must enable REFINE_DEBUG to use REFINE_DEBUG_MORE -#endif - #define DELTA (0.0001e9) typedef struct { @@ -59,6 +53,20 @@ typedef struct { } Deviation; +static void refine_printf(DisplayWindow *dw, char *fmt, ...) { + + va_list ap; + char tmp[1024]; + + va_start(ap, fmt); + vsnprintf(tmp, 1023, fmt, ap); + va_end(ap); + + printf("%s", tmp); + displaywindow_message(dw, tmp); + +} + void refine_do_sequence(ControlContext *ctx) { double omega_offs; @@ -88,8 +96,8 @@ void refine_do_sequence(ControlContext *ctx) { reproject_lattice_changed(ctx); fit = refine_do_cell(ctx); - printf("RF: omega_offs=%f deg, fit=%f nm^-1\n", rad2deg(omega_offs), - fit/DISPFACTOR); + refine_printf(ctx->dw, " omega_offs=%f deg, fit=%f nm^-1\n", + rad2deg(omega_offs), fit/DISPFACTOR); fit_vals[idx++] = fit; if ( fit < fit_best ) { fit_best = fit; @@ -112,7 +120,8 @@ void refine_do_sequence(ControlContext *ctx) { gtk_widget_show_all(window_fit); /* Perform final refinement */ - printf("Best omega offset = %f deg (%f nm^-1)\n", rad2deg(omega_offs_best), fit_best/DISPFACTOR); + refine_printf(ctx->dw, "Best omega offset = %f deg (%f nm^-1)\n", + rad2deg(omega_offs_best), fit_best/DISPFACTOR); for ( j=0; j<ctx->images->n_images; j++ ) { ctx->images->images[j].omega += omega_offs_best; } @@ -188,11 +197,14 @@ static void refine_cell_delta(Basis *devcell_try, int comp) { } -static void refine_show_cell(Basis cell) { +static void refine_show_cell(DisplayWindow *dw, Basis cell) { - printf("a: %+10.8f %+10.8f %+10.8f\n", cell.a.x/DISPFACTOR, cell.a.y/DISPFACTOR, cell.a.z/DISPFACTOR); - printf("b: %+10.8f %+10.8f %+10.8f\n", cell.b.x/DISPFACTOR, cell.b.y/DISPFACTOR, cell.b.z/DISPFACTOR); - printf("c: %+10.8f %+10.8f %+10.8f\n", cell.c.x/DISPFACTOR, cell.c.y/DISPFACTOR, cell.c.z/DISPFACTOR); + refine_printf(dw, "a: %+10.8f %+10.8f %+10.8f\n", + cell.a.x/DISPFACTOR, cell.a.y/DISPFACTOR, cell.a.z/DISPFACTOR); + refine_printf(dw, "b: %+10.8f %+10.8f %+10.8f\n", + cell.b.x/DISPFACTOR, cell.b.y/DISPFACTOR, cell.b.z/DISPFACTOR); + refine_printf(dw, "c: %+10.8f %+10.8f %+10.8f\n", + cell.c.x/DISPFACTOR, cell.c.y/DISPFACTOR, cell.c.z/DISPFACTOR); } @@ -295,14 +307,10 @@ double refine_do_cell(ControlContext *ctx) { if ( ctx->images->images[i].rflist->features[j].partner != NULL ) nf++; } - #if REFINE_DEBUG - printf("%i features from image %i\n", nf, i); - #endif /* REFINE_DEBUG */ + refine_printf(ctx->dw, "%i features from image %i\n", nf, i); } - #if REFINE_DEBUG - printf("RF: There are %i partnered features in total\n", nf); - #endif /* REFINE_DEBUG */ + refine_printf(ctx->dw, "There are %i partnered features in total\n", nf); /* Initialise the 'deviation table' */ d = malloc(nf*sizeof(Deviation)); @@ -330,10 +338,8 @@ double refine_do_cell(ControlContext *ctx) { /* Determine the difference vector */ dix = rf->partner->x - rf->x; diy = rf->partner->y - rf->y; - #if REFINE_DEBUG - printf("RF: Image %3i, feature %3i: %3i %3i %3i dev = %+9.5f %+9.5f px ", + refine_printf(ctx->dw, "%3i: %3i: %3i %3i %3i dev %+9.5f %+9.5f px ", i, j, d[f].h, d[f].k, d[f].l, dix, diy); - #endif /* REFINE_DEBUG */ old_x = rf->partner->x; old_y = rf->partner->y; @@ -342,10 +348,9 @@ double refine_do_cell(ControlContext *ctx) { mapping_scale(rf->partner, &dx, &dy); rf->partner->x = old_x; rf->partner->y = old_y; - #if REFINE_DEBUG double mod = sqrt(dx*dx + dy*dy)/DISPFACTOR; - printf("=> %+10.5f %+10.5f nm^-1 (length %10.5f nm^1)\n", dx/DISPFACTOR, dy/DISPFACTOR, mod); - #endif /* REFINE_DEBUG */ + refine_printf(ctx->dw, "= %+10.5f %+10.5f nm^-1 (length %7.5f nm^1)\n", + dx/DISPFACTOR, dy/DISPFACTOR, mod); d[f].dx = dx; d[f].dy = dy; @@ -371,12 +376,9 @@ double refine_do_cell(ControlContext *ctx) { devcell->a.y = 0.0e9; devcell->b.y = 0.0e9; devcell->c.y = 0.0e9; devcell->a.z = 0.0e9; devcell->b.z = 0.0e9; devcell->c.z = 0.0e9; mean_dev = refine_mean_dev(d, nf, devcell, 0); - #if REFINE_DEBUG - printf("Initial mean deviation: %13.8f nm^1\n", mean_dev/DISPFACTOR); - #endif /* REFINE_DEBUG */ + refine_printf(ctx->dw, "Initial mean deviation: %13.8f nm^1\n", mean_dev/DISPFACTOR); /* Test confidence */ - printf("Testing confidence...\n"); conf = refine_test_confidence(d, nf); /* Determine direction of steepest gradient */ @@ -389,13 +391,13 @@ double refine_do_cell(ControlContext *ctx) { #if REFINE_DEBUG_MORE refine_mean_dev(d, nf, devcell, 1); - printf("Iteration %i starts at dev %14.12f\n", it, mean_dev/DISPFACTOR); - printf("Current dev cell:\n"); - printf("a = %8.5f %8.5f %8.5f\n", + printf(ctx->dw, "Iteration %i starts at dev %14.12f\n", it, mean_dev/DISPFACTOR); + printf(ctx->dw, "Current dev cell:\n"); + printf(ctx->dw, "a = %8.5f %8.5f %8.5f\n", devcell->a.x/DISPFACTOR, devcell->a.y/DISPFACTOR, devcell->a.z/DISPFACTOR); - printf("b = %8.5f %8.5f %8.5f\n", + printf(ctx->dw, "b = %8.5f %8.5f %8.5f\n", devcell->b.x/DISPFACTOR, devcell->b.y/DISPFACTOR, devcell->b.z/DISPFACTOR); - printf("c = %8.5f %8.5f %8.5f\n", + printf(ctx->dw, "c = %8.5f %8.5f %8.5f\n", devcell->c.x/DISPFACTOR, devcell->c.y/DISPFACTOR, devcell->c.z/DISPFACTOR); #endif /* REFINE_DEBUG_MORE */ @@ -421,21 +423,19 @@ double refine_do_cell(ControlContext *ctx) { } else { break; } - #if REFINE_DEBUG if ( !(it % 1000) ) { - printf("After %5i iterations: mean dev = %13.8f nm^1\n", it, mean_dev/DISPFACTOR); + refine_printf(ctx->dw, "After %5i iterations: mean dev = %13.8f nm^1\n", it, + mean_dev/DISPFACTOR); } - #endif /* REFINE_DEBUG */ + } free(devcell_try); free(devcell_try_best); - #if REFINE_DEBUG - printf("Final mean dev (%5i iterations) = %13.8f nm^1\n", it, mean_dev/DISPFACTOR); - printf("Final cell deviation:\n"); - refine_show_cell(*devcell); - printf("Confidence:\n"); - refine_show_cell(conf); - #endif /* REFINE_DEBUG */ + refine_printf(ctx->dw, "Final mean dev (%5i iterations) = %13.8f nm^1\n", it, mean_dev/DISPFACTOR); + refine_printf(ctx->dw, "Final cell deviation:\n"); + refine_show_cell(ctx->dw, *devcell); + refine_printf(ctx->dw, "Confidence:\n"); + refine_show_cell(ctx->dw, conf); /* Apply the final values to the cell */ conf_threshold = 2.5; diff --git a/src/refinetest2d.c b/src/refinetest2d.c index 1c30348..a959bf0 100644 --- a/src/refinetest2d.c +++ b/src/refinetest2d.c @@ -157,6 +157,7 @@ void displaywindow_update_imagestack(DisplayWindow *dw) { }; void displaywindow_enable_cell_functions(DisplayWindow *dw, gboolean g) { }; void displaywindow_update(DisplayWindow *dw) { }; void displaywindow_error(const char *msg, DisplayWindow *dw) { }; +void displaywindow_message(DisplayWindow *dw, const char *text) { }; guint gtk_value_graph_get_type() { return 0; }; GtkWidget *gtk_value_graph_new() { return NULL; }; void gtk_value_graph_set_data(GtkValueGraph *vg, double *data, unsigned int n) { }; diff --git a/src/refinetest3d1.c b/src/refinetest3d1.c index cd8cc84..4a87fd8 100644 --- a/src/refinetest3d1.c +++ b/src/refinetest3d1.c @@ -173,6 +173,7 @@ void displaywindow_update_imagestack(DisplayWindow *dw) { }; void displaywindow_enable_cell_functions(DisplayWindow *dw, gboolean g) { }; void displaywindow_update(DisplayWindow *dw) { }; void displaywindow_error(const char *msg, DisplayWindow *dw) { }; +void displaywindow_message(DisplayWindow *dw, const char *text) { }; guint gtk_value_graph_get_type() { return 0; }; GtkWidget *gtk_value_graph_new() { return NULL; }; void gtk_value_graph_set_data(GtkValueGraph *vg, double *data, unsigned int n) { }; diff --git a/src/refinetest3d2.c b/src/refinetest3d2.c index 38ea72e..7733106 100644 --- a/src/refinetest3d2.c +++ b/src/refinetest3d2.c @@ -185,6 +185,7 @@ void displaywindow_update_imagestack(DisplayWindow *dw) { }; void displaywindow_enable_cell_functions(DisplayWindow *dw, gboolean g) { }; void displaywindow_update(DisplayWindow *dw) { }; void displaywindow_error(const char *msg, DisplayWindow *dw) { }; +void displaywindow_message(DisplayWindow *dw, const char *text) { }; guint gtk_value_graph_get_type() { return 0; }; GtkWidget *gtk_value_graph_new() { return NULL; }; void gtk_value_graph_set_data(GtkValueGraph *vg, double *data, unsigned int n) { }; diff --git a/src/refinetest3d3.c b/src/refinetest3d3.c index de8a792..5850b09 100644 --- a/src/refinetest3d3.c +++ b/src/refinetest3d3.c @@ -181,6 +181,7 @@ void displaywindow_update_imagestack(DisplayWindow *dw) { }; void displaywindow_enable_cell_functions(DisplayWindow *dw, gboolean g) { }; void displaywindow_update(DisplayWindow *dw) { }; void displaywindow_error(const char *msg, DisplayWindow *dw) { }; +void displaywindow_message(DisplayWindow *dw, const char *text) { }; guint gtk_value_graph_get_type() { return 0; }; GtkWidget *gtk_value_graph_new() { return NULL; }; void gtk_value_graph_set_data(GtkValueGraph *vg, double *data, unsigned int n) { }; |