From 3849a9692813ddd850b5e2ce1bec8a32b43b5900 Mon Sep 17 00:00:00 2001 From: Thomas White Date: Fri, 4 Dec 2009 14:17:35 +0100 Subject: Add new program: get_hkl, for generating ideal intensity lists --- src/Makefile.am | 11 +++++-- src/get_hkl.c | 78 +++++++++++++++++++++++++++++++++++++++++++++++++ src/process_hkl.c | 70 +------------------------------------------- src/reflections.c | 87 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/reflections.h | 29 +++++++++++++++++++ 5 files changed, 203 insertions(+), 72 deletions(-) create mode 100644 src/get_hkl.c create mode 100644 src/reflections.c create mode 100644 src/reflections.h (limited to 'src') diff --git a/src/Makefile.am b/src/Makefile.am index efaf09a8..81b52045 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,10 +1,15 @@ -bin_PROGRAMS = pattern_sim process_hkl +bin_PROGRAMS = pattern_sim process_hkl get_hkl AM_CFLAGS = -Wall pattern_sim_SOURCES = pattern_sim.c diffraction.c utils.c image.c cell.c \ - hdf5-file.c ewald.c detector.c sfac.c intensities.c + hdf5-file.c ewald.c detector.c sfac.c intensities.c \ + reflections.c pattern_sim_LDADD = @LIBS@ -process_hkl_SOURCES = process_hkl.c sfac.c statistics.c cell.c utils.c +process_hkl_SOURCES = process_hkl.c sfac.c statistics.c cell.c utils.c \ + reflections.c process_hkl_LDADD = @LIBS@ + +get_hkl_SOURCES = get_hkl.c sfac.c cell.c utils.c reflections.c +get_hkl_LDADD = @LIBS@ diff --git a/src/get_hkl.c b/src/get_hkl.c new file mode 100644 index 00000000..907a47d4 --- /dev/null +++ b/src/get_hkl.c @@ -0,0 +1,78 @@ +/* + * get_hkl.c + * + * Small program to write out a list of h,k,l,I values given a structure + * + * (c) 2006-2009 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"); +} + + +int main(int argc, char *argv[]) +{ + int c; + double *ref; + struct molecule *mol; + + /* Long options */ + const struct option longopts[] = { + {"help", 0, NULL, 'h'}, + {0, 0, NULL, 0} + }; + + /* Short options */ + while ((c = getopt_long(argc, argv, "hi:e:r", longopts, NULL)) != -1) { + + switch (c) { + case 'h' : { + show_help(argv[0]); + return 0; + } + + case 0 : { + break; + } + + default : { + return 1; + } + } + + } + + mol = load_molecule(); + get_reflections_cached(mol, eV_to_J(2.0e3)); + ref = ideal_intensities(mol->reflections); + write_reflections("results/ideal-reflections.hkl", NULL, ref, 1, + mol->cell); + + return 0; +} diff --git a/src/process_hkl.c b/src/process_hkl.c index aed9856e..9142d5c7 100644 --- a/src/process_hkl.c +++ b/src/process_hkl.c @@ -24,6 +24,7 @@ #include "utils.h" #include "statistics.h" #include "sfac.h" +#include "reflections.h" /* Number of divisions for R vs |q| graphs */ @@ -124,72 +125,6 @@ static void write_RvsQ(const char *name, double *ref, double *trueref, } -static void write_reflections(const char *filename, unsigned int *counts, - double *ref, int zone_axis, UnitCell *cell) -{ - FILE *fh; - signed int h, k, l; - - fh = fopen(filename, "w"); - - /* Write spacings and angle if zone axis pattern */ - if ( zone_axis ) { - double a, b, c, alpha, beta, gamma; - cell_get_parameters(cell, &a, &b, &c, &alpha, &beta, &gamma); - fprintf(fh, "a %5.3f nm\n", a*1e9); - fprintf(fh, "b %5.3f nm\n", b*1e9); - fprintf(fh, "angle %5.3f deg\n", rad2deg(gamma)); - fprintf(fh, "scale 10\n"); - } - - for ( h=-INDMAX; hreflections); - write_reflections("results/ideal-reflections.hkl", NULL, trueref, 1, - mol->cell); - if ( strcmp(filename, "-") == 0 ) { fh = stdin; } else { diff --git a/src/reflections.c b/src/reflections.c new file mode 100644 index 00000000..5790b543 --- /dev/null +++ b/src/reflections.c @@ -0,0 +1,87 @@ +/* + * reflections.c + * + * Utilities for handling reflections + * + * (c) 2007-2009 Thomas White + * + * Part of CrystFEL - crystallography with a FEL + * + */ + + +#include +#include +#include +#include +#include + +#include "utils.h" +#include "cell.h" +#include "reflections.h" + + +void write_reflections(const char *filename, unsigned int *counts, + double *ref, int zone_axis, UnitCell *cell) +{ + FILE *fh; + signed int h, k, l; + + fh = fopen(filename, "w"); + + /* Write spacings and angle if zone axis pattern */ + if ( zone_axis ) { + double a, b, c, alpha, beta, gamma; + cell_get_parameters(cell, &a, &b, &c, &alpha, &beta, &gamma); + fprintf(fh, "a %5.3f nm\n", a*1e9); + fprintf(fh, "b %5.3f nm\n", b*1e9); + fprintf(fh, "angle %5.3f deg\n", rad2deg(gamma)); + fprintf(fh, "scale 10\n"); + } + + for ( h=-INDMAX; h + * + * Part of CrystFEL - crystallography with a FEL + * + */ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#ifndef REFLECTIONS_H +#define REFLECTIONS_H + + +#include "cell.h" + + +extern void write_reflections(const char *filename, unsigned int *counts, + double *ref, int zone_axis, UnitCell *cell); + +extern double *ideal_intensities(double complex *sfac); + + +#endif /* REFLECTIONS_H */ -- cgit v1.2.3