aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2013-03-15 11:44:22 +0100
committerThomas White <taw@physics.org>2013-04-17 17:33:49 +0200
commit9436a03fd02a464b1440f0b54cf9f3aaca5b2ded (patch)
tree17ec9ce2e590ca0c368724424e8c711bd6818b52
parent101aa5f9f8290b1d180d04d6ab5ff7eac934c148 (diff)
partial_sim: Add --full-stddev and --noise-stddev
-rw-r--r--doc/man/partial_sim.118
-rw-r--r--src/partial_sim.c49
2 files changed, 59 insertions, 8 deletions
diff --git a/doc/man/partial_sim.1 b/doc/man/partial_sim.1
index 9f3436ea..7321b9ff 100644
--- a/doc/man/partial_sim.1
+++ b/doc/man/partial_sim.1
@@ -1,7 +1,7 @@
.\"
.\" partial_sim man page
.\"
-.\" Copyright © 2012 Thomas White <taw@physics.org>
+.\" Copyright © 2012-2013 Thomas White <taw@physics.org>
.\"
.\" Part of CrystFEL - crystallography with a FEL
.\"
@@ -81,7 +81,19 @@ Save a table of values to \fIfilename\fR containing, in resolution shells, the f
.B
.IP "\fB--osf-stddev=\fR\fIval\fR
.PD
-Set the standard deviation of the distribution of overall scaling factors to \fIval\fR. The distribution will be cut at zero, i.e. negative or zero scaling factors are not allowed. The distribution will be centered on 1. The default is \fB--osf-stddev=2.0\fR.
+Set the standard deviation of the distribution of overall scaling factors to \fIval\fR. The distribution will be cut at zero, i.e. negative or zero scaling factors are not allowed. The distribution will be Gaussian centered on 1. The default is \fB--osf-stddev=2.0\fR.
+
+.PD 0
+.B
+.IP "\fB--full-stddev=\fR\fIval\fR
+.PD
+Set the standard deviation of the distribution of randomly generated full intensities to \fIval\fR. The distribution will be Gaussian, centered on zero, and the absolute value will be taken (i.e. there will be no negative values). The default is \fB--full-stddev=1000.0\fR. This option has no effect if you also use \fB-i\fR or \fR--input\fB.
+
+.PD 0
+.B
+.IP "\fB--noise-stddev=\fR\fIval\fR
+.PD
+Set the standard deviation of the noise added to the partial intensities to \fIval\fR. The noise will be Gaussian, and the same for all reflections. The default is \fB--noise-stddev=20.0\fR.
.SH AUTHOR
This page was written by Thomas White.
@@ -90,7 +102,7 @@ This page was written by Thomas White.
Report bugs to <taw@physics.org>, or visit <http://www.desy.de/~twhite/crystfel>.
.SH COPYRIGHT AND DISCLAIMER
-Copyright © 2012 Deutsches Elektronen-Synchrotron DESY, a research centre of the Helmholtz Association.
+Copyright © 2012-2013 Deutsches Elektronen-Synchrotron DESY, a research centre of the Helmholtz Association.
.P
partial_sim, and this manaul, are part of CrystFEL.
.P
diff --git a/src/partial_sim.c b/src/partial_sim.c
index 615c66a3..4fcbc823 100644
--- a/src/partial_sim.c
+++ b/src/partial_sim.c
@@ -88,7 +88,8 @@ static void calculate_partials(Crystal *cr,
int random_intensities,
pthread_mutex_t *full_lock,
unsigned long int *n_ref, double *p_hist,
- double *p_max, double max_q)
+ double *p_max, double max_q, double full_stddev,
+ double noise_stddev)
{
Reflection *refl;
RefListIterator *iter;
@@ -121,7 +122,7 @@ static void calculate_partials(Crystal *cr,
* thing under lock. */
pthread_mutex_lock(full_lock);
rfull = add_refl(full, h, k, l);
- If = fabs(gaussian_noise(0.0, 1000.0));
+ If = fabs(gaussian_noise(0.0, full_stddev));
set_intensity(rfull, If);
set_redundancy(rfull, 1);
pthread_mutex_unlock(full_lock);
@@ -153,10 +154,10 @@ static void calculate_partials(Crystal *cr,
res, bin, p);
}
- Ip = gaussian_noise(Ip, 100.0);
+ Ip = gaussian_noise(Ip, noise_stddev);
set_intensity(refl, Ip);
- set_esd_intensity(refl, 100.0);
+ set_esd_intensity(refl, noise_stddev);
}
}
@@ -185,6 +186,9 @@ static void show_help(const char *s)
" reciprocal lattice vector components given in the\n"
" stream, with maximum error +/- <val> percent.\n"
" --osf-stddev=<val> Set the standard deviation of the scaling factors.\n"
+" --full-stddev=<val> Set the standard deviation of the randomly\n"
+" generated full intensities, if not using -i.\n"
+" --noise-stddev=<val> Set the standard deviation of the noise.\n"
"\n"
);
}
@@ -204,6 +208,8 @@ struct queue_args
UnitCell *cell;
double cnoise;
double osf_stddev;
+ double full_stddev;
+ double noise_stddev;
struct image *template_image;
double max_q;
@@ -291,7 +297,8 @@ static void run_job(void *vwargs, int cookie)
qargs->sym, qargs->random_intensities,
&qargs->full_lock,
wargs->n_ref, wargs->p_hist, wargs->p_max,
- qargs->max_q);
+ qargs->max_q, qargs->full_stddev,
+ qargs->noise_stddev);
/* Give a slightly incorrect cell in the stream */
mess_up_cell(cr, qargs->cnoise);
@@ -351,6 +358,8 @@ int main(int argc, char *argv[])
FILE *fh;
char *phist_file = NULL;
double osf_stddev = 2.0;
+ double full_stddev = 1000.0;
+ double noise_stddev = 20.0;
/* Long options */
const struct option longopts[] = {
@@ -366,6 +375,8 @@ int main(int argc, char *argv[])
{"pgraph", 1, NULL, 2},
{"osf-stddev", 1, NULL, 3},
+ {"full-stddev", 1, NULL, 4},
+ {"noise-stddev", 1, NULL, 5},
{0, 0, NULL, 0}
};
@@ -441,6 +452,32 @@ int main(int argc, char *argv[])
}
break;
+ case 4 :
+ full_stddev = strtod(optarg, &rval);
+ if ( *rval != '\0' ) {
+ ERROR("Invalid full standard deviation.\n");
+ return 1;
+ }
+ if ( full_stddev <= 0.0 ) {
+ ERROR("Invalid full standard deviation.");
+ ERROR(" (must be positive).\n");
+ return 1;
+ }
+ break;
+
+ case 5 :
+ noise_stddev = strtod(optarg, &rval);
+ if ( *rval != '\0' ) {
+ ERROR("Invalid noise standard deviation.\n");
+ return 1;
+ }
+ if ( noise_stddev <= 0.0 ) {
+ ERROR("Invalid noise standard deviation.");
+ ERROR(" (must be positive).\n");
+ return 1;
+ }
+ break;
+
case 0 :
break;
@@ -573,6 +610,8 @@ int main(int argc, char *argv[])
qargs.stream = stream;
qargs.cnoise = cnoise;
qargs.osf_stddev = osf_stddev;
+ qargs.full_stddev = full_stddev;
+ qargs.noise_stddev = noise_stddev;
qargs.max_q = largest_q(&image);
for ( i=0; i<NBINS; i++ ) {