From 9c14e5f69d55f20ea41f36c3da3f6ee9adc1678a Mon Sep 17 00:00:00 2001 From: taw27 Date: Fri, 23 Nov 2007 14:24:39 +0000 Subject: Add random sequencer git-svn-id: svn://cook.msm.cam.ac.uk:745/diff-tomo/dtr@211 bf6ca9ba-c028-0410-8290-897cf20841d1 --- src/refine.c | 69 +++++++++++++----------------------------------------------- 1 file changed, 15 insertions(+), 54 deletions(-) diff --git a/src/refine.c b/src/refine.c index 4ae7ec8..e4ee409 100644 --- a/src/refine.c +++ b/src/refine.c @@ -262,10 +262,14 @@ static int refine_sequence_random(ControlContext *ctx, double *fit, double *warp int nf; ImageRecord *image; ImageFeature *feature; + Basis *cell; + Basis cd; + RefinementIndex shared; /* Ensure lattice is up to date */ reproject_lattice_changed(ctx); - ctx->images->images[i].rflist = NULL; /* Invalidate reprojection for this image - it's wrong */ + + cell = ctx->cell; /* Select a random feature from a random image */ ni = ((float)ctx->images->n_images * random()) / RAND_MAX; @@ -273,7 +277,15 @@ static int refine_sequence_random(ControlContext *ctx, double *fit, double *warp nf = ((float)image->features->n_features * random()) / RAND_MAX; feature = &image->features->features[nf]; + image->rflist = reproject_get_reflections(image, ctx->cell_lattice); + + if ( !feature->partner ) continue; + cd = refine_cell_delta(cell, feature, &shared); + + cell->a.x += cd.a.x; cell->a.y += cd.a.y; cell->a.z += cd.a.z; + cell->b.x += cd.b.x; cell->b.y += cd.b.y; cell->b.z += cd.b.z; + cell->c.x += cd.c.x; cell->c.y += cd.c.y; cell->c.z += cd.c.z; } @@ -286,19 +298,8 @@ static int refine_sequence_random(ControlContext *ctx, double *fit, double *warp static gint refine_random_sequence(GtkWidget *widget, ControlContext *ctx) { - double omega_offs; - GtkWidget *window_fit; - GtkWidget *graph_fit; - double *fit_vals; - GtkWidget *window_warp; - GtkWidget *graph_warp; - double *warp_vals; - size_t idx; ImageDisplay *id; - - fit_vals = malloc(401*sizeof(double)); - warp_vals = malloc(401*sizeof(double)); - idx = 0; + double fit, warp; if ( !ctx->cell ) { displaywindow_error("No reciprocal unit cell has been found.", ctx->dw); @@ -309,51 +310,11 @@ static gint refine_random_sequence(GtkWidget *widget, ControlContext *ctx) { id = ctx->reproject_id; ctx->reproject_id = NULL; - for ( omega_offs=-2.0; omega_offs<=2.0; omega_offs+=0.01 ) { - - double fit, warp; - int i; - Basis cell_copy; - - memcpy(&cell_copy, ctx->cell, sizeof(Basis)); - for ( i=0; iimages->n_images; i++ ) { - ctx->images->images[i].omega += omega_offs; - } - - if ( refine_sequence_random(ctx, &fit, &warp) ) { - printf("RF: Sequencer run failed\n"); - return 0; - } - printf("RF: omega_offs=%f, fit=%f, warp=%f\n", omega_offs, fit, warp); - fit_vals[idx] = fit; - warp_vals[idx++] = warp; - - for ( i=0; iimages->n_images; i++ ) { - ctx->images->images[i].omega -= omega_offs; - } - memcpy(ctx->cell, &cell_copy, sizeof(Basis)); - - } + refine_sequence_random(ctx, &fit, &warp); ctx->reproject_id = id; reproject_lattice_changed(ctx); - window_fit = gtk_window_new(GTK_WINDOW_TOPLEVEL); - gtk_window_set_default_size(GTK_WINDOW(window_fit), 640, 256); - gtk_window_set_title(GTK_WINDOW(window_fit), "Omega-Search Graph: Fit"); - graph_fit = gtk_value_graph_new(); - gtk_value_graph_set_data(GTK_VALUE_GRAPH(graph_fit), fit_vals, idx); - gtk_container_add(GTK_CONTAINER(window_fit), graph_fit); - gtk_widget_show_all(window_fit); - - window_warp = gtk_window_new(GTK_WINDOW_TOPLEVEL); - gtk_window_set_default_size(GTK_WINDOW(window_warp), 640, 256); - gtk_window_set_title(GTK_WINDOW(window_warp), "Omega-Search Graph: Warp"); - graph_warp = gtk_value_graph_new(); - gtk_value_graph_set_data(GTK_VALUE_GRAPH(graph_warp), warp_vals, idx); - gtk_container_add(GTK_CONTAINER(window_warp), graph_warp); - gtk_widget_show_all(window_warp); - return 0; } -- cgit v1.2.3