diff options
author | Thomas White <taw@physics.org> | 2014-02-28 15:25:04 +0100 |
---|---|---|
committer | Thomas White <taw@physics.org> | 2014-02-28 15:25:04 +0100 |
commit | bea8ba818ef735fa2d667f132c90471da15ae1d1 (patch) | |
tree | 75a1125ea11157721a839c7744b4a6dfa36b50fd | |
parent | b6ec4053a99b1c0b584a20af189a1a48db89f908 (diff) |
pattern_sim: Add --no-fringes
-rw-r--r-- | doc/man/pattern_sim.1 | 10 | ||||
-rw-r--r-- | src/diffraction-gpu.c | 17 | ||||
-rw-r--r-- | src/diffraction-gpu.h | 12 | ||||
-rw-r--r-- | src/diffraction.c | 16 | ||||
-rw-r--r-- | src/diffraction.h | 3 | ||||
-rw-r--r-- | src/pattern_sim.c | 8 | ||||
-rw-r--r-- | tests/gpu_sim_check.c | 4 |
7 files changed, 46 insertions, 24 deletions
diff --git a/doc/man/pattern_sim.1 b/doc/man/pattern_sim.1 index 2ce1f9f0..e71413db 100644 --- a/doc/man/pattern_sim.1 +++ b/doc/man/pattern_sim.1 @@ -1,7 +1,8 @@ .\" .\" pattern_sim man page .\" -.\" Copyright © 2012 Thomas White <taw@physics.org> +.\" Copyright © 2012-2014 Deutsches Elektronen-Synchrotron DESY, +.\" a research centre of the Helmholtz Association. .\" .\" Part of CrystFEL - crystallography with a FEL .\" @@ -137,6 +138,11 @@ Use \fItype\fR of spectrum. \fItype\fR can be one of \fBtophat\fR or \fBsase\fR .PD Add \fIn\fR photons of Poisson-distributed background uniformly over the detector surface. +.PD 0 +.IP \fB--no-fringes\fR +.PD +Suppress the subsidiary maxima of the shape transforms by setting I_latt(q) to zero beyond the first minimum of the function. + .SH REFLECTION LISTS @@ -206,7 +212,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-2014 Deutsches Elektronen-Synchrotron DESY, a research centre of the Helmholtz Association. .P pattern_sim, and this manual, are part of CrystFEL. .P diff --git a/src/diffraction-gpu.c b/src/diffraction-gpu.c index b5bd2e88..8b165856 100644 --- a/src/diffraction-gpu.c +++ b/src/diffraction-gpu.c @@ -73,7 +73,7 @@ struct gpu_context }; -static void check_sinc_lut(struct gpu_context *gctx, int n) +static void check_sinc_lut(struct gpu_context *gctx, int n, int no_fringes) { cl_int err; cl_image_format fmt; @@ -106,7 +106,11 @@ static void check_sinc_lut(struct gpu_context *gctx, int n) for ( i=1; i<SINC_LUT_ELEMENTS; i++ ) { double x, val; x = (double)i/SINC_LUT_ELEMENTS; - val = fabs(sin(M_PI*n*x)/sin(M_PI*x)); + if ( no_fringes && (x > 1.0/n) && (1.0-x > 1.0/n) ) { + val = 0.0; + } else { + val = fabs(sin(M_PI*n*x)/sin(M_PI*x)); + } gctx->sinc_lut_ptrs[n-1][i] = val; } } @@ -278,7 +282,8 @@ static void do_panels(struct gpu_context *gctx, struct image *image, void get_diffraction_gpu(struct gpu_context *gctx, struct image *image, - int na, int nb, int nc, UnitCell *ucell) + int na, int nb, int nc, UnitCell *ucell, + int no_fringes) { double ax, ay, az; double bx, by, bz; @@ -297,9 +302,9 @@ void get_diffraction_gpu(struct gpu_context *gctx, struct image *image, } /* Ensure all required LUTs are available */ - check_sinc_lut(gctx, na); - check_sinc_lut(gctx, nb); - check_sinc_lut(gctx, nc); + check_sinc_lut(gctx, na, no_fringes); + check_sinc_lut(gctx, nb, no_fringes); + check_sinc_lut(gctx, nc, no_fringes); /* Unit cell */ cell_get_cartesian(ucell, &ax, &ay, &az, &bx, &by, &bz, &cx, &cy, &cz); diff --git a/src/diffraction-gpu.h b/src/diffraction-gpu.h index 349a6bff..e7ae23fd 100644 --- a/src/diffraction-gpu.h +++ b/src/diffraction-gpu.h @@ -3,11 +3,11 @@ * * Calculate diffraction patterns by Fourier methods (GPU version) * - * Copyright © 2012 Deutsches Elektronen-Synchrotron DESY, - * a research centre of the Helmholtz Association. + * Copyright © 2012-2014 Deutsches Elektronen-Synchrotron DESY, + * a research centre of the Helmholtz Association. * * Authors: - * 2010-2012 Thomas White <taw@physics.org> + * 2010-2014 Thomas White <taw@physics.org> * * This file is part of CrystFEL. * @@ -41,7 +41,8 @@ struct gpu_context; #if HAVE_OPENCL extern void get_diffraction_gpu(struct gpu_context *gctx, struct image *image, - int na, int nb, int nc, UnitCell *ucell); + int na, int nb, int nc, UnitCell *ucell, + int no_fringes); extern struct gpu_context *setup_gpu(int no_sfac, const double *intensities, const unsigned char *flags, @@ -51,7 +52,8 @@ extern void cleanup_gpu(struct gpu_context *gctx); #else static void get_diffraction_gpu(struct gpu_context *gctx, struct image *image, - int na, int nb, int nc, UnitCell *ucell) + int na, int nb, int nc, UnitCell *ucell, + int no_fringes) { /* Do nothing */ ERROR("This copy of CrystFEL was not compiled with OpenCL support.\n"); diff --git a/src/diffraction.c b/src/diffraction.c index 0fa9f79b..6383a8b4 100644 --- a/src/diffraction.c +++ b/src/diffraction.c @@ -49,7 +49,7 @@ #define SINC_LUT_ELEMENTS (4096) -static double *get_sinc_lut(int n) +static double *get_sinc_lut(int n, int no_fringes) { int i; double *lut; @@ -64,7 +64,11 @@ static double *get_sinc_lut(int n) for ( i=1; i<SINC_LUT_ELEMENTS; i++ ) { double x, val; x = (double)i/SINC_LUT_ELEMENTS; - val = fabs(sin(M_PI*n*x)/sin(M_PI*x)); + if ( no_fringes && (x > 1.0/n) && (1.0-x > 1.0/n) ) { + val = 0.0; + } else { + val = fabs(sin(M_PI*n*x)/sin(M_PI*x)); + } lut[i] = val; } } @@ -665,7 +669,7 @@ struct sample *generate_twocolour(struct image *image) void get_diffraction(struct image *image, int na, int nb, int nc, const double *intensities, const double *phases, const unsigned char *flags, UnitCell *cell, - GradientMethod m, const SymOpList *sym) + GradientMethod m, const SymOpList *sym, int no_fringes) { double ax, ay, az; double bx, by, bz; @@ -683,9 +687,9 @@ void get_diffraction(struct image *image, int na, int nb, int nc, /* Needed later for Lorentz calculation */ image->twotheta = malloc(image->width * image->height * sizeof(double)); - lut_a = get_sinc_lut(na); - lut_b = get_sinc_lut(nb); - lut_c = get_sinc_lut(nc); + lut_a = get_sinc_lut(na, no_fringes); + lut_b = get_sinc_lut(nb, no_fringes); + lut_c = get_sinc_lut(nc, no_fringes); for ( i=0; i<image->nsamples; i++ ) { diff --git a/src/diffraction.h b/src/diffraction.h index e397bd3a..28f3ec0a 100644 --- a/src/diffraction.h +++ b/src/diffraction.h @@ -51,7 +51,8 @@ typedef enum { extern void get_diffraction(struct image *image, int na, int nb, int nc, const double *intensities, const double *phases, const unsigned char *flags, UnitCell *cell, - GradientMethod m, const SymOpList *sym); + GradientMethod m, const SymOpList *sym, + int no_fringes); extern struct sample *generate_tophat(struct image *image); diff --git a/src/pattern_sim.c b/src/pattern_sim.c index a747cd72..b8cc1c68 100644 --- a/src/pattern_sim.c +++ b/src/pattern_sim.c @@ -92,6 +92,7 @@ static void show_help(const char *s) " -x, --spectrum=<type> Type of spectrum to simulate.\n" " --background=<N> Add N photons of Poisson background (default 0).\n" " --template=<file> Take orientations from stream <file>.\n" +" --no-fringes Exclude the side maxima of Bragg peaks.\n" ); } @@ -255,6 +256,7 @@ int main(int argc, char *argv[]) int background = 0; char *template_file = NULL; Stream *st = NULL; + int no_fringes = 0; /* Long options */ const struct option longopts[] = { @@ -276,6 +278,7 @@ int main(int argc, char *argv[]) {"type-spectrum", 1, NULL, 'x'}, {"spectrum", 1, NULL, 'x'}, {"really-random", 0, &config_random, 1}, + {"no-fringes", 0, &no_fringes, 1}, {"gpu-dev", 1, NULL, 2}, {"min-size", 1, NULL, 3}, {"max-size", 1, NULL, 4}, @@ -693,10 +696,11 @@ int main(int argc, char *argv[]) intensities, flags, sym_str, gpu_dev); } - get_diffraction_gpu(gctx, &image, na, nb, nc, cell); + get_diffraction_gpu(gctx, &image, na, nb, nc, cell, + no_fringes); } else { get_diffraction(&image, na, nb, nc, intensities, phases, - flags, cell, grad, sym); + flags, cell, grad, sym, no_fringes); } if ( image.data == NULL ) { ERROR("Diffraction calculation failed.\n"); diff --git a/tests/gpu_sim_check.c b/tests/gpu_sim_check.c index d2475213..0419d945 100644 --- a/tests/gpu_sim_check.c +++ b/tests/gpu_sim_check.c @@ -166,7 +166,7 @@ int main(int argc, char *argv[]) gpu_image.spectrum = generate_tophat(&gpu_image); start = get_hires_seconds(); - get_diffraction_gpu(gctx, &gpu_image, 8, 8, 8, cell); + get_diffraction_gpu(gctx, &gpu_image, 8, 8, 8, cell, 1); end = get_hires_seconds(); gpu_time = end - start; @@ -174,7 +174,7 @@ int main(int argc, char *argv[]) start = get_hires_seconds(); get_diffraction(&cpu_image, 8, 8, 8, NULL, NULL, NULL, cell, - GRADIENT_MOSAIC, sym); + GRADIENT_MOSAIC, sym, 1); end = get_hires_seconds(); cpu_time = end - start; |