/* * 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" " -i, --intensities= Read intensities from file instead of\n" " calculating them from scratch. You might use\n" " this if you need to apply noise or twinning.\n" " -p, --pdb= PDB file from which to get the structure.\n" ); } /* 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); } } } } if ( template ) { /* Write out only reflections which are in the template * (and which we have in the input) */ ReflItemList *template_items; template_items = read_reflections(template, NULL, NULL, NULL); write_items = intersection_items(input_items, template_items); delete_items(template_items); } else { /* Write out all reflections */ write_items = new_items(); union_items(write_items, input_items); } write_reflections(output, write_items, ideal_ref, phases, NULL, mol->cell); delete_items(input_items); delete_items(write_items); return 0; }