From 86e621ad289638d7bf1440092cffd4c2ac64f982 Mon Sep 17 00:00:00 2001 From: Thomas White Date: Wed, 16 Mar 2011 18:23:48 +0100 Subject: Remove old reflections.h --- src/get_hkl.c | 283 ++++++++++++++++++++++++++++++---------------------------- 1 file changed, 145 insertions(+), 138 deletions(-) (limited to 'src/get_hkl.c') diff --git a/src/get_hkl.c b/src/get_hkl.c index 1b7e4406..026198ab 100644 --- a/src/get_hkl.c +++ b/src/get_hkl.c @@ -22,7 +22,7 @@ #include #include "utils.h" -#include "reflections.h" +#include "reflist-utils.h" #include "symmetry.h" #include "beam-parameters.h" @@ -45,7 +45,8 @@ static void show_help(const char *s) "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" +"You can artificially 'twin' the reflections, or expand them out. You can also" +" do both, in which case the 'twinning' will be done first:\n" " -w, --twin= Generate twinned data according to the given\n" " point group.\n" " -e, --expand= Expand reflections to this point group.\n" @@ -59,99 +60,123 @@ static void show_help(const char *s) "\n" "Don't forget to specify the output filename:\n" " -o, --output= Output filename (default: stdout).\n" +" -p, --pdb= Use unit cell parameters from this PDB file to\n" +" generate resolution values in the output file.\n" ); } /* Apply Poisson noise to all reflections */ -static void poisson_reflections(double *ref, ReflItemList *items, - double adu_per_photon) +static void poisson_reflections(RefList *list, double adu_per_photon) { - int i; - const int n = num_items(items); + Reflection *refl; + RefListIterator *iter; - for ( i=0; ih, it->k, it->l); c = adu_per_photon * poisson_noise(val/adu_per_photon); - set_intensity(ref, it->h, it->k, it->l, c); - - progress_bar(i, n-1, "Simulating noise"); + set_int(refl, c); } } /* Apply 10% uniform noise to all reflections */ -static void noise_reflections(double *ref, ReflItemList *items) +static void noise_reflections(RefList *list) { - int i; - const int n = num_items(items); - - for ( i=0; ih, it->k, it->l); + val = get_intensity(refl); 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"); + set_int(refl, val); } } -static ReflItemList *twin_reflections(double *ref, ReflItemList *items, - const char *holo, const char *mero, - double *esds) +static RefList *template_reflections(RefList *list, RefList *template) { - int i; - ReflItemList *new; + Reflection *refl; + RefListIterator *iter; + RefList *out; - new = new_items(); + out = reflist_new(); + + for ( refl = first_refl(template, &iter); + refl != NULL; + refl = next_refl(refl, iter) ) { + + signed int h, k, l; + Reflection *new; + Reflection *old; + + get_indices(refl, &h, &k, &l); + + old = find_refl(list, h, k, l); + if ( old == NULL ) continue; + + new = add_refl(out, h, k, l); + copy_data(new, old); + + } + + return out; +} + + +static RefList *twin_reflections(RefList *in, + const char *holo, const char *mero) +{ + Reflection *refl; + RefListIterator *iter; + RefList *out; 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); + get_asymm(h, k, l, &h, &k, &l, holo); + if ( find_refl(out, h, k, l) != NULL ) continue; total = 0.0; sigma = 0.0; skip = 0; + n = num_equivs(h, k, l, holo); 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); + get_indices(refl, &h, &k, &l); + intensity = get_intensity(refl); - /* 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 each equivalent in the higher symmetry group */ for ( j=0; jadu_per_photon); + poisson_reflections(input, beam->adu_per_photon); } else { ERROR("You must give a beam parameters file in order" " to calculate Poisson noise.\n"); @@ -387,72 +397,69 @@ int main(int argc, char *argv[]) } } - if ( config_noise ) noise_reflections(input_ref, input_items); + if ( config_noise ) noise_reflections(input); if ( holo != NULL ) { - ReflItemList *new; + RefList *new; STATUS("Twinning from %s into %s\n", mero, holo); - new = twin_reflections(input_ref, input_items, - holo, mero, esds); - delete_items(input_items); - input_items = new; + new = twin_reflections(input, holo, mero); + + /* Replace old with new */ + reflist_free(input); + input = new; + + /* The symmetry of the list has changed */ + free(mero); + mero = holo; } if ( expand != NULL ) { - ReflItemList *new; + RefList *new; STATUS("Expanding from %s into %s\n", mero, expand); - new = expand_reflections(input_ref, input_items, expand, mero); - delete_items(input_items); - input_items = new; + new = expand_reflections(input, expand, mero); + + /* Replace old with new */ + reflist_free(input); + input = new; } if ( config_multi ) { - int i; + Reflection *refl; + RefListIterator *iter; - for ( i=0; ih, it->k, it->l); - inty *= num_equivs(it->h, it->k, it->l, mero); - set_intensity(input_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)); + inty *= (double)num_equivs(h, k, l, mero); + set_int(refl, inty); } } 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); + RefList *t = read_reflections(template); + RefList *new = template_reflections(input, t); + reflist_free(input); + input = new; } - write_reflections(output, write_items, input_ref, esds, phases, - NULL, cell); + write_reflist(output, input, cell); - delete_items(input_items); - delete_items(write_items); + reflist_free(input); return 0; } -- cgit v1.2.3