From dc76f055cefcfc70f97f4c5520e65eec7e662fcf Mon Sep 17 00:00:00 2001 From: Thomas White Date: Thu, 19 Mar 2009 12:07:53 +0000 Subject: Send a random selection of reflections to DirAx if more than 1,000 are present --- src/dirax.c | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 62 insertions(+), 5 deletions(-) diff --git a/src/dirax.c b/src/dirax.c index 2924380..7c79412 100644 --- a/src/dirax.c +++ b/src/dirax.c @@ -365,12 +365,59 @@ void dirax_rerun(ControlContext *ctx) ctx->dirax_step = 7; } + +static void dirax_send_random_selection(ReflectionList *r, int n, FILE *fh) +{ + char *used; + int i; + + used = malloc(n*sizeof(char)); + + for ( i=0; ireflections; + for ( j=0; jnext; + } + fprintf(fh, "%10f %10f %10f %8f\n", + ref->x/1e10, ref->y/1e10, + ref->z/1e10, ref->intensity); + used[ra] = 'U'; + + } +} + + void dirax_invoke(ControlContext *ctx) { FILE *fh; Reflection *ref; unsigned int opts; int saved_stderr; + int n; if ( ctx->dirax ) { dirax_rerun(ctx); @@ -386,11 +433,21 @@ void dirax_invoke(ControlContext *ctx) } fprintf(fh, "%f\n", 0.5); /* Lie about the wavelength. DirAx can't * handle the truth. */ - ref = ctx->reflectionlist->reflections; - while ( ref ) { - fprintf(fh, "%10f %10f %10f %8f\n", ref->x/1e10, ref->y/1e10, - ref->z/1e10, ref->intensity); - ref = ref->next; + + n = ctx->reflectionlist->n_reflections; + printf("DX: There are %i reflections - ", n); + if ( n > 1000 ) { + printf("sending a random selection to DirAx\n"); + dirax_send_random_selection(ctx->reflectionlist, n, fh); + } else { + printf("sending them all to DirAx\n"); + ref = ctx->reflectionlist->reflections; + while ( ref ) { + fprintf(fh, "%10f %10f %10f %8f\n", + ref->x/1e10, ref->y/1e10, + ref->z/1e10, ref->intensity); + ref = ref->next; + } } fclose(fh); -- cgit v1.2.3