diff options
author | Thomas White <taw@bitwiz.org.uk> | 2010-05-04 06:50:01 -0700 |
---|---|---|
committer | Thomas White <taw@bitwiz.org.uk> | 2010-05-04 06:50:01 -0700 |
commit | eee5f3a9dac03134ee2269968ad870b0c812c036 (patch) | |
tree | 53242a82a30e5672cbe098196615f1e2fe7d91e6 /src/pattern_sim.c | |
parent | e666496c3143524d835f4cbf489974ce6c5556a5 (diff) |
pattern_sim: Switchable gradient methods
Diffstat (limited to 'src/pattern_sim.c')
-rw-r--r-- | src/pattern_sim.c | 42 |
1 files changed, 40 insertions, 2 deletions
diff --git a/src/pattern_sim.c b/src/pattern_sim.c index ab223288..a0d81a9d 100644 --- a/src/pattern_sim.c +++ b/src/pattern_sim.c @@ -53,6 +53,14 @@ static void show_help(const char *s) " this invocation to results/integr.h5.\n" " -i, --intensities=<file> Specify file containing reflection intensities\n" " to use.\n" +" -g, --gradients=<method> Use <method> for the calculation of shape\n" +" transform intensities. Choose from:\n" +" mosaic : Take the intensity of the nearest\n" +" Bragg position.\n" +" interpolate : Interpolate trilinearly between\n" +" six adjacent Bragg intensities.\n" +" phased : As 'interpolate', but take phase\n" +" values into account.\n" "\n" "By default, the simulation aims to be as accurate as possible. For greater\n" "speed, or for testing, you can choose to disable certain things using the\n" @@ -158,6 +166,8 @@ int main(int argc, char *argv[]) int config_nosfac = 0; int config_gpu = 0; int config_powder = 0; + char *grad_str = NULL; + GradientMethod grad; int ndone = 0; /* Number of simulations done (images or not) */ int number = 1; /* Number used for filename of image */ int n_images = 1; /* Generate one image by default */ @@ -178,11 +188,12 @@ int main(int argc, char *argv[]) {"no-noise", 0, &config_nonoise, 1}, {"intensities", 1, NULL, 'i'}, {"powder", 0, &config_powder, 1}, + {"gradients", 1, NULL, 'g'}, {0, 0, NULL, 0} }; /* Short options */ - while ((c = getopt_long(argc, argv, "hrn:i:", longopts, NULL)) != -1) { + while ((c = getopt_long(argc, argv, "hrn:i:g:", longopts, NULL)) != -1) { switch (c) { case 'h' : { @@ -205,6 +216,11 @@ int main(int argc, char *argv[]) break; } + case 'g' : { + grad_str = strdup(optarg); + break; + } + case 0 : { break; } @@ -240,6 +256,28 @@ int main(int argc, char *argv[]) free(intfile); } + if ( grad_str == NULL ) { + STATUS("You didn't specify a gradient calculation method, so" + " I'm using the 'mosaic' method, which is fastest.\n"); + grad = GRADIENT_MOSAIC; + } else if ( strcmp(grad_str, "mosaic") == 0 ) { + grad = GRADIENT_MOSAIC; + } else if ( strcmp(grad_str, "interpolate") == 0) { + grad = GRADIENT_INTERPOLATE; + } else if ( strcmp(grad_str, "phased") == 0) { + grad = GRADIENT_PHASED; + } else { + ERROR("Unrecognised gradient method '%s'\n", grad_str); + return 1; + } + free(grad_str); + + if ( config_gpu && (grad != GRADIENT_MOSAIC) ) { + ERROR("Only the mosaic method can be used for gradients when" + "calculating on the GPU.\n"); + return 1; + } + /* Define image parameters */ image.width = 1024; image.height = 1024; @@ -298,7 +336,7 @@ int main(int argc, char *argv[]) get_diffraction_gpu(gctx, &image, na, nb, nc, cell); } else { get_diffraction(&image, na, nb, nc, intensities, counts, - cell, !config_nowater); + cell, !config_nowater, grad); } if ( image.data == NULL ) { ERROR("Diffraction calculation failed.\n"); |