From 2374fa202a63862ad32e3265b068db001815424a Mon Sep 17 00:00:00 2001 From: Thomas White Date: Fri, 4 Dec 2009 15:31:29 +0100 Subject: Add new options to get_hkl --- src/get_hkl.c | 89 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 85 insertions(+), 4 deletions(-) (limited to 'src/get_hkl.c') diff --git a/src/get_hkl.c b/src/get_hkl.c index 907a47d4..477a2631 100644 --- a/src/get_hkl.c +++ b/src/get_hkl.c @@ -32,24 +32,87 @@ static void show_help(const char *s) printf( "Write idealised intensity lists.\n" "\n" -" -h, --help Display this help message.\n"); +" -h, --help Display this help message.\n" +"\n" +" -t, --template= Only include reflections mentioned in file.\n"); +} + + +static double *template_reflections(double *ref, const char *filename) +{ + char *rval; + double *out; + FILE *fh; + + fh = fopen(filename, "r"); + if ( fh == NULL ) { + return NULL; + } + + out = new_list_intensity(); + + do { + + char line[1024]; + double val; + int r; + signed int h, k, l; + + rval = fgets(line, 1023, fh); + + r = sscanf(line, "%i %i %i", &h, &k, &l); + if ( r != 3 ) continue; + + val = lookup_intensity(ref, h, k, l); + set_intensity(out, h, k, l, val); + + } while ( rval != NULL ); + + fclose(fh); + + return out; +} + + +/* Apply Poisson noise to all reflections */ +static void noisify_reflections(double *ref) +{ + signed int h, k, l; + + for ( h=-INDMAX; hreflections); - write_reflections("results/ideal-reflections.hkl", NULL, ref, 1, + + if ( template != NULL ) { + tref = template_reflections(ref, template); + if ( tref == NULL ) { + ERROR("Couldn't read template file!\n"); + return 1; + } + free(ref); + ref = tref; + } + + if ( config_noisify ) noisify_reflections(ref); + + write_reflections("results/ideal-reflections.hkl", NULL, tref, 1, mol->cell); return 0; -- cgit v1.2.3