From af0c25e17b4b37d74f6589f746b0763fd59b0c38 Mon Sep 17 00:00:00 2001 From: Thomas White Date: Fri, 16 Jul 2010 18:42:02 +0200 Subject: get_hkl: Do twinning with proper regard to group theory and stuff --- src/Makefile.am | 2 +- src/Makefile.in | 4 +- src/get_hkl.c | 184 +++++++++++++++++++++++++++++++++++++++++++++----------- 3 files changed, 152 insertions(+), 38 deletions(-) diff --git a/src/Makefile.am b/src/Makefile.am index 8c78fc48..b9b70c22 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -35,7 +35,7 @@ hdfsee_SOURCES = hdfsee.c displaywindow.c render.c hdf5-file.c utils.c image.c \ hdfsee_LDADD = @LIBS@ endif -get_hkl_SOURCES = get_hkl.c sfac.c cell.c utils.c reflections.c +get_hkl_SOURCES = get_hkl.c sfac.c cell.c utils.c reflections.c symmetry.c get_hkl_LDADD = @LIBS@ compare_hkl_SOURCES = compare_hkl.c sfac.c cell.c utils.c reflections.c \ diff --git a/src/Makefile.in b/src/Makefile.in index 31de7f83..7c8c1028 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -64,7 +64,7 @@ am_compare_hkl_OBJECTS = compare_hkl.$(OBJEXT) sfac.$(OBJEXT) \ compare_hkl_OBJECTS = $(am_compare_hkl_OBJECTS) compare_hkl_DEPENDENCIES = am_get_hkl_OBJECTS = get_hkl.$(OBJEXT) sfac.$(OBJEXT) cell.$(OBJEXT) \ - utils.$(OBJEXT) reflections.$(OBJEXT) + utils.$(OBJEXT) reflections.$(OBJEXT) symmetry.$(OBJEXT) get_hkl_OBJECTS = $(am_get_hkl_OBJECTS) get_hkl_DEPENDENCIES = am__hdfsee_SOURCES_DIST = hdfsee.c displaywindow.c render.c \ @@ -253,7 +253,7 @@ indexamajig_LDADD = @LIBS@ @HAVE_GTK_TRUE@ filters.c @HAVE_GTK_TRUE@hdfsee_LDADD = @LIBS@ -get_hkl_SOURCES = get_hkl.c sfac.c cell.c utils.c reflections.c +get_hkl_SOURCES = get_hkl.c sfac.c cell.c utils.c reflections.c symmetry.c get_hkl_LDADD = @LIBS@ compare_hkl_SOURCES = compare_hkl.c sfac.c cell.c utils.c reflections.c \ statistics.c diff --git a/src/get_hkl.c b/src/get_hkl.c index 6b6b71be..1052d786 100644 --- a/src/get_hkl.c +++ b/src/get_hkl.c @@ -24,6 +24,7 @@ #include "utils.h" #include "sfac.h" #include "reflections.h" +#include "symmetry.h" static void show_help(const char *s) @@ -36,7 +37,9 @@ static void show_help(const char *s) "\n" " -t, --template= Only include reflections mentioned in file.\n" " --poisson Simulate Poisson samples.\n" -" --twin Generate twinned data.\n" +" -y, --symmetry= The symmetry of the input file (-i).\n" +" -w, --twin= Generate twinned data according to the given\n" +" point group.\n" " -o, --output= Output filename (default: stdout).\n" " -i, --intensities= Read intensities from file instead of\n" " calculating them from scratch. You might use\n" @@ -69,6 +72,132 @@ static void noisify_reflections(double *ref) } +static void scold_user_about_symmetry(signed int h, signed int k, signed int l, + signed int he, signed int ke, + signed int le) +{ + ERROR("Merohedrally equivalent reflection (%i %i %i) found for " + "%i %i %i.\n", he, ke, le, h, k, l); + ERROR("This indicates that you lied to me about the symmetry of the " + "input reflections. "); + ERROR("I won't be able to give you a meaningful result in this " + "situation, so I'm going to give up right now. "); + ERROR("Please reconsider your previous processing of the data, and " + "perhaps try again with a lower symmetry for the '-y' option.\n"); +} + + +static int find_unique_equiv(ReflItemList *items, signed int h, signed int k, + signed int l, const char *mero, signed int *hu, + signed int *ku, signed int *lu) +{ + int i; + + for ( i=0; ih; k = it->k; l = it->l; + + /* None of the equivalent reflections should exist in the + * input dataset. That would indicate that the user lied about + * the input symmetry. + * + * Start from j=1 to ignore the reflection itself. + */ + for ( j=1; j INDMAX ) { - set_intensity(ideal_ref, h, k, l, 0.0); - continue; - } - - a = lookup_intensity(ideal_ref, h, k, l); - b = lookup_intensity(ideal_ref, k, h, -l); - c = lookup_intensity(ideal_ref, -(h+k), k, -l); - d = lookup_intensity(ideal_ref, -(h+k), h, l); - - t = (a+b+c+d)/4.0; - - set_intensity(ideal_ref, h, k, l, t); - set_intensity(ideal_ref, k, h, -l, t); - set_intensity(ideal_ref, -(h+k), h, l, t); - set_intensity(ideal_ref, -(h+k), k, -l, t); - - } - } - } - + if ( holo != NULL ) { + ReflItemList *new; + STATUS("Twinning from %s into %s\n", mero, holo); + new = twin_reflections(ideal_ref, input_items, holo, mero); + delete_items(input_items); + input_items = new; } if ( template ) { -- cgit v1.2.3