/* * reflist-utils.c * * Utilities to complement the core reflist.c * * (c) 2006-2011 Thomas White * * Part of CrystFEL - crystallography with a FEL * */ #include #include #include "reflist.h" #include "cell.h" #include "utils.h" #include "reflist-utils.h" #include "symmetry.h" /** * SECTION:reflist-utils * @short_description: Reflection list utilities * @title: RefList utilities * @section_id: * @see_also: * @include: "reflist-utils.h" * @Image: * * There are some utility functions associated with the core %RefList. **/ double *intensities_from_list(RefList *list) { Reflection *refl; RefListIterator *iter; double *out = new_list_intensity(); for ( refl = first_refl(list, &iter); refl != NULL; refl = next_refl(refl, iter) ) { signed int h, k, l; double intensity = get_intensity(refl); get_indices(refl, &h, &k, &l); set_intensity(out, h, k, l, intensity); } return out; } double *phases_from_list(RefList *list) { Reflection *refl; RefListIterator *iter; double *out = new_list_phase(); for ( refl = first_refl(list, &iter); refl != NULL; refl = next_refl(refl, iter) ) { signed int h, k, l; double phase = get_phase(refl); get_indices(refl, &h, &k, &l); set_phase(out, h, k, l, phase); } return out; } unsigned char *flags_from_list(RefList *list) { Reflection *refl; RefListIterator *iter; unsigned char *out = new_list_flag(); for ( refl = first_refl(list, &iter); refl != NULL; refl = next_refl(refl, iter) ) { signed int h, k, l; get_indices(refl, &h, &k, &l); set_flag(out, h, k, l, 1); } return out; } int check_list_symmetry(RefList *list, const SymOpList *sym) { unsigned char *flags; Reflection *refl; RefListIterator *iter; SymOpMask *mask; flags = flags_from_list(list); mask = new_symopmask(sym); if ( mask == NULL ) { ERROR("Couldn't create mask for list symmetry check.\n"); return 1; } for ( refl = first_refl(list, &iter); refl != NULL; refl = next_refl(refl, iter) ) { int j; int found = 0; signed int h, k, l; int n; get_indices(refl, &h, &k, &l); special_position(sym, mask, h, k, l); n = num_equivs(sym, mask); STATUS("%i equivs: %3i %3i %3i\n", n, h, k, l); for ( j=0; j INDMAX ) continue; if ( abs(le) > INDMAX ) continue; if ( abs(ke) > INDMAX ) continue; found += lookup_flag(flags, he, ke, le); } if ( found > 1 ) { free(flags); free_symopmask(mask); STATUS("Found %i %i %i twice\n", h, k, l); return 1; /* Symmetry is wrong! */ } } free(flags); free_symopmask(mask); return 0; } int find_equiv_in_list(RefList *list, signed int h, signed int k, signed int l, const SymOpList *sym, signed int *hu, signed int *ku, signed int *lu) { int i; int found = 0; for ( i=0; i