/* * get_hkl.c * * Small program to manipulate reflection lists * * (c) 2006-2011 Thomas White * * Part of CrystFEL - crystallography with a FEL * */ #ifdef HAVE_CONFIG_H #include #endif #include #include #include #include #include #include #include "utils.h" #include "reflections.h" #include "symmetry.h" #include "beam-parameters.h" static void show_help(const char *s) { printf("Syntax: %s [options]\n\n", s); printf( "Manipulate reflection lists.\n" "\n" " -h, --help Display this help message.\n" "\n" " -i, --input= Read reflections from .\n" " -y, --symmetry= The symmetry of the input reflection list.\n" "\n" "You can add noise to the reflections with either of:\n" " --poisson Simulate Poisson samples.\n" " --noise Add 10%% random noise.\n" "\n" "To calculate Poisson samples accurately, you must also give:\n" " -b, --beam= Get beam parameters from file.\n" "\n" "You can artificially 'twin' the reflections, or expand them out:\n" " -w, --twin= Generate twinned data according to the given\n" " point group.\n" " -e, --expand= Expand reflections to this point group.\n" "\n" "You can restrict which reflections are written out:\n" " -t, --template= Only include reflections mentioned in file.\n" "\n" "You might sometimes need to do this:\n" " --multiplicity Multiply intensities by the number of\n" " equivalent reflections.\n" "\n" "Don't forget to specify the output filename:\n" " -o, --output= Output filename (default: stdout).\n" ); } /* Apply Poisson noise to all reflections */ static void poisson_reflections(double *ref, ReflItemList *items) { int i; const int n = num_items(items); for ( i=0; ih, it->k, it->l); c = poisson_noise(val); set_intensity(ref, it->h, it->k, it->l, c); progress_bar(i, n-1, "Simulating noise"); } } /* Apply 10% uniform noise to all reflections */ static void noise_reflections(double *ref, ReflItemList *items) { int i; const int n = num_items(items); for ( i=0; ih, it->k, it->l); r = (double)random()/RAND_MAX; val += 0.1 * val * r; set_intensity(ref, it->h, it->k, it->l, val); progress_bar(i, n-1, "Simulating noise"); } } static ReflItemList *twin_reflections(double *ref, ReflItemList *items, const char *holo, const char *mero, double *esds) { int i; ReflItemList *new; new = new_items(); if ( num_general_equivs(holo) < num_general_equivs(mero) ) { ERROR("%s is not a subgroup of %s!\n", mero, holo); return NULL; } for ( i=0; ih, it->k, it->l, &h, &k, &l, holo); if ( find_item(new, h, k, l) ) continue; n = num_equivs(h, k, l, holo); total = 0.0; sigma = 0.0; skip = 0; for ( j=0; j num_general_equivs(initial) ) { ERROR("%s is not a subgroup of %s!\n", initial, target); return NULL; } for ( i=0; ih; k = it->k; l = it->l; /* Actually we don't really care what the equivalent is, * we just want to be sure that there is nly be one version of * this reflection. */ find_unique_equiv(items, h, k, l, initial, &hd, &kd, &ld); /* Now find out how many reflections need to be filled in */ n = num_equivs(h, k, l, initial); intensity = lookup_intensity(ref, h, k, l); for ( j=0; jh, it->k, it->l); inty *= num_equivs(it->h, it->k, it->l, mero); set_intensity(ideal_ref, it->h, it->k, it->l, inty); STATUS("%i %i %i %i\n", it->h, it->k, it->l, num_equivs(it->h, it->k, it->l, mero)); } } if ( template ) { /* Write out only reflections which are in the template * (and which we have in the input) */ ReflItemList *template_items; template_items = read_reflections(template, NULL, NULL, NULL, NULL); write_items = intersection_items(input_items, template_items); delete_items(template_items); } else { /* Write out all reflections */ write_items = new_items(); /* (quick way of copying a list) */ union_items(write_items, input_items); } write_reflections(output, write_items, ideal_ref, esds, phases, NULL, cell); delete_items(input_items); delete_items(write_items); return 0; }