/* * 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" " -o --output= Output filename (default: stdout).\n"); } static double *template_reflections(double *ref, const char *filename) { char *rval; double *out; FILE *fh; fh = fopen(filename, "r"); if ( fh == NULL ) { return NULL; } out = new_list_intensity(); do { char line[1024]; double val; 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; val = lookup_intensity(ref, h, k, l); set_intensity(out, h, k, l, val); } while ( rval != NULL ); fclose(fh); return out; } /* Apply Poisson noise to all reflections */ static void noisify_reflections(double *ref) { signed int h, k, l; for ( h=-INDMAX; hreflections); if ( template != NULL ) { double *tref; tref = template_reflections(ref, template); if ( tref == NULL ) { ERROR("Couldn't read template file!\n"); return 1; } free(ref); ref = tref; } if ( config_noisify ) noisify_reflections(ref); write_reflections(output, NULL, ref, 1, mol->cell); return 0; }