From 5d4fac96cf467d72b783f4a8abe802eb154ed878 Mon Sep 17 00:00:00 2001 From: Thomas White Date: Wed, 11 May 2011 16:05:06 +0200 Subject: partial_sim: -n option for number of patterns --- src/partial_sim.c | 64 +++++++++++++++++++++++++++++++++---------------------- 1 file changed, 38 insertions(+), 26 deletions(-) diff --git a/src/partial_sim.c b/src/partial_sim.c index a412330c..b7d1fd1d 100644 --- a/src/partial_sim.c +++ b/src/partial_sim.c @@ -93,6 +93,7 @@ static void show_help(const char *s) " -p, --pdb= PDB file from which to get the unit cell.\n" "\n" " -y, --symmetry= Symmetry of the input reflection list.\n" +" -n Simulate patterns. Default: 2\n" ); } @@ -113,7 +114,8 @@ int main(int argc, char *argv[]) struct quaternion orientation; struct image image; FILE *ofh; - UnitCell *new; + int n = 2; + int i; /* Long options */ const struct option longopts[] = { @@ -128,7 +130,7 @@ int main(int argc, char *argv[]) }; /* Short options */ - while ((c = getopt_long(argc, argv, "hi:o:b:p:g:y:", + while ((c = getopt_long(argc, argv, "hi:o:b:p:g:y:n:", longopts, NULL)) != -1) { switch (c) { @@ -160,6 +162,10 @@ int main(int argc, char *argv[]) sym = strdup(optarg); break; + case 'n' : + n = atoi(optarg); + break; + case 0 : break; @@ -222,6 +228,11 @@ int main(int argc, char *argv[]) return 1; } + if ( n < 1 ) { + ERROR("Number of patterns must be at least 1.\n"); + return 1; + } + if ( output_file == NULL ) { ERROR("You must pgive a filename for the output.\n"); return 1; @@ -234,10 +245,6 @@ int main(int argc, char *argv[]) free(output_file); write_stream_header(ofh, argc, argv); - /* Set up a random orientation */ - orientation = random_quaternion(); - image.indexed_cell = cell_rotate(cell, orientation); - image.det = det; image.width = det->max_fs; image.height = det->max_ss; @@ -247,26 +254,30 @@ int main(int argc, char *argv[]) image.bw = beam->bandwidth; image.profile_radius = 0.005e9; image.i0_available = 0; - image.filename = "(simulated 1)"; - image.reflections = find_intersections(&image, image.indexed_cell, 0); - calculate_partials(image.reflections, 1.0, full, sym); - write_chunk(ofh, &image, STREAM_INTEGRATED); - reflist_free(image.reflections); - - /* Alter the cell by a tiny amount */ - image.filename = "(simulated 2)"; - new = rotate_cell(image.indexed_cell, deg2rad(1.0), deg2rad(0.0), 0.0); - cell_free(image.indexed_cell); - image.indexed_cell = new; - - /* Calculate new partials */ - image.reflections = find_intersections(&image, image.indexed_cell, 0); - calculate_partials(image.reflections, 0.5, full, sym); - - /* Give a slightly incorrect cell in the stream */ - mess_up_cell(image.indexed_cell); - write_chunk(ofh, &image, STREAM_INTEGRATED); - reflist_free(image.reflections); + image.filename = malloc(256); + + for ( i=0; i