From 6b1108c5576311a212a366b95bc6ba13ccf662bf Mon Sep 17 00:00:00 2001 From: Thomas White Date: Thu, 26 Aug 2010 17:26:09 +0200 Subject: compare_hkl: Add Luzzati plot --- src/compare_hkl.c | 95 +++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 92 insertions(+), 3 deletions(-) (limited to 'src/compare_hkl.c') diff --git a/src/compare_hkl.c b/src/compare_hkl.c index b58e6d25..6f033400 100644 --- a/src/compare_hkl.c +++ b/src/compare_hkl.c @@ -28,6 +28,10 @@ #include "symmetry.h" +/* Number of bins for Luzzati plot */ +#define NBINS (10) + + static void show_help(const char *s) { printf("Syntax: %s [options] \n\n", s); @@ -41,6 +45,85 @@ static void show_help(const char *s) } +static void plot_luzzati(const double *ref1, const double *ref2, + ReflItemList *items, double scale, UnitCell *cell) +{ + double num[NBINS]; + double den[NBINS]; + double rmin, rmax, rstep; + int i; + FILE *fh; + + if ( cell == NULL ) { + ERROR("Need the unit cell to plot the Luzzati plot.\n"); + return; + } + + fh = fopen("luzzati.dat", "w"); + if ( fh == NULL ) { + ERROR("Couldn't open 'luzzati.dat'\n"); + return; + } + + for ( i=0; ih; k = it->k; l = it->l; + + res = 2.0*resolution(cell, h, k, l); + if ( res > rmax ) rmax = res; + if ( res < rmin ) rmin = res; + + } + rstep = (rmax-rmin) / NBINS; + + for ( i=0; ih; k = it->k; l = it->l; + + res = 2.0*resolution(cell, h, k, l); + + bin = (res-rmin)/rstep; + + i1 = lookup_intensity(ref1, h, k, l); + i2 = scale * lookup_intensity(ref2, h, k, l); + + num[bin] += pow(i1 - i2, 2.0); + den[bin] += pow(i1, 2.0); + + } + + for ( i=0; i