/* * compare_hkl.c * * Compare reflection lists * * (c) 2006-2011 Thomas White * * Part of CrystFEL - crystallography with a FEL * */ #ifdef HAVE_CONFIG_H #include #endif #include #include #include #include #include #include #include #include #include "utils.h" #include "statistics.h" #include "symmetry.h" #include "reflist-utils.h" /* Number of bins for plot of resolution shells */ #define NBINS (10) static void show_help(const char *s) { printf("Syntax: %s [options] \n\n", s); printf( "Compare intensity lists.\n" "\n" " -h, --help Display this help message.\n" " -o, --ratio= Specify output filename for ratios.\n" " -y, --symmetry= The symmetry of both the input files.\n" " -p, --pdb= PDB file to use (default: molecule.pdb).\n" " --shells Plot the figures of merit by resolution.\n" " --rmin= Fix lower resolution limit for --shells (m^-1).\n" " --rmax= Fix upper resolution limit for --shells (m^-1).\n" "\n"); } static void plot_shells(RefList *list1, RefList *list2, double scale, UnitCell *cell, double rmin_fix, double rmax_fix) { double num[NBINS]; int cts[NBINS]; unsigned int measurements[NBINS]; unsigned int measured[NBINS]; double total_vol, vol_per_shell; double rmins[NBINS]; double rmaxs[NBINS]; double snr[NBINS]; double rmin, rmax; int i; Reflection *refl1; RefListIterator *iter; FILE *fh; double den; int ctot, nout; if ( cell == NULL ) { ERROR("Need the unit cell to plot resolution shells.\n"); return; } for ( i=0; i 0.0 ) rmin = rmin_fix; if ( rmax_fix > 0.0 ) rmax = rmax_fix; /* Calculate the resolution bins */ total_vol = pow(rmax, 3.0) - pow(rmin, 3.0); vol_per_shell = total_vol / NBINS; rmins[0] = rmin; for ( i=1; irmins[j]) && (d<=rmaxs[j]) ) { bin = j; break; } } /* Outside resolution range? */ if ( bin == -1 ) { nout++; continue; } refl2 = find_refl(list2, h, k, l); if ( refl2 == NULL ) continue; i1 = get_intensity(refl1); i2 = scale * get_intensity(refl2); num[bin] += fabs(i1 - i2); den += i1 + i2; ctot++; cts[bin]++; } if ( nout ) { STATUS("Warning; %i reflections outside resolution range.\n", nout); } fh = fopen("shells.dat", "w"); if ( fh == NULL ) { ERROR("Couldn't open 'shells.dat'\n"); return; } fprintf(fh, "1/d centre Rsplit / %%\n"); for ( i=0; i