From 1e801eb8d029b9bc6cc51a059078f53a23c33832 Mon Sep 17 00:00:00 2001 From: Thomas White Date: Wed, 28 Sep 2011 12:05:53 +0200 Subject: Get the amount of unit cell noise from the command line --- src/partial_sim.c | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/partial_sim.c b/src/partial_sim.c index 87ef397b..ef1a48b1 100644 --- a/src/partial_sim.c +++ b/src/partial_sim.c @@ -33,15 +33,12 @@ #include "thread-pool.h" -static void mess_up_cell(UnitCell *cell) +static void mess_up_cell(UnitCell *cell, double cnoise) { double ax, ay, az; double bx, by, bz; double cx, cy, cz; - /* Cell noise in percent */ - const double cnoise = 1.0; - //STATUS("Real:\n"); //cell_print(cell); @@ -143,6 +140,10 @@ static void show_help(const char *s) " -y, --symmetry= Symmetry of the input reflection list.\n" " -n Simulate patterns. Default: 2.\n" " -r, --save-random= Save randomly generated intensities to file.\n" +" -c, --cnoise= Add random noise, with a flat distribution, to the\n" +" reciprocal lattice vector components given in the\n" +" stream, with maximum error +/- percent.\n" +"\n" ); } @@ -159,6 +160,7 @@ struct queue_args SymOpList *sym; int random_intensities; UnitCell *cell; + double cnoise; struct image *template_image; @@ -208,7 +210,7 @@ static void run_job(void *vwargs, int cookie) &qargs->full_lock); /* Give a slightly incorrect cell in the stream */ - mess_up_cell(wargs->image.indexed_cell); + mess_up_cell(wargs->image.indexed_cell, qargs->cnoise); } @@ -249,6 +251,8 @@ int main(int argc, char *argv[]) struct queue_args qargs; struct image image; int n_threads = 1; + double cnoise = 0.0; + char *rval; /* Long options */ const struct option longopts[] = { @@ -260,11 +264,12 @@ int main(int argc, char *argv[]) {"geometry", 1, NULL, 'g'}, {"symmetry", 1, NULL, 'y'}, {"save-random", 1, NULL, 'r'}, + {"cnoise", 1, NULL, 'c'}, {0, 0, NULL, 0} }; /* Short options */ - while ((c = getopt_long(argc, argv, "hi:o:b:p:g:y:n:r:j:", + while ((c = getopt_long(argc, argv, "hi:o:b:p:g:y:n:r:j:c:", longopts, NULL)) != -1) { switch (c) { @@ -308,6 +313,14 @@ int main(int argc, char *argv[]) n_threads = atoi(optarg); break; + case 'c' : + cnoise = strtod(optarg, &rval); + if ( *rval != '\0' ) { + ERROR("Invalid cell noise value.\n"); + return 1; + } + break; + case 0 : break; @@ -430,6 +443,7 @@ int main(int argc, char *argv[]) qargs.cell = cell; qargs.template_image = ℑ qargs.stream = ofh; + qargs.cnoise = cnoise; run_threads(n_threads, run_job, create_job, finalise_job, &qargs, n, n, 1, 0); -- cgit v1.2.3