aboutsummaryrefslogtreecommitdiff
path: root/src/partial_sim.c
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2011-05-11 16:05:06 +0200
committerThomas White <taw@physics.org>2012-02-22 15:27:26 +0100
commit5d4fac96cf467d72b783f4a8abe802eb154ed878 (patch)
tree890950266e7633f6da0831451f7eb7c9671595e5 /src/partial_sim.c
parent921b5deeed01abf68048cb8227a516dfad78edb0 (diff)
partial_sim: -n option for number of patterns
Diffstat (limited to 'src/partial_sim.c')
-rw-r--r--src/partial_sim.c64
1 files 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=<file> PDB file from which to get the unit cell.\n"
"\n"
" -y, --symmetry=<sym> Symmetry of the input reflection list.\n"
+" -n <n> Simulate <n> 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<n; i++ ) {
+
+ /* Set up a random orientation */
+ orientation = random_quaternion();
+ image.indexed_cell = cell_rotate(cell, orientation);
+
+ snprintf(image.filename, 255, "(simulated %i)", i);
+ image.reflections = find_intersections(&image,
+ image.indexed_cell, 0);
+ calculate_partials(image.reflections, 1.0, 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);
+ cell_free(image.indexed_cell);
+
+ progress_bar(i+1, n, "Simulating");
+
+ }
+
fclose(ofh);
cell_free(cell);
@@ -274,6 +285,7 @@ int main(int argc, char *argv[])
free(beam);
free(sym);
reflist_free(full);
+ free(image.filename);
return 0;
}