Commit 5d4fac96 authored by Thomas White's avatar Thomas White
Browse files

partial_sim: -n option for number of patterns

parent 921b5dee
...@@ -93,6 +93,7 @@ static void show_help(const char *s) ...@@ -93,6 +93,7 @@ static void show_help(const char *s)
" -p, --pdb=<file> PDB file from which to get the unit cell.\n" " -p, --pdb=<file> PDB file from which to get the unit cell.\n"
"\n" "\n"
" -y, --symmetry=<sym> Symmetry of the input reflection list.\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[]) ...@@ -113,7 +114,8 @@ int main(int argc, char *argv[])
struct quaternion orientation; struct quaternion orientation;
struct image image; struct image image;
FILE *ofh; FILE *ofh;
UnitCell *new; int n = 2;
int i;
/* Long options */ /* Long options */
const struct option longopts[] = { const struct option longopts[] = {
...@@ -128,7 +130,7 @@ int main(int argc, char *argv[]) ...@@ -128,7 +130,7 @@ int main(int argc, char *argv[])
}; };
/* Short options */ /* 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) { longopts, NULL)) != -1) {
switch (c) { switch (c) {
...@@ -160,6 +162,10 @@ int main(int argc, char *argv[]) ...@@ -160,6 +162,10 @@ int main(int argc, char *argv[])
sym = strdup(optarg); sym = strdup(optarg);
break; break;
case 'n' :
n = atoi(optarg);
break;
case 0 : case 0 :
break; break;
...@@ -222,6 +228,11 @@ int main(int argc, char *argv[]) ...@@ -222,6 +228,11 @@ int main(int argc, char *argv[])
return 1; return 1;
} }
if ( n < 1 ) {
ERROR("Number of patterns must be at least 1.\n");
return 1;
}
if ( output_file == NULL ) { if ( output_file == NULL ) {
ERROR("You must pgive a filename for the output.\n"); ERROR("You must pgive a filename for the output.\n");
return 1; return 1;
...@@ -234,10 +245,6 @@ int main(int argc, char *argv[]) ...@@ -234,10 +245,6 @@ int main(int argc, char *argv[])
free(output_file); free(output_file);
write_stream_header(ofh, argc, argv); 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.det = det;
image.width = det->max_fs; image.width = det->max_fs;
image.height = det->max_ss; image.height = det->max_ss;
...@@ -247,26 +254,30 @@ int main(int argc, char *argv[]) ...@@ -247,26 +254,30 @@ int main(int argc, char *argv[])
image.bw = beam->bandwidth; image.bw = beam->bandwidth;
image.profile_radius = 0.005e9; image.profile_radius = 0.005e9;
image.i0_available = 0; image.i0_available = 0;
image.filename = "(simulated 1)"; image.filename = malloc(256);
image.reflections = find_intersections(&image, image.indexed_cell, 0);
calculate_partials(image.reflections, 1.0, full, sym); for ( i=0; i<n; i++ ) {
write_chunk(ofh, &image, STREAM_INTEGRATED);
reflist_free(image.reflections); /* Set up a random orientation */
orientation = random_quaternion();
/* Alter the cell by a tiny amount */ image.indexed_cell = cell_rotate(cell, orientation);
image.filename = "(simulated 2)";
new = rotate_cell(image.indexed_cell, deg2rad(1.0), deg2rad(0.0), 0.0); snprintf(image.filename, 255, "(simulated %i)", i);
cell_free(image.indexed_cell); image.reflections = find_intersections(&image,
image.indexed_cell = new; image.indexed_cell, 0);
calculate_partials(image.reflections, 1.0, full, sym);
/* Calculate new partials */
image.reflections = find_intersections(&image, image.indexed_cell, 0); /* Give a slightly incorrect cell in the stream */
calculate_partials(image.reflections, 0.5, full, sym); mess_up_cell(image.indexed_cell);
write_chunk(ofh, &image, STREAM_INTEGRATED);
/* Give a slightly incorrect cell in the stream */
mess_up_cell(image.indexed_cell); reflist_free(image.reflections);
write_chunk(ofh, &image, STREAM_INTEGRATED); cell_free(image.indexed_cell);
reflist_free(image.reflections);
progress_bar(i+1, n, "Simulating");
}
fclose(ofh); fclose(ofh);
cell_free(cell); cell_free(cell);
...@@ -274,6 +285,7 @@ int main(int argc, char *argv[]) ...@@ -274,6 +285,7 @@ int main(int argc, char *argv[])
free(beam); free(beam);
free(sym); free(sym);
reflist_free(full); reflist_free(full);
free(image.filename);
return 0; return 0;
} }
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment