/* * get_hkl.c * * Small program to write out a list of h,k,l,I values given a structure * * (c) 2006-2010 Thomas White * * Part of CrystFEL - crystallography with a FEL * */ #ifdef HAVE_CONFIG_H #include #endif #include #include #include #include #include #include #include "utils.h" #include "sfac.h" #include "reflections.h" static void show_help(const char *s) { printf("Syntax: %s [options]\n\n", s); printf( "Write idealised intensity lists.\n" "\n" " -h, --help Display this help message.\n" "\n" " -t, --template= Only include reflections mentioned in file.\n" " --poisson Simulate Poisson samples.\n" " --twin Generate twinned data.\n" " -o, --output= Output filename (default: stdout).\n" " --zone-axis Generate hk0 intensities only (and add\n" " Synth2D-style header.\n" " -i, --intensities= Read intensities from file instead of\n" " calculating them from scratch.\n" ); } static int template_reflections(const char *filename, unsigned int *counts) { char *rval; FILE *fh; fh = fopen(filename, "r"); if ( fh == NULL ) { return 1; } do { char line[1024]; int r; signed int h, k, l; rval = fgets(line, 1023, fh); r = sscanf(line, "%i %i %i", &h, &k, &l); if ( r != 3 ) continue; set_count(counts, h, k, l, 1); } while ( rval != NULL ); fclose(fh); return 0; } /* Apply Poisson noise to all reflections */ static void noisify_reflections(double *ref) { signed int h, k, l; for ( h=-INDMAX; h 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); } } } } write_reflections(output, counts, ideal_ref, config_za, mol->cell); return 0; }