diff options
Diffstat (limited to 'src/pattern_sim.c')
-rw-r--r-- | src/pattern_sim.c | 96 |
1 files changed, 83 insertions, 13 deletions
diff --git a/src/pattern_sim.c b/src/pattern_sim.c index 08fc75dd..a747cd72 100644 --- a/src/pattern_sim.c +++ b/src/pattern_sim.c @@ -54,6 +54,7 @@ #include "reflist.h" #include "reflist-utils.h" #include "pattern_sim.h" +#include "stream.h" static void show_help(const char *s) @@ -90,6 +91,7 @@ static void show_help(const char *s) " -s, --sample-spectrum=<N> Use N samples from spectrum. Default 3.\n" " -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" ); } @@ -251,6 +253,8 @@ int main(int argc, char *argv[]) int nsamples = 3; gsl_rng *rng; int background = 0; + char *template_file = NULL; + Stream *st = NULL; /* Long options */ const struct option longopts[] = { @@ -276,6 +280,7 @@ int main(int argc, char *argv[]) {"min-size", 1, NULL, 3}, {"max-size", 1, NULL, 4}, {"background", 1, NULL, 5}, + {"template", 1, NULL, 6}, {0, 0, NULL, 0} }; @@ -375,6 +380,10 @@ int main(int argc, char *argv[]) } break; + case 6 : + template_file = strdup(optarg); + break; + case 0 : break; @@ -406,6 +415,19 @@ int main(int argc, char *argv[]) } } + if ( template_file != NULL ) { + if ( config_randomquat ) { + ERROR("You cannot use -r and --template together.\n"); + return 1; + } + st = open_stream_for_read(template_file); + if ( st == NULL ) { + ERROR("Failed to open stream.\n"); + return 1; + } + free(template_file); + } + if ( sym_str == NULL ) sym_str = strdup("1"); sym = get_pointgroup(sym_str); /* sym_str is used below */ @@ -451,6 +473,11 @@ int main(int argc, char *argv[]) spectrum_type = SPECTRUM_TOPHAT; } else if ( strcasecmp(spectrum_str, "sase") == 0) { spectrum_type = SPECTRUM_SASE; + } else if ( strcasecmp(spectrum_str, "twocolour") == 0 || + strcasecmp(spectrum_str, "twocolor") == 0 || + strcasecmp(spectrum_str, "twocolours") == 0 || + strcasecmp(spectrum_str, "twocolors") == 0) { + spectrum_type = SPECTRUM_TWOCOLOUR; } else { ERROR("Unrecognised spectrum type '%s'\n", spectrum_str); return 1; @@ -578,23 +605,62 @@ int main(int argc, char *argv[]) } - /* Read quaternion from stdin */ - if ( config_randomquat ) { - orientation = random_quaternion(rng); + if ( st == NULL ) { + + if ( config_randomquat ) { + orientation = random_quaternion(rng); + } else { + orientation = read_quaternion(); + } + + STATUS("Orientation is %5.3f %5.3f %5.3f %5.3f\n", + orientation.w, orientation.x, + orientation.y, orientation.z); + + if ( !quaternion_valid(orientation) ) { + ERROR("Orientation modulus is not zero!\n"); + return 1; + } + + cell = cell_rotate(input_cell, orientation); + } else { - orientation = read_quaternion(); - } - STATUS("Orientation is %5.3f %5.3f %5.3f %5.3f\n", - orientation.w, orientation.x, - orientation.y, orientation.z); + struct image image; + int i; + Crystal *cr; - if ( !quaternion_valid(orientation) ) { - ERROR("Orientation modulus is not zero!\n"); - return 1; - } + image.det = NULL; + + /* Get data from next chunk */ + if ( read_chunk(st, &image) ) break; + + free(image.filename); + image_feature_list_free(image.features); + + if ( image.n_crystals == 0 ) continue; + + cr = image.crystals[0]; + cell = crystal_get_cell(cr); + + if ( image.n_crystals > 1 ) { + ERROR("Using the first crystal only.\n"); + } + + for ( i=1; i<image.n_crystals; i++ ) { + + Crystal *cr = image.crystals[i]; + cell = crystal_get_cell(cr); - cell = cell_rotate(input_cell, orientation); + reflist_free(crystal_get_reflections(cr)); + cell_free(crystal_get_cell(cr)); + crystal_free(cr); + + } + + free(image.crystals); + + } switch ( spectrum_type ) { @@ -606,6 +672,10 @@ int main(int argc, char *argv[]) image.spectrum = generate_SASE(&image, rng); break; + case SPECTRUM_TWOCOLOUR : + image.spectrum = generate_twocolour(&image); + break; + } /* Ensure no residual information */ |