From fb6a2d1f8cd57b8e40fd7b33dfebe07057cfc1e9 Mon Sep 17 00:00:00 2001 From: Thomas White Date: Sun, 30 Mar 2014 20:54:23 +0200 Subject: check_hkl: Add Wilson plot --- src/check_hkl.c | 103 ++++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 96 insertions(+), 7 deletions(-) diff --git a/src/check_hkl.c b/src/check_hkl.c index c2ab0788..db41fac5 100644 --- a/src/check_hkl.c +++ b/src/check_hkl.c @@ -3,11 +3,11 @@ * * Characterise reflection lists * - * Copyright © 2012-2013 Deutsches Elektronen-Synchrotron DESY, + * Copyright © 2012-2014 Deutsches Elektronen-Synchrotron DESY, * a research centre of the Helmholtz Association. * * Authors: - * 2010-2013 Thomas White + * 2010-2014 Thomas White * * This file is part of CrystFEL. * @@ -55,15 +55,89 @@ static void show_help(const char *s) " -h, --help Display this help message.\n" " -y, --symmetry= The symmetry of the input file.\n" " -p, --pdb= PDB file to use.\n" -" --rmin= Fix lower resolution limit for resolution shells. (m^-1).\n" -" --rmax= Fix upper resolution limit for resolution shells. (m^-1).\n" +" --rmin= Lower resolution limit (1/d in m^-1).\n" +" --rmax= Upper resolution limit (1/d in m^-1).\n" " --sigma-cutoff= Discard reflections with I/sigma(I) < n.\n" -" --nshells= Use resolution shells.\n" -" --shell-file= Write resolution shells to .\n" +" --nshells= Use resolution shells or bins.\n" +" --wilson Calculate a Wilson plot\n" +" --shell-file= Write results table to .\n" "\n"); } +static void wilson_plot(RefList *list, UnitCell *cell, const SymOpList *sym, + double rmin_fix, double rmax_fix, int nbins, + const char *filename) +{ + double rmin, rmax; + double s2min, s2max, s2step; + Reflection *refl; + RefListIterator *iter; + FILE *fh; + double *plot_i; + int *plot_n; + int i; + + resolution_limits(list, cell, &rmin, &rmax); + STATUS("1/d goes from %f to %f nm^-1\n", rmin/1e9, rmax/1e9); + + /* Widen the range just a little bit */ + rmin -= 0.001e9; + rmax += 0.001e9; + + /* Fixed resolution shells if needed */ + if ( rmin_fix > 0.0 ) rmin = rmin_fix; + if ( rmax_fix > 0.0 ) rmax = rmax_fix; + + s2min = pow(rmin/2.0, 2.0); + s2max = pow(rmax/2.0, 2.0); + s2step = (s2max - s2min)/nbins; + + plot_i = malloc(nbins*sizeof(double)); + if ( plot_i == NULL ) return; + for ( i=0; i\n"); + for ( i=0; i