aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortaw27 <taw27@bf6ca9ba-c028-0410-8290-897cf20841d1>2008-04-26 11:11:04 +0000
committertaw27 <taw27@bf6ca9ba-c028-0410-8290-897cf20841d1>2008-04-26 11:11:04 +0000
commit832f6e02a2f0b860c84b18d0db7451ccd2961441 (patch)
tree45320429a7f336e60cb547c4834e7e51c854bfc3
parente12bd3f7872cde18f096dce373002b63fa078448 (diff)
Create refinetest3d.c
git-svn-id: svn://cook.msm.cam.ac.uk:745/diff-tomo/dtr@279 bf6ca9ba-c028-0410-8290-897cf20841d1
-rw-r--r--src/refinetest2d.c12
-rw-r--r--src/refinetest3d.c133
2 files changed, 139 insertions, 6 deletions
diff --git a/src/refinetest2d.c b/src/refinetest2d.c
index 870ac68..5df7f19 100644
--- a/src/refinetest2d.c
+++ b/src/refinetest2d.c
@@ -1,7 +1,7 @@
/*
- * refinectx.c
+ * refinetest2d.c
*
- * Unit test for refinement procedure
+ * Unit test for refinement procedure in 2D
*
* (c) 2007-2008 Thomas White <taw27@cam.ac.uk>
*
@@ -73,19 +73,19 @@ int main(int argc, char *argv[]) {
fail = 0;
if ( fabs(ctx->cell->a.x - cell_real->a.x) > 0.01e9 ) {
- fprintf(stderr, "refinetest: ax not determined correctly\n");
+ fprintf(stderr, "refinetest2d: ax not determined correctly\n");
fail = 1;
}
if ( fabs(ctx->cell->a.y - cell_real->a.y) > 0.01e9 ) {
- fprintf(stderr, "refinetest: ay not determined correctly\n");
+ fprintf(stderr, "refinetest2d: ay not determined correctly\n");
fail = 1;
}
if ( fabs(ctx->cell->b.x - cell_real->b.x) > 0.01e9 ) {
- fprintf(stderr, "refinetest: bx not determined correctly\n");
+ fprintf(stderr, "refinetest2d: bx not determined correctly\n");
fail = 1;
}
if ( fabs(ctx->cell->b.y - cell_real->b.y) > 0.01e9 ) {
- fprintf(stderr, "refinetest: by not determined correctly\n");
+ fprintf(stderr, "refinetest2d: by not determined correctly\n");
fail = 1;
}
/* az, bz, cx, cy and cz are unconstrained hence will 'float' to meaningless values.
diff --git a/src/refinetest3d.c b/src/refinetest3d.c
new file mode 100644
index 0000000..5f6fd7e
--- /dev/null
+++ b/src/refinetest3d.c
@@ -0,0 +1,133 @@
+/*
+ * refinetest3d.c
+ *
+ * Unit test for refinement procedure in 3D
+ *
+ * (c) 2007-2008 Thomas White <taw27@cam.ac.uk>
+ *
+ * dtr - Diffraction Tomography Reconstruction
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <stdlib.h>
+#include <math.h>
+
+#include "basis.h"
+#include "reflections.h"
+#include "image.h"
+#include "reproject.h"
+#include "refine.h"
+#include "utils.h"
+#include "mapping.h"
+#include "control.h"
+#include "displaywindow.h"
+
+int main(int argc, char *argv[]) {
+
+ ControlContext *ctx;
+ ReflectionList *reflections_real;
+ Basis *cell_real;
+ int fail;
+
+ ctx = control_ctx_new();
+ ctx->omega = deg2rad(0.0);
+ ctx->lambda = lambda(300.0e3); /* 300 keV */
+ ctx->fmode = FORMULATION_PIXELSIZE;
+ ctx->x_centre = 256;
+ ctx->y_centre = 256;
+ ctx->pixel_size = 5e7;
+ image_add(ctx->images, NULL, 512, 512, deg2rad(0.0), ctx);
+ ctx->images->images[0].features = image_feature_list_new();
+ image_add(ctx->images, NULL, 512, 512, deg2rad(90.0), ctx);
+ ctx->images->images[1].features = image_feature_list_new();
+
+ /* Fudge to avoid horrifying pointer-related death */
+ ctx->dw = malloc(sizeof(DisplayWindow));
+ ctx->dw->cur_image = 0;
+
+ /* The "true" cell */
+ cell_real = malloc(sizeof(Basis));
+ cell_real->a.x = 5.0e9; cell_real->a.y = 0.0e9; cell_real->a.z = 0.0e9;
+ cell_real->b.x = 0.0e9; cell_real->b.y = 5.0e9; cell_real->b.z = 0.0e9;
+ cell_real->c.x = 0.0e9; cell_real->c.y = 0.0e9; cell_real->c.z = 5.0e9;
+ /* The "real" reflections */
+ reflections_real = reflection_list_from_cell(cell_real);
+ ctx->images->images[0].features = reproject_get_reflections(&ctx->images->images[0], reflections_real);
+ ctx->images->images[1].features = reproject_get_reflections(&ctx->images->images[1], reflections_real);
+// printf("RT: %i test features generated.\n", ctx->images->images[0].features->n_features);
+
+ /* The "model" cell to be refined */
+ ctx->cell = malloc(sizeof(Basis));
+ ctx->cell->a.x = 5.2e9; ctx->cell->a.y = 0.1e9; ctx->cell->a.z = 0.0e9;
+ ctx->cell->b.x = 0.2e9; ctx->cell->b.y = 4.8e9; ctx->cell->b.z = 0.0e9;
+ ctx->cell->c.x = 0.0e9; ctx->cell->c.y = 0.0e9; ctx->cell->c.z = 5.0e9;
+ ctx->cell_lattice = reflection_list_from_cell(ctx->cell);
+ ctx->images->images[0].rflist = reproject_get_reflections(&ctx->images->images[0], ctx->cell_lattice);
+ reproject_partner_features(ctx->images->images[0].rflist, &ctx->images->images[0]);
+ ctx->images->images[1].rflist = reproject_get_reflections(&ctx->images->images[1], ctx->cell_lattice);
+ reproject_partner_features(ctx->images->images[1].rflist, &ctx->images->images[1]);
+
+ refine_do_cell(ctx);
+ image_feature_list_free(ctx->images->images[0].rflist);
+ image_feature_list_free(ctx->images->images[1].rflist);
+
+ fail = 0;
+ if ( fabs(ctx->cell->a.x - cell_real->a.x) > 0.01e9 ) {
+ fprintf(stderr, "refinetest3d: ax not determined correctly\n");
+ fail = 1;
+ }
+ if ( fabs(ctx->cell->a.y - cell_real->a.y) > 0.01e9 ) {
+ fprintf(stderr, "refinetest3d: ay not determined correctly\n");
+ fail = 1;
+ }
+ if ( fabs(ctx->cell->a.z - cell_real->a.z) > 0.01e9 ) {
+ fprintf(stderr, "refinetest3d: az not determined correctly\n");
+ fail = 1;
+ }
+ if ( fabs(ctx->cell->b.x - cell_real->b.x) > 0.01e9 ) {
+ fprintf(stderr, "refinetest3d: bx not determined correctly\n");
+ fail = 1;
+ }
+ if ( fabs(ctx->cell->b.y - cell_real->b.y) > 0.01e9 ) {
+ fprintf(stderr, "refinetest3d: by not determined correctly\n");
+ fail = 1;
+ }
+ if ( fabs(ctx->cell->b.z - cell_real->b.z) > 0.01e9 ) {
+ fprintf(stderr, "refinetest3d: bz not determined correctly\n");
+ fail = 1;
+ }
+ if ( fabs(ctx->cell->c.x - cell_real->c.x) > 0.01e9 ) {
+ fprintf(stderr, "refinetest3d: cx not determined correctly\n");
+ fail = 1;
+ }
+ if ( fabs(ctx->cell->c.y - cell_real->c.y) > 0.01e9 ) {
+ fprintf(stderr, "refinetest3d: cy not determined correctly\n");
+ fail = 1;
+ }
+ if ( fabs(ctx->cell->c.z - cell_real->c.z) > 0.01e9 ) {
+ fprintf(stderr, "refinetest3d: cz not determined correctly\n");
+ fail = 1;
+ }
+
+ free(ctx);
+
+ if ( fail ) return 1;
+
+ return 0;
+
+}
+
+/* Dummy function stubs */
+#include "gtk-valuegraph.h"
+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) { };
+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) { };
+